Skip to content

Commit 877e102

Browse files
🏗️ Axis name arrays
Co-Authored-By: DerAndere <[email protected]>
1 parent 8b8defe commit 877e102

File tree

8 files changed

+13
-17
lines changed

8 files changed

+13
-17
lines changed

Marlin/src/HAL/AVR/pinsDebug.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
#define MULTI_NAME_PAD 26 // space needed to be pretty if not first name assigned to a pin
7575

7676
void PRINT_ARRAY_NAME(uint8_t x) {
77-
char *name_mem_pointer = (char*)pgm_read_ptr(&pin_array[x].name);
77+
char *name_mem_pointer = (PGM_P)pgm_read_ptr(&pin_array[x].name);
7878
LOOP_L_N(y, MAX_NAME_LENGTH) {
7979
char temp_char = pgm_read_byte(name_mem_pointer + y);
8080
if (temp_char != 0)

Marlin/src/core/serial.h

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ extern const char NUL_STR[], SP_P_STR[], SP_T_STR[],
3636
X_STR[], Y_STR[], Z_STR[], I_STR[], J_STR[], K_STR[], U_STR[], V_STR[], W_STR[], E_STR[],
3737
X_LBL[], Y_LBL[], Z_LBL[], I_LBL[], J_LBL[], K_LBL[], U_LBL[], V_LBL[], W_LBL[], E_LBL[];
3838

39+
PGM_P const SP_AXIS_LBL[] PROGMEM = LOGICAL_AXIS_ARRAY(SP_E_LBL, SP_X_LBL, SP_Y_LBL, SP_Z_LBL, SP_I_LBL, SP_J_LBL, SP_K_LBL, SP_U_LBL, SP_V_LBL, SP_W_LBL);
40+
PGM_P const SP_AXIS_STR[] PROGMEM = LOGICAL_AXIS_ARRAY(SP_E_STR, SP_X_STR, SP_Y_STR, SP_Z_STR, SP_I_STR, SP_J_STR, SP_K_STR, SP_U_STR, SP_V_STR, SP_W_STR);
41+
3942
//
4043
// Debugging flags for use by M111
4144
//

Marlin/src/core/utility.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void safe_delay(millis_t ms) {
126126
#if ABL_PLANAR
127127
SERIAL_ECHOPGM("ABL Adjustment");
128128
LOOP_NUM_AXES(a) {
129-
SERIAL_CHAR(' ', AXIS_CHAR(a));
129+
SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_STR[a]));
130130
serial_offset(planner.get_axis_position_mm(AxisEnum(a)) - current_position[a]);
131131
}
132132
#else

Marlin/src/gcode/calibrate/M425.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ void GcodeSuite::M425() {
9292
SERIAL_ECHOLNPGM(" Correction Amount/Fade-out: F", backlash.get_correction(), " (F1.0 = full, F0.0 = none)");
9393
SERIAL_ECHOPGM(" Backlash Distance (mm): ");
9494
LOOP_NUM_AXES(a) if (axis_can_calibrate(a)) {
95-
SERIAL_CHAR(' ', AXIS_CHAR(a));
96-
SERIAL_ECHO(backlash.get_distance_mm(AxisEnum(a)));
97-
SERIAL_EOL();
95+
SERIAL_ECHOLNPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_STR[a]), backlash.get_distance_mm((AxisEnum)a));
9896
}
9997

10098
#ifdef BACKLASH_SMOOTHING_MM
@@ -105,8 +103,7 @@ void GcodeSuite::M425() {
105103
SERIAL_ECHOPGM(" Average measured backlash (mm):");
106104
if (backlash.has_any_measurement()) {
107105
LOOP_NUM_AXES(a) if (axis_can_calibrate(a) && backlash.has_measurement(AxisEnum(a))) {
108-
SERIAL_CHAR(' ', AXIS_CHAR(a));
109-
SERIAL_ECHO(backlash.get_measurement(AxisEnum(a)));
106+
SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_STR[a]), backlash.get_measurement((AxisEnum)a));
110107
}
111108
}
112109
else

Marlin/src/gcode/control/M111.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void GcodeSuite::M111() {
4949
LOOP_L_N(i, COUNT(debug_strings)) {
5050
if (TEST(marlin_debug_flags, i)) {
5151
if (comma++) SERIAL_CHAR(',');
52-
SERIAL_ECHOPGM_P((char*)pgm_read_ptr(&debug_strings[i]));
52+
SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&debug_strings[i]));
5353
}
5454
}
5555
}

Marlin/src/gcode/control/M17_M18_M84.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void try_to_disable(const stepper_flags_t to_disable) {
184184

185185
auto overlap_warning = [](const ena_mask_t axis_bits) {
186186
SERIAL_ECHOPGM(" not disabled. Shared with");
187-
LOOP_NUM_AXES(a) if (TEST(axis_bits, a)) SERIAL_CHAR(' ', axis_codes[a]);
187+
LOOP_NUM_AXES(a) if (TEST(axis_bits, a)) SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_STR[a]));
188188
#if HAS_EXTRUDERS
189189
#define _EN_STILLON(N) if (TEST(axis_bits, INDEX_OF_AXIS(E_AXIS, N))) SERIAL_CHAR(' ', 'E', '0' + N);
190190
REPEAT(EXTRUDERS, _EN_STILLON)

Marlin/src/gcode/host/M114.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
void report_all_axis_pos(const xyze_pos_t &pos, const uint8_t n=LOGICAL_AXES, const uint8_t precision=3) {
3838
char str[12];
3939
LOOP_L_N(a, n) {
40-
SERIAL_CHAR(' ', axis_codes[a], ':');
40+
SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_LBL[a]));
4141
if (pos[a] >= 0) SERIAL_CHAR(' ');
4242
SERIAL_ECHO(dtostrf(pos[a], 1, precision, str));
4343
}
@@ -47,10 +47,7 @@
4747

4848
void report_linear_axis_pos(const xyz_pos_t &pos, const uint8_t precision=3) {
4949
char str[12];
50-
LOOP_NUM_AXES(a) {
51-
SERIAL_CHAR(' ', AXIS_CHAR(a), ':');
52-
SERIAL_ECHO(dtostrf(pos[a], 1, precision, str));
53-
}
50+
LOOP_NUM_AXES(a) SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_LBL[a]), dtostrf(pos[a], 1, precision, str));
5451
SERIAL_EOL();
5552
}
5653

@@ -172,8 +169,7 @@
172169

173170
SERIAL_ECHOPGM("Stepper:");
174171
LOOP_LOGICAL_AXES(i) {
175-
SERIAL_CHAR(' ', axis_codes[i], ':');
176-
SERIAL_ECHO(stepper.position((AxisEnum)i));
172+
SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_LBL[i]), stepper.position((AxisEnum)i));
177173
}
178174
SERIAL_EOL();
179175

Marlin/src/lcd/menu/menu_tramming.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static void tramming_wizard_menu() {
8383

8484
// Draw a menu item for each tramming point
8585
for (tram_index = 0; tram_index < G35_PROBE_COUNT; tram_index++)
86-
SUBMENU_P((char*)pgm_read_ptr(&tramming_point_name[tram_index]), _menu_single_probe);
86+
SUBMENU_P((PGM_P)pgm_read_ptr(&tramming_point_name[tram_index]), _menu_single_probe);
8787

8888
ACTION_ITEM(MSG_BUTTON_DONE, []{
8989
probe.stow(); // Stow before exiting Tramming Wizard

0 commit comments

Comments
 (0)