Skip to content

Commit

Permalink
🎨 Standardize G-code reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Sep 9, 2021
1 parent 650e73a commit 79c72ed
Show file tree
Hide file tree
Showing 48 changed files with 1,359 additions and 1,169 deletions.
10 changes: 5 additions & 5 deletions Marlin/src/HAL/AVR/pinsDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static void print_is_also_tied() { SERIAL_ECHOPGM(" is also tied to this pin");

inline void com_print(const uint8_t N, const uint8_t Z) {
const uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
SERIAL_ECHOPAIR(" COM", AS_CHAR('0' + N));
SERIAL_ECHOPAIR(" COM", AS_DIGIT(N));
SERIAL_CHAR(Z);
SERIAL_ECHOPAIR(": ", int((*TCCRA >> (6 - Z * 2)) & 0x03));
}
Expand All @@ -247,7 +247,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
uint8_t WGM = (((*TCCRB & _BV(WGM_2)) >> 1) | (*TCCRA & (_BV(WGM_0) | _BV(WGM_1))));
if (N == 4) WGM |= ((*TCCRB & _BV(WGM_3)) >> 1);

SERIAL_ECHOPAIR(" TIMER", AS_CHAR(T + '0'));
SERIAL_ECHOPAIR(" TIMER", AS_DIGIT(T));
SERIAL_CHAR(L);
SERIAL_ECHO_SP(3);

Expand All @@ -262,11 +262,11 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
SERIAL_ECHOPAIR(" WGM: ", WGM);
com_print(T,L);
SERIAL_ECHOPAIR(" CS: ", (*TCCRB & (_BV(CS_0) | _BV(CS_1) | _BV(CS_2)) ));
SERIAL_ECHOPAIR(" TCCR", AS_CHAR(T + '0'), "A: ", *TCCRA);
SERIAL_ECHOPAIR(" TCCR", AS_CHAR(T + '0'), "B: ", *TCCRB);
SERIAL_ECHOPAIR(" TCCR", AS_DIGIT(T), "A: ", *TCCRA);
SERIAL_ECHOPAIR(" TCCR", AS_DIGIT(T), "B: ", *TCCRB);

const uint8_t *TMSK = (uint8_t*)TIMSK(T);
SERIAL_ECHOPAIR(" TIMSK", AS_CHAR(T + '0'), ": ", *TMSK);
SERIAL_ECHOPAIR(" TIMSK", AS_DIGIT(T), ": ", *TMSK);

const uint8_t OCIE = L - 'A' + 1;
if (N == 3) { if (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6) err_is_counter(); }
Expand Down
47 changes: 44 additions & 3 deletions Marlin/src/core/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@
#define STR_OFF "OFF"
#define STR_ENDSTOP_HIT "TRIGGERED"
#define STR_ENDSTOP_OPEN "open"
#define STR_HOTEND_OFFSET "Hotend offsets:"
#define STR_DUPLICATION_MODE "Duplication mode: "
#define STR_SOFT_ENDSTOPS "Soft endstops: "
#define STR_SOFT_MIN " Min: "
#define STR_SOFT_MAX " Max: "

Expand Down Expand Up @@ -262,6 +260,49 @@
#define STR_REMINDER_SAVE_SETTINGS "Remember to save!"
#define STR_PASSWORD_SET "Password is "

// Settings Report Strings
#define STR_Z_AUTO_ALIGN "Z Auto-Align"
#define STR_BACKLASH_COMPENSATION "Backlash compensation"
#define STR_DELTA_SETTINGS "Delta settings (L<diagonal-rod> R<radius> H<height> S<segments-per-sec> XYZ<tower-angle-trim> ABC<rod-trim>)"
#define STR_SCARA_SETTINGS "SCARA settings"
#define STR_SCARA_S "S<seg-per-sec>"
#define STR_SCARA_P_T_Z "P<theta-psi-offset> T<theta-offset> Z<home-offset>"
#define STR_ENDSTOP_ADJUSTMENT "Endstop adjustment"
#define STR_SKEW_FACTOR "Skew Factor"
#define STR_FILAMENT_SETTINGS "Filament settings"
#define STR_MAX_ACCELERATION "Max Acceleration (units/s2)"
#define STR_MAX_FEEDRATES "Max feedrates (units/s)"
#define STR_ACCELERATION_P_R_T "Acceleration (units/s2) (P<print-accel> R<retract-accel> T<travel-accel>)"
#define STR_TOOL_CHANGING "Tool-changing"
#define STR_HOTEND_OFFSETS "Hotend offsets"
#define STR_SERVO_ANGLES "Servo Angles"
#define STR_HOTEND_PID "Hotend PID"
#define STR_BED_PID "Bed PID"
#define STR_CHAMBER_PID "Chamber PID"
#define STR_STEPS_PER_UNIT "Steps per unit"
#define STR_LINEAR_ADVANCE "Linear Advance"
#define STR_CONTROLLER_FAN "Controller Fan"
#define STR_STEPPER_MOTOR_CURRENTS "Stepper motor currents"
#define STR_RETRACT_S_F_Z "Retract (S<length> F<feedrate> Z<lift>)"
#define STR_RECOVER_S_F "Recover (S<length> F<feedrate>)"
#define STR_AUTO_RETRACT_S "Auto-Retract (S<enable>)"
#define STR_FILAMENT_LOAD_UNLOAD "Filament load/unload"
#define STR_POWER_LOSS_RECOVERY "Power-loss recovery"
#define STR_FILAMENT_RUNOUT_SENSOR "Filament runout sensor"
#define STR_DRIVER_STEPPING_MODE "Driver stepping mode"
#define STR_STEPPER_DRIVER_CURRENT "Stepper driver current"
#define STR_HYBRID_THRESHOLD "Hybrid Threshold"
#define STR_STALLGUARD_THRESHOLD "StallGuard threshold"
#define STR_HOME_OFFSET "Home offset"
#define STR_SOFT_ENDSTOPS "Soft endstops"
#define STR_MATERIAL_HEATUP "Material heatup parameters"
#define STR_LCD_CONTRAST "LCD Contrast"
#define STR_LCD_BRIGHTNESS "LCD Brightness"
#define STR_UI_LANGUAGE "UI Language"
#define STR_Z_PROBE_OFFSET "Z-Probe Offset"
#define STR_TEMPERATURE_UNITS "Temperature Units"
#define STR_USER_THERMISTORS "User thermistors"

//
// Endstop Names used by Endstops::report_states
//
Expand Down Expand Up @@ -290,7 +331,7 @@

#define STR_Z_PROBE "z_probe"
#define STR_PROBE_EN "probe_en"
#define STR_FILAMENT_RUNOUT_SENSOR "filament"
#define STR_FILAMENT "filament"

// General axis names
#define STR_X "X"
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/core/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ struct IF<true, L, R> { typedef L type; };
#define LOGICAL_AXIS_ELEM(O) LOGICAL_AXIS_LIST(O.e, O.x, O.y, O.z, O.i, O.j, O.k)
#define LOGICAL_AXIS_DECL(T,V) LOGICAL_AXIS_LIST(T e=V, T x=V, T y=V, T z=V, T i=V, T j=V, T k=V)

#define LOGICAL_AXES_STRING LOGICAL_AXIS_GANG("E", "X", "Y", "Z", AXIS4_STR, AXIS5_STR, AXIS6_STR)

#if HAS_EXTRUDERS
#define LIST_ITEM_E(N) , N
#define CODE_ITEM_E(N) ; N
Expand Down
11 changes: 4 additions & 7 deletions Marlin/src/feature/fwretract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ FWRetract fwretract; // Single instance - this calls the constructor
#include "../module/planner.h"
#include "../module/stepper.h"

#include "../gcode/parser.h"
#include "../gcode/gcode.h"

#if ENABLED(RETRACT_SYNC_MIXING)
#include "mixing.h"
Expand Down Expand Up @@ -214,8 +214,7 @@ void FWRetract::M207() {
if (parser.seenval('W')) settings.swap_retract_length = parser.value_axis_units(E_AXIS);
}

void FWRetract::M207_report(const bool forReplay/*=false*/) {
if (!forReplay) { SERIAL_ECHO_MSG("; Retract: S<length> F<units/m> Z<lift>"); SERIAL_ECHO_START(); }
void FWRetract::M207_report() {
SERIAL_ECHOLNPAIR_P(
PSTR(" M207 S"), LINEAR_UNIT(settings.retract_length)
, PSTR(" W"), LINEAR_UNIT(settings.swap_retract_length)
Expand All @@ -240,8 +239,7 @@ void FWRetract::M208() {
if (parser.seen('W')) settings.swap_retract_recover_extra = parser.value_axis_units(E_AXIS);
}

void FWRetract::M208_report(const bool forReplay/*=false*/) {
if (!forReplay) { SERIAL_ECHO_MSG("; Recover: S<length> F<units/m>"); SERIAL_ECHO_START(); }
void FWRetract::M208_report() {
SERIAL_ECHOLNPAIR(
" M208 S", LINEAR_UNIT(settings.retract_recover_extra)
, " W", LINEAR_UNIT(settings.swap_retract_recover_extra)
Expand All @@ -262,8 +260,7 @@ void FWRetract::M208_report(const bool forReplay/*=false*/) {
enable_autoretract(parser.value_bool());
}

void FWRetract::M209_report(const bool forReplay/*=false*/) {
if (!forReplay) { SERIAL_ECHO_MSG("; Auto-Retract: S=0 to disable, 1 to interpret E-only moves as retract/recover"); SERIAL_ECHO_START(); }
void FWRetract::M209_report() {
SERIAL_ECHOLNPAIR(" M209 S", AS_DIGIT(autoretract_enabled));
}

Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/feature/fwretract.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ class FWRetract {

static void retract(const bool retracting OPTARG(HAS_MULTI_EXTRUDER, bool swapping = false));

static void M207_report();
static void M207();
static void M207_report(const bool forReplay=false);
static void M208_report();
static void M208();
static void M208_report(const bool forReplay=false);
#if ENABLED(FWRETRACT_AUTORETRACT)
static void M209_report();
static void M209();
static void M209_report(const bool forReplay=false);
#endif
};

Expand Down
14 changes: 14 additions & 0 deletions Marlin/src/gcode/bedlevel/M420.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,18 @@ void GcodeSuite::M420() {
report_current_position();
}

void GcodeSuite::M420_report(const bool forReplay/*=true*/) {
report_heading_etc(forReplay, PSTR(
TERN(MESH_BED_LEVELING, "Mesh Bed Leveling", TERN(AUTO_BED_LEVELING_UBL, "Unified Bed Leveling", "Auto Bed Leveling"))
));
SERIAL_ECHOPAIR_P(
PSTR(" M420 S"), planner.leveling_active
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
, SP_Z_STR, LINEAR_UNIT(planner.z_fade_height)
#endif
, " ; Leveling "
);
serialprintln_onoff(planner.leveling_active);
}

#endif // HAS_LEVELING
34 changes: 24 additions & 10 deletions Marlin/src/gcode/calibrate/G34_M422.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,21 +475,13 @@ void GcodeSuite::G34() {
*/
void GcodeSuite::M422() {

if (!parser.seen_any()) return M422_report();

if (parser.seen('R')) {
z_stepper_align.reset_to_default();
return;
}

if (!parser.seen_any()) {
LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS)
SERIAL_ECHOLNPAIR_P(PSTR("M422 S"), i + 1, SP_X_STR, z_stepper_align.xy[i].x, SP_Y_STR, z_stepper_align.xy[i].y);
#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS)
SERIAL_ECHOLNPAIR_P(PSTR("M422 W"), i + 1, SP_X_STR, z_stepper_align.stepper_xy[i].x, SP_Y_STR, z_stepper_align.stepper_xy[i].y);
#endif
return;
}

const bool is_probe_point = parser.seen('S');

if (TERN0(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, is_probe_point && parser.seen('W'))) {
Expand Down Expand Up @@ -545,4 +537,26 @@ void GcodeSuite::M422() {
pos_dest[position_index] = pos;
}

void GcodeSuite::M422_report(const bool forReplay/*=true*/) {
report_heading(forReplay, PSTR(STR_Z_AUTO_ALIGN));
LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) {
report_echo_start(forReplay);
SERIAL_ECHOLNPAIR_P(
PSTR(" M422 S"), i + 1,
SP_X_STR, z_stepper_align.xy[i].x,
SP_Y_STR, z_stepper_align.xy[i].y
);
}
#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) {
report_echo_start(forReplay);
SERIAL_ECHOLNPAIR_P(
PSTR(" M422 W"), i + 1,
SP_X_STR, z_stepper_align.stepper_xy[i].x,
SP_Y_STR, z_stepper_align.stepper_xy[i].y
);
}
#endif
}

#endif // Z_STEPPER_AUTO_ALIGN
18 changes: 18 additions & 0 deletions Marlin/src/gcode/calibrate/M425.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,22 @@ void GcodeSuite::M425() {
}
}

void GcodeSuite::M425_report(const bool forReplay/*=true*/) {
report_heading_etc(forReplay, PSTR(STR_BACKLASH_COMPENSATION));
SERIAL_ECHOLNPAIR_P(
PSTR(" M425 F"), backlash.get_correction()
#ifdef BACKLASH_SMOOTHING_MM
, PSTR(" S"), LINEAR_UNIT(backlash.smoothing_mm)
#endif
, LIST_N(DOUBLE(LINEAR_AXES),
SP_X_STR, LINEAR_UNIT(backlash.distance_mm.x),
SP_Y_STR, LINEAR_UNIT(backlash.distance_mm.y),
SP_Z_STR, LINEAR_UNIT(backlash.distance_mm.z),
SP_I_STR, LINEAR_UNIT(backlash.distance_mm.i),
SP_J_STR, LINEAR_UNIT(backlash.distance_mm.j),
SP_K_STR, LINEAR_UNIT(backlash.distance_mm.k)
)
);
}

#endif // BACKLASH_GCODE
36 changes: 36 additions & 0 deletions Marlin/src/gcode/calibrate/M665.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#if ENABLED(DELTA)

#include "../../module/delta.h"

/**
* M665: Set delta configurations
*
Expand All @@ -45,6 +46,8 @@
* C = Gamma (Tower 3) diagonal rod trim
*/
void GcodeSuite::M665() {
if (!parser.seen_any()) return M665_report();

if (parser.seenval('H')) delta_height = parser.value_linear_units();
if (parser.seenval('L')) delta_diagonal_rod = parser.value_linear_units();
if (parser.seenval('R')) delta_radius = parser.value_linear_units();
Expand All @@ -58,6 +61,22 @@
recalc_delta_settings();
}

void GcodeSuite::M665_report(const bool forReplay/*=true*/) {
report_heading_etc(forReplay, PSTR(STR_DELTA_SETTINGS));
SERIAL_ECHOLNPAIR_P(
PSTR(" M665 L"), LINEAR_UNIT(delta_diagonal_rod)
, PSTR(" R"), LINEAR_UNIT(delta_radius)
, PSTR(" H"), LINEAR_UNIT(delta_height)
, PSTR(" S"), segments_per_second
, SP_X_STR, LINEAR_UNIT(delta_tower_angle_trim.a)
, SP_Y_STR, LINEAR_UNIT(delta_tower_angle_trim.b)
, SP_Z_STR, LINEAR_UNIT(delta_tower_angle_trim.c)
, PSTR(" A"), LINEAR_UNIT(delta_diagonal_rod_trim.a)
, PSTR(" B"), LINEAR_UNIT(delta_diagonal_rod_trim.b)
, PSTR(" C"), LINEAR_UNIT(delta_diagonal_rod_trim.c)
);
}

#elif IS_SCARA

#include "../../module/scara.h"
Expand All @@ -68,6 +87,9 @@
* Parameters:
*
* S[segments-per-second] - Segments-per-second
*
* Without NO_WORKSPACE_OFFSETS:
*
* P[theta-psi-offset] - Theta-Psi offset, added to the shoulder (A/X) angle
* T[theta-offset] - Theta offset, added to the elbow (B/Y) angle
* Z[z-offset] - Z offset, added to Z
Expand All @@ -76,6 +98,8 @@
* B, T, and Y are all aliases for the elbow angle
*/
void GcodeSuite::M665() {
if (!parser.seen_any()) return M665_report();

if (parser.seenval('S')) segments_per_second = parser.value_float();

#if HAS_SCARA_OFFSET
Expand Down Expand Up @@ -107,6 +131,18 @@
#endif // HAS_SCARA_OFFSET
}

void GcodeSuite::M665_report(const bool forReplay/*=true*/) {
report_heading_etc(forReplay, PSTR(STR_SCARA_SETTINGS " (" STR_SCARA_S TERN_(HAS_SCARA_OFFSET, " " STR_SCARA_P_T_Z) ")"));
SERIAL_ECHOLNPAIR_P(
PSTR(" M665 S"), segments_per_second
#if HAS_SCARA_OFFSET
, SP_P_STR, scara_home_offset.a
, SP_T_STR, scara_home_offset.b
, SP_Z_STR, LINEAR_UNIT(scara_home_offset.z)
#endif
);
}

#endif

#endif // IS_KINEMATIC
Loading

0 comments on commit 79c72ed

Please sign in to comment.