Skip to content

Commit

Permalink
Fix G35 on Arduino
Browse files Browse the repository at this point in the history
The tramming_point_name[] array is PROGMEM and points to PGMSTR()
strings... this apparently means it can't be used with
SERIAL_ECHOPAIR() on Arduino.

On my CR-10 v3 with original Creality board, the first output sent
a long string of characters to the serial port and then hung.

This change allows it to work correctly.

NOTE: The debug output wasn't tested, and I'm sure there's a better
way of doing this, but I'm not familiar enough with the firmware to
know what SERIAL_*() macro is appropriate for this.
  • Loading branch information
W8BSD committed Sep 22, 2020
1 parent a52afd2 commit 486437e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Marlin/src/gcode/bedlevel/G35.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,18 @@ void GcodeSuite::G35() {
const float z_probed_height = probe.probe_at_point(screws_tilt_adjust_pos[i], PROBE_PT_RAISE, 0, true);

if (isnan(z_probed_height)) {
SERIAL_ECHOPAIR("G35 failed at point ", int(i), " (", tramming_point_name[i], ")");
SERIAL_ECHOPAIR("G35 failed at point ", int(i), " (");
serialprintPGM((char *)pgm_read_ptr(&tramming_point_name[i]));
serialprintPGM(PSTR(")"));
SERIAL_ECHOLNPAIR_P(SP_X_STR, screws_tilt_adjust_pos[i].x, SP_Y_STR, screws_tilt_adjust_pos[i].y);
err_break = true;
break;
}

if (DEBUGGING(LEVELING)) {
DEBUG_ECHOPAIR("Probing point ", int(i), " (", tramming_point_name[i], ")");
DEBUG_ECHOPAIR("Probing point ", int(i), " (");
DEBUG_PRINT_P((char *)pgm_read_ptr(&tramming_point_name[i]));
DEBUG_PRINT_P(PSTR(")"));
SERIAL_ECHOLNPAIR_P(SP_X_STR, screws_tilt_adjust_pos[i].x, SP_Y_STR, screws_tilt_adjust_pos[i].y, SP_Z_STR, z_probed_height);
}

Expand All @@ -152,8 +156,9 @@ void GcodeSuite::G35() {
const float decimal_part = adjust - float(full_turns);
const int minutes = trunc(decimal_part * 60.0f);

SERIAL_ECHOPAIR("Turn ", tramming_point_name[i],
" ", (screw_thread & 1) == (adjust > 0) ? "Counter-Clockwise" : "Clockwise",
serialprintPGM(PSTR("Turn "));
serialprintPGM((char *)pgm_read_ptr(&tramming_point_name[i]));
SERIAL_ECHOPAIR(" ", (screw_thread & 1) == (adjust > 0) ? "Counter-Clockwise" : "Clockwise",
" by ", abs(full_turns), " turns");
if (minutes) SERIAL_ECHOPAIR(" and ", abs(minutes), " minutes");
SERIAL_EOL();
Expand Down

0 comments on commit 486437e

Please sign in to comment.