From bd491818d66c2612249a8d4ac6c1a6e356b7860c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 27 Jun 2016 16:29:35 -0700 Subject: [PATCH] Reduce storage requirements for strings, make some PGM --- Marlin/M100_Free_Mem_Chk.cpp | 24 +++--- Marlin/Marlin.h | 3 +- Marlin/Marlin_main.cpp | 129 ++++++++++++++++----------------- Marlin/cardreader.cpp | 43 +++++------ Marlin/configuration_store.cpp | 6 +- Marlin/endstops.cpp | 2 +- Marlin/language.h | 2 +- Marlin/stepper.cpp | 2 +- Marlin/stepper_dac.cpp | 2 +- Marlin/temperature.cpp | 64 ++++++++-------- Marlin/ultralcd.cpp | 13 ++-- 11 files changed, 139 insertions(+), 151 deletions(-) diff --git a/Marlin/M100_Free_Mem_Chk.cpp b/Marlin/M100_Free_Mem_Chk.cpp index 521b759e3..c3027794c 100644 --- a/Marlin/M100_Free_Mem_Chk.cpp +++ b/Marlin/M100_Free_Mem_Chk.cpp @@ -86,7 +86,7 @@ void gcode_M100() { sp = top_of_stack(); SERIAL_ECHOPGM("\nStack Pointer : "); prt_hex_word((unsigned int) sp); - SERIAL_ECHOPGM("\n"); + SERIAL_EOL; sp = (unsigned char*)((unsigned long) sp | 0x000f); n = sp - ptr; // @@ -94,25 +94,25 @@ void gcode_M100() { // while (ptr < sp) { prt_hex_word((unsigned int) ptr); // Print the address - SERIAL_ECHOPGM(":"); + SERIAL_CHAR(':'); for (i = 0; i < 16; i++) { // and 16 data bytes prt_hex_byte(*(ptr + i)); - SERIAL_ECHOPGM(" "); + SERIAL_CHAR(' '); delay(2); } - SERIAL_ECHO("|"); // now show where non 0xE5's are + SERIAL_CHAR('|'); // now show where non 0xE5's are for (i = 0; i < 16; i++) { delay(2); if (*(ptr + i) == 0xe5) - SERIAL_ECHOPGM(" "); + SERIAL_CHAR(' '); else - SERIAL_ECHOPGM("?"); + SERIAL_CHAR('?'); } - SERIAL_ECHO("\n"); + SERIAL_EOL; ptr += 16; delay(2); } - SERIAL_ECHOLNPGM("Done.\n"); + SERIAL_ECHOLNPGM("Done."); return; } #endif @@ -137,7 +137,7 @@ void gcode_M100() { SERIAL_ECHOPAIR("Found ", j); SERIAL_ECHOPGM(" bytes free at 0x"); prt_hex_word((int) ptr + i); - SERIAL_ECHOPGM("\n"); + SERIAL_EOL; i += j; block_cnt++; } @@ -150,8 +150,8 @@ void gcode_M100() { } } if (block_cnt > 1) - SERIAL_ECHOLNPGM("\nMemory Corruption detected in free memory area.\n"); - SERIAL_ECHO("\nDone.\n"); + SERIAL_ECHOLNPGM("\nMemory Corruption detected in free memory area."); + SERIAL_ECHOLNPGM("\nDone."); return; } // @@ -173,7 +173,7 @@ void gcode_M100() { j = n / (x + 1); for (i = 1; i <= x; i++) { *(ptr + (i * j)) = i; - SERIAL_ECHO("\nCorrupting address: 0x"); + SERIAL_ECHOPGM("\nCorrupting address: 0x"); prt_hex_word((unsigned int)(ptr + (i * j))); } SERIAL_ECHOLNPGM("\n"); diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 17a1c421b..c4298aaac 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -84,8 +84,9 @@ typedef unsigned long millis_t; #define SERIAL_PROTOCOL_F(x,y) MYSERIAL.print(x,y) #define SERIAL_PROTOCOLPGM(x) serialprintPGM(PSTR(x)) #define SERIAL_PROTOCOLLN(x) do{ MYSERIAL.print(x); SERIAL_EOL; }while(0) -#define SERIAL_PROTOCOLLNPGM(x) do{ serialprintPGM(PSTR(x)); SERIAL_EOL; }while(0) +#define SERIAL_PROTOCOLLNPGM(x) do{ serialprintPGM(PSTR(x "\n")); }while(0) +#define SERIAL_PROTOCOLPAIR(name, value) SERIAL_ECHOPAIR(name, value) extern const char errormagic[] PROGMEM; extern const char echomagic[] PROGMEM; diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index aaddca033..5cc93cf32 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2107,7 +2107,7 @@ static void clean_up_after_endstop_or_probe_move() { do_blocking_move_to_xy(x - (X_PROBE_OFFSET_FROM_EXTRUDER), y - (Y_PROBE_OFFSET_FROM_EXTRUDER)); #if ENABLED(DEBUG_LEVELING_FEATURE) - if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> deploy_z_probe"); + if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> "); #endif deploy_z_probe(); @@ -2543,7 +2543,7 @@ void unknown_command_error() { SERIAL_ECHO_START; SERIAL_ECHOPGM(MSG_UNKNOWN_COMMAND); SERIAL_ECHO(current_command); - SERIAL_ECHOPGM("\"\n"); + SERIAL_ECHOLNPGM("\""); } #if ENABLED(HOST_KEEPALIVE_FEATURE) @@ -3187,19 +3187,11 @@ inline void gcode_G28() { switch (state) { case MeshReport: if (mbl.has_mesh()) { - SERIAL_PROTOCOLPGM("State: "); - if (mbl.active()) - SERIAL_PROTOCOLPGM("On"); - else - SERIAL_PROTOCOLPGM("Off"); - SERIAL_PROTOCOLPGM("\nNum X,Y: "); - SERIAL_PROTOCOL(MESH_NUM_X_POINTS); - SERIAL_PROTOCOLCHAR(','); - SERIAL_PROTOCOL(MESH_NUM_Y_POINTS); - SERIAL_PROTOCOLPGM("\nZ search height: "); - SERIAL_PROTOCOL(MESH_HOME_SEARCH_Z); - SERIAL_PROTOCOLPGM("\nZ offset: "); - SERIAL_PROTOCOL_F(mbl.z_offset, 5); + SERIAL_PROTOCOLPAIR("State: ", mbl.active() ? "On" : "Off"); + SERIAL_PROTOCOLPAIR("\nNum X,Y: ", MESH_NUM_X_POINTS); + SERIAL_PROTOCOLCHAR(','); SERIAL_PROTOCOL(MESH_NUM_Y_POINTS); + SERIAL_PROTOCOLPAIR("\nZ search height: ", MESH_HOME_SEARCH_Z); + SERIAL_PROTOCOLPGM("\nZ offset: "); SERIAL_PROTOCOL_F(mbl.z_offset, 5); SERIAL_PROTOCOLLNPGM("\nMeasured points:"); for (py = 0; py < MESH_NUM_Y_POINTS; py++) { for (px = 0; px < MESH_NUM_X_POINTS; px++) { @@ -3268,30 +3260,30 @@ inline void gcode_G28() { if (code_seen('X')) { px = code_value_int() - 1; if (px < 0 || px >= MESH_NUM_X_POINTS) { - SERIAL_PROTOCOLPGM("X out of range (1-" STRINGIFY(MESH_NUM_X_POINTS) ").\n"); + SERIAL_PROTOCOLLNPGM("X out of range (1-" STRINGIFY(MESH_NUM_X_POINTS) ")."); return; } } else { - SERIAL_PROTOCOLPGM("X not entered.\n"); + SERIAL_PROTOCOLLNPGM("X not entered."); return; } if (code_seen('Y')) { py = code_value_int() - 1; if (py < 0 || py >= MESH_NUM_Y_POINTS) { - SERIAL_PROTOCOLPGM("Y out of range (1-" STRINGIFY(MESH_NUM_Y_POINTS) ").\n"); + SERIAL_PROTOCOLLNPGM("Y out of range (1-" STRINGIFY(MESH_NUM_Y_POINTS) ")."); return; } } else { - SERIAL_PROTOCOLPGM("Y not entered.\n"); + SERIAL_PROTOCOLLNPGM("Y not entered."); return; } if (code_seen('Z')) { z = code_value_axis_units(Z_AXIS); } else { - SERIAL_PROTOCOLPGM("Z not entered.\n"); + SERIAL_PROTOCOLLNPGM("Z not entered."); return; } mbl.z_values[py][px] = z; @@ -3302,7 +3294,7 @@ inline void gcode_G28() { z = code_value_axis_units(Z_AXIS); } else { - SERIAL_PROTOCOLPGM("Z not entered.\n"); + SERIAL_PROTOCOLLNPGM("Z not entered."); return; } mbl.z_offset = z; @@ -3397,8 +3389,8 @@ inline void gcode_G28() { #endif if (verbose_level > 0) { - SERIAL_PROTOCOLPGM("G29 Auto Bed Leveling\n"); - if (dryrun) SERIAL_ECHOLNPGM("Running in DRY-RUN mode"); + SERIAL_PROTOCOLLNPGM("G29 Auto Bed Leveling"); + if (dryrun) SERIAL_PROTOCOLLNPGM("Running in DRY-RUN mode"); } int auto_bed_leveling_grid_points = AUTO_BED_LEVELING_GRID_POINTS; @@ -3406,7 +3398,7 @@ inline void gcode_G28() { #if DISABLED(DELTA) if (code_seen('P')) auto_bed_leveling_grid_points = code_value_int(); if (auto_bed_leveling_grid_points < 2) { - SERIAL_PROTOCOLPGM("?Number of probed (P)oints is implausible (2 minimum).\n"); + SERIAL_PROTOCOLLNPGM("?Number of probed (P)oints is implausible (2 minimum)."); return; } #endif @@ -3637,17 +3629,17 @@ inline void gcode_G28() { // Show the Topography map if enabled if (do_topography_map) { - SERIAL_PROTOCOLPGM(" \nBed Height Topography: \n"); - SERIAL_PROTOCOLPGM(" +--- BACK --+\n"); - SERIAL_PROTOCOLPGM(" | |\n"); - SERIAL_PROTOCOLPGM(" L | (+) | R\n"); - SERIAL_PROTOCOLPGM(" E | | I\n"); - SERIAL_PROTOCOLPGM(" F | (-) N (+) | G\n"); - SERIAL_PROTOCOLPGM(" T | | H\n"); - SERIAL_PROTOCOLPGM(" | (-) | T\n"); - SERIAL_PROTOCOLPGM(" | |\n"); - SERIAL_PROTOCOLPGM(" O-- FRONT --+\n"); - SERIAL_PROTOCOLPGM(" (0,0)\n"); + SERIAL_PROTOCOLLNPGM("\nBed Height Topography:\n" + " +--- BACK --+\n" + " | |\n" + " L | (+) | R\n" + " E | | I\n" + " F | (-) N (+) | G\n" + " T | | H\n" + " | (-) | T\n" + " | |\n" + " O-- FRONT --+\n" + " (0,0)"); float min_diff = 999; @@ -3674,7 +3666,7 @@ inline void gcode_G28() { } // yy SERIAL_EOL; if (verbose_level > 3) { - SERIAL_PROTOCOLPGM(" \nCorrected Bed Height vs. Bed Topology: \n"); + SERIAL_PROTOCOLLNPGM("\nCorrected Bed Height vs. Bed Topology:"); for (int yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) { for (int xx = 0; xx < auto_bed_leveling_grid_points; xx++) { @@ -3703,7 +3695,7 @@ inline void gcode_G28() { #if DISABLED(DELTA) if (verbose_level > 0) - planner.bed_level_matrix.debug(" \n\nBed Level Correction Matrix:"); + planner.bed_level_matrix.debug("\n\nBed Level Correction Matrix:"); if (!dryrun) { /** @@ -3747,7 +3739,7 @@ inline void gcode_G28() { #ifdef Z_PROBE_END_SCRIPT #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { - SERIAL_ECHO("Z Probe End Script: "); + SERIAL_ECHOPGM("Z Probe End Script: "); SERIAL_ECHOLNPGM(Z_PROBE_END_SCRIPT); } #endif @@ -4130,16 +4122,16 @@ inline void gcode_M42() { int8_t verbose_level = code_seen('V') ? code_value_byte() : 1; if (verbose_level < 0 || verbose_level > 4) { - SERIAL_PROTOCOLPGM("?Verbose Level not plausible (0-4).\n"); + SERIAL_PROTOCOLLNPGM("?Verbose Level not plausible (0-4)."); return; } if (verbose_level > 0) - SERIAL_PROTOCOLPGM("M48 Z-Probe Repeatability test\n"); + SERIAL_PROTOCOLLNPGM("M48 Z-Probe Repeatability test"); int8_t n_samples = code_seen('P') ? code_value_byte() : 10; if (n_samples < 4 || n_samples > 50) { - SERIAL_PROTOCOLPGM("?Sample size not plausible (4-50).\n"); + SERIAL_PROTOCOLLNPGM("?Sample size not plausible (4-50)."); return; } @@ -4168,7 +4160,7 @@ inline void gcode_M42() { } #else if (sqrt(X_probe_location * X_probe_location + Y_probe_location * Y_probe_location) > DELTA_PROBEABLE_RADIUS) { - SERIAL_PROTOCOLPGM("? (X,Y) location outside of probeable radius.\n"); + SERIAL_PROTOCOLLNPGM("? (X,Y) location outside of probeable radius."); return; } #endif @@ -4176,7 +4168,7 @@ inline void gcode_M42() { bool seen_L = code_seen('L'); uint8_t n_legs = seen_L ? code_value_byte() : 0; if (n_legs > 15) { - SERIAL_PROTOCOLPGM("?Number of legs in movement not plausible (0-15).\n"); + SERIAL_PROTOCOLLNPGM("?Number of legs in movement not plausible (0-15)."); return; } if (n_legs == 1) n_legs = 2; @@ -4190,7 +4182,7 @@ inline void gcode_M42() { * we don't want to use that as a starting point for each probe. */ if (verbose_level > 2) - SERIAL_PROTOCOLPGM("Positioning the probe...\n"); + SERIAL_PROTOCOLLNPGM("Positioning the probe..."); #if ENABLED(DELTA) // we don't do bed level correction in M48 because we want the raw data when we probe @@ -4223,9 +4215,9 @@ inline void gcode_M42() { if (verbose_level > 3) { SERIAL_ECHOPAIR("Starting radius: ", radius); SERIAL_ECHOPAIR(" angle: ", angle); - SERIAL_ECHO(" Direction: "); - if (dir > 0) SERIAL_ECHO("Counter "); - SERIAL_ECHOLN("Clockwise"); + SERIAL_ECHOPGM(" Direction: "); + if (dir > 0) SERIAL_ECHOPGM("Counter-"); + SERIAL_ECHOLNPGM("Clockwise"); } for (uint8_t l = 0; l < n_legs - 1; l++) { @@ -4268,10 +4260,10 @@ inline void gcode_M42() { } #endif if (verbose_level > 3) { - SERIAL_PROTOCOL("Going to:"); - SERIAL_ECHOPAIR("x: ", X_current); - SERIAL_ECHOPAIR("y: ", Y_current); - SERIAL_ECHOPAIR(" z: ", current_position[Z_AXIS]); + SERIAL_PROTOCOLPGM("Going to:"); + SERIAL_ECHOPAIR(" X", X_current); + SERIAL_ECHOPAIR(" Y", Y_current); + SERIAL_ECHOPAIR(" Z", current_position[Z_AXIS]); SERIAL_EOL; } do_blocking_move_to_xy(X_current, Y_current); @@ -5542,9 +5534,9 @@ inline void gcode_M226() { } else if (servo_index >= 0) { SERIAL_ECHO_START; - SERIAL_ECHO(" Servo "); + SERIAL_ECHOPGM(" Servo "); SERIAL_ECHO(servo_index); - SERIAL_ECHO(": "); + SERIAL_ECHOPGM(": "); SERIAL_ECHOLN(servo[servo_index].read()); } } @@ -5601,17 +5593,17 @@ inline void gcode_M226() { thermalManager.updatePID(); SERIAL_ECHO_START; #if ENABLED(PID_PARAMS_PER_HOTEND) - SERIAL_ECHO(" e:"); // specify extruder in serial output + SERIAL_ECHOPGM(" e:"); // specify extruder in serial output SERIAL_ECHO(e); #endif // PID_PARAMS_PER_HOTEND - SERIAL_ECHO(" p:"); + SERIAL_ECHOPGM(" p:"); SERIAL_ECHO(PID_PARAM(Kp, e)); - SERIAL_ECHO(" i:"); + SERIAL_ECHOPGM(" i:"); SERIAL_ECHO(unscalePID_i(PID_PARAM(Ki, e))); - SERIAL_ECHO(" d:"); + SERIAL_ECHOPGM(" d:"); SERIAL_ECHO(unscalePID_d(PID_PARAM(Kd, e))); #if ENABLED(PID_ADD_EXTRUSION_RATE) - SERIAL_ECHO(" c:"); + SERIAL_ECHOPGM(" c:"); //Kc does not have scaling applied above, or in resetting defaults SERIAL_ECHO(PID_PARAM(Kc, e)); #endif @@ -5635,11 +5627,11 @@ inline void gcode_M226() { thermalManager.updatePID(); SERIAL_ECHO_START; - SERIAL_ECHO(" p:"); + SERIAL_ECHOPGM(" p:"); SERIAL_ECHO(thermalManager.bedKp); - SERIAL_ECHO(" i:"); + SERIAL_ECHOPGM(" i:"); SERIAL_ECHO(unscalePID_i(thermalManager.bedKi)); - SERIAL_ECHO(" d:"); + SERIAL_ECHOPGM(" d:"); SERIAL_ECHOLN(unscalePID_d(thermalManager.bedKd)); } @@ -5739,7 +5731,7 @@ inline void gcode_M303() { #if ENABLED(SCARA) bool SCARA_move_to_cal(uint8_t delta_x, uint8_t delta_y) { //SoftEndsEnabled = false; // Ignore soft endstops during calibration - //SERIAL_ECHOLN(" Soft endstops disabled "); + //SERIAL_ECHOLNPGM(" Soft endstops disabled"); if (IsRunning()) { //gcode_get_destination(); // For X Y Z E F delta[X_AXIS] = delta_x; @@ -5758,7 +5750,7 @@ inline void gcode_M303() { * M360: SCARA calibration: Move to cal-position ThetaA (0 deg calibration) */ inline bool gcode_M360() { - SERIAL_ECHOLN(" Cal: Theta 0 "); + SERIAL_ECHOLNPGM(" Cal: Theta 0"); return SCARA_move_to_cal(0, 120); } @@ -5766,7 +5758,7 @@ inline void gcode_M303() { * M361: SCARA calibration: Move to cal-position ThetaB (90 deg calibration - steps per degree) */ inline bool gcode_M361() { - SERIAL_ECHOLN(" Cal: Theta 90 "); + SERIAL_ECHOLNPGM(" Cal: Theta 90"); return SCARA_move_to_cal(90, 130); } @@ -5774,7 +5766,7 @@ inline void gcode_M303() { * M362: SCARA calibration: Move to cal-position PsiA (0 deg calibration) */ inline bool gcode_M362() { - SERIAL_ECHOLN(" Cal: Psi 0 "); + SERIAL_ECHOLNPGM(" Cal: Psi 0"); return SCARA_move_to_cal(60, 180); } @@ -5782,7 +5774,7 @@ inline void gcode_M303() { * M363: SCARA calibration: Move to cal-position PsiB (90 deg calibration - steps per degree) */ inline bool gcode_M363() { - SERIAL_ECHOLN(" Cal: Psi 90 "); + SERIAL_ECHOLNPGM(" Cal: Psi 90"); return SCARA_move_to_cal(50, 90); } @@ -5790,7 +5782,7 @@ inline void gcode_M303() { * M364: SCARA calibration: Move to cal-position PSIC (90 deg to Theta calibration position) */ inline bool gcode_M364() { - SERIAL_ECHOLN(" Cal: Theta-Psi 90 "); + SERIAL_ECHOLNPGM(" Cal: Theta-Psi 90"); return SCARA_move_to_cal(45, 135); } @@ -6109,6 +6101,7 @@ inline void gcode_M503() { else { SERIAL_ECHOPGM(MSG_Z_MIN); SERIAL_ECHO(Z_PROBE_OFFSET_RANGE_MIN); + SERIAL_CHAR(' '); SERIAL_ECHOPGM(MSG_Z_MAX); SERIAL_ECHO(Z_PROBE_OFFSET_RANGE_MAX); } @@ -6625,7 +6618,7 @@ inline void gcode_T(uint8_t tmp_extruder) { #endif SERIAL_ECHO_START; - SERIAL_ECHO(MSG_ACTIVE_EXTRUDER); + SERIAL_ECHOPGM(MSG_ACTIVE_EXTRUDER); SERIAL_PROTOCOLLN((int)active_extruder); } diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp index 3910bee4e..4b7aaf676 100644 --- a/Marlin/cardreader.cpp +++ b/Marlin/cardreader.cpp @@ -102,7 +102,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m if (!dir.open(parent, lfilename, O_READ)) { if (lsAction == LS_SerialPrint) { SERIAL_ECHO_START; - SERIAL_ECHOLN(MSG_SD_CANT_OPEN_SUBDIR); + SERIAL_ECHOPGM(MSG_SD_CANT_OPEN_SUBDIR); SERIAL_ECHOLN(lfilename); } } @@ -357,8 +357,8 @@ void CardReader::openFile(char* name, bool read, bool push_current/*=false*/) { dirname_start = &name[1]; while (dirname_start != NULL) { dirname_end = strchr(dirname_start, '/'); - //SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start - name)); - //SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end - name)); + //SERIAL_ECHOPGM("start:");SERIAL_ECHOLN((int)(dirname_start - name)); + //SERIAL_ECHOPGM("end :");SERIAL_ECHOLN((int)(dirname_end - name)); if (dirname_end != NULL && dirname_end > dirname_start) { char subdirname[FILENAME_LENGTH]; strncpy(subdirname, dirname_start, dirname_end - dirname_start); @@ -371,7 +371,7 @@ void CardReader::openFile(char* name, bool read, bool push_current/*=false*/) { return; } else { - //SERIAL_ECHOLN("dive ok"); + //SERIAL_ECHOLNPGM("dive ok"); } curDir = &myDir; @@ -379,7 +379,7 @@ void CardReader::openFile(char* name, bool read, bool push_current/*=false*/) { } else { // the remainder after all /fsa/fdsa/ is the filename fname = dirname_start; - //SERIAL_ECHOLN("remainder"); + //SERIAL_ECHOLNPGM("remainder"); //SERIAL_ECHOLN(fname); break; } @@ -392,10 +392,9 @@ void CardReader::openFile(char* name, bool read, bool push_current/*=false*/) { if (read) { if (file.open(curDir, fname, O_READ)) { filesize = file.fileSize(); - SERIAL_PROTOCOLPGM(MSG_SD_FILE_OPENED); - SERIAL_PROTOCOL(fname); - SERIAL_PROTOCOLPGM(MSG_SD_SIZE); - SERIAL_PROTOCOLLN(filesize); + SERIAL_PROTOCOLPAIR(MSG_SD_FILE_OPENED, fname); + SERIAL_PROTOCOLPAIR(MSG_SD_SIZE, filesize); + SERIAL_EOL; sdpos = 0; SERIAL_PROTOCOLLNPGM(MSG_SD_FILE_SELECTED); @@ -403,21 +402,20 @@ void CardReader::openFile(char* name, bool read, bool push_current/*=false*/) { lcd_setstatus(longFilename[0] ? longFilename : fname); } else { - SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL); - SERIAL_PROTOCOL(fname); - SERIAL_PROTOCOLPGM(".\n"); + SERIAL_PROTOCOLPAIR(MSG_SD_OPEN_FILE_FAIL, fname); + SERIAL_PROTOCOLCHAR('.'); + SERIAL_EOL; } } else { //write if (!file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) { - SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL); - SERIAL_PROTOCOL(fname); - SERIAL_PROTOCOLPGM(".\n"); + SERIAL_PROTOCOLPAIR(MSG_SD_OPEN_FILE_FAIL, fname); + SERIAL_PROTOCOLCHAR('.'); + SERIAL_EOL; } else { saving = true; - SERIAL_PROTOCOLPGM(MSG_SD_WRITE_TO_FILE); - SERIAL_PROTOCOLLN(name); + SERIAL_PROTOCOLPAIR(MSG_SD_WRITE_TO_FILE, name); lcd_setstatus(fname); } } @@ -438,21 +436,20 @@ void CardReader::removeFile(char* name) { dirname_start = strchr(name, '/') + 1; while (dirname_start != NULL) { dirname_end = strchr(dirname_start, '/'); - //SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start - name)); - //SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end - name)); + //SERIAL_ECHOPGM("start:");SERIAL_ECHOLN((int)(dirname_start - name)); + //SERIAL_ECHOPGM("end :");SERIAL_ECHOLN((int)(dirname_end - name)); if (dirname_end != NULL && dirname_end > dirname_start) { char subdirname[FILENAME_LENGTH]; strncpy(subdirname, dirname_start, dirname_end - dirname_start); subdirname[dirname_end - dirname_start] = 0; SERIAL_ECHOLN(subdirname); if (!myDir.open(curDir, subdirname, O_READ)) { - SERIAL_PROTOCOLPGM("open failed, File: "); - SERIAL_PROTOCOL(subdirname); + SERIAL_PROTOCOLPAIR("open failed, File: ", subdirname); SERIAL_PROTOCOLCHAR('.'); return; } else { - //SERIAL_ECHOLN("dive ok"); + //SERIAL_ECHOLNPGM("dive ok"); } curDir = &myDir; @@ -460,7 +457,7 @@ void CardReader::removeFile(char* name) { } else { // the remainder after all /fsa/fdsa/ is the filename fname = dirname_start; - //SERIAL_ECHOLN("remainder"); + //SERIAL_ECHOLNPGM("remainder"); //SERIAL_ECHOLN(fname); break; } diff --git a/Marlin/configuration_store.cpp b/Marlin/configuration_store.cpp index 3def1c3eb..8af50da26 100644 --- a/Marlin/configuration_store.cpp +++ b/Marlin/configuration_store.cpp @@ -344,7 +344,7 @@ void Config_RetrieveSettings() { char stored_ver[4]; char ver[4] = EEPROM_VERSION; EEPROM_READ_VAR(i, stored_ver); //read stored version - // SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]"); + // SERIAL_ECHO("Version: [" << ver << "] Stored version: [" << stored_ver << "]\n"); if (strncmp(ver, stored_ver, 3) != 0) { Config_ResetDefault(); @@ -717,7 +717,7 @@ void Config_PrintSettings(bool forReplay) { CONFIG_ECHO_START; if (!forReplay) { - SERIAL_ECHOLNPGM("Home offset (mm):"); + SERIAL_ECHOLNPGM("Home offset (mm)"); CONFIG_ECHO_START; } SERIAL_ECHOPAIR(" M206 X", home_offset[X_AXIS]); @@ -883,7 +883,7 @@ void Config_PrintSettings(bool forReplay) { SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries"); CONFIG_ECHO_START; } - SERIAL_ECHOPAIR(" M209 S", (autoretract_enabled ? 1 : 0)); + SERIAL_ECHOPAIR(" M209 S", autoretract_enabled ? 1 : 0); SERIAL_EOL; #endif // FWRETRACT diff --git a/Marlin/endstops.cpp b/Marlin/endstops.cpp index 945b61577..81a080ebf 100644 --- a/Marlin/endstops.cpp +++ b/Marlin/endstops.cpp @@ -197,7 +197,7 @@ void Endstops::report_state() { } // Endstops::report_state void Endstops::M119() { - SERIAL_PROTOCOLLN(MSG_M119_REPORT); + SERIAL_PROTOCOLLNPGM(MSG_M119_REPORT); #if HAS_X_MIN SERIAL_PROTOCOLPGM(MSG_X_MIN); SERIAL_PROTOCOLLN(((READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); diff --git a/Marlin/language.h b/Marlin/language.h index f7ac1474b..eb378feea 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -157,7 +157,7 @@ #define MSG_ENDSTOP_OPEN "open" #define MSG_HOTEND_OFFSET "Hotend offsets:" -#define MSG_SD_CANT_OPEN_SUBDIR "Cannot open subdir" +#define MSG_SD_CANT_OPEN_SUBDIR "Cannot open subdir " #define MSG_SD_INIT_FAIL "SD init fail" #define MSG_SD_VOL_INIT_FAIL "volume.init failed" #define MSG_SD_OPENROOT_FAIL "openRoot failed" diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index b544cd6fe..300bd286f 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -1103,7 +1103,7 @@ void Stepper::microstep_mode(uint8_t driver, uint8_t stepping_mode) { } void Stepper::microstep_readings() { - SERIAL_PROTOCOLPGM("MS1,MS2 Pins\n"); + SERIAL_PROTOCOLLNPGM("MS1,MS2 Pins"); SERIAL_PROTOCOLPGM("X: "); SERIAL_PROTOCOL(digitalRead(X_MS1_PIN)); SERIAL_PROTOCOLLN(digitalRead(X_MS2_PIN)); diff --git a/Marlin/stepper_dac.cpp b/Marlin/stepper_dac.cpp index 2e3248daa..cb078570c 100644 --- a/Marlin/stepper_dac.cpp +++ b/Marlin/stepper_dac.cpp @@ -98,7 +98,7 @@ SERIAL_ECHOPAIR(" (", dac_amps(2)); SERIAL_ECHOPAIR(") E:", dac_perc(3)); SERIAL_ECHOPAIR(" (", dac_amps(3)); - SERIAL_ECHOLN(")"); + SERIAL_ECHOLNPGM(")"); } void dac_commit_eeprom() { diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 4a19968d0..a011b77d2 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -304,37 +304,37 @@ unsigned char Temperature::soft_pwm[HOTENDS]; bias = constrain(bias, 20, max_pow - 20); d = (bias > max_pow / 2) ? max_pow - 1 - bias : bias; - SERIAL_PROTOCOLPGM(MSG_BIAS); SERIAL_PROTOCOL(bias); - SERIAL_PROTOCOLPGM(MSG_D); SERIAL_PROTOCOL(d); - SERIAL_PROTOCOLPGM(MSG_T_MIN); SERIAL_PROTOCOL(min); - SERIAL_PROTOCOLPGM(MSG_T_MAX); SERIAL_PROTOCOLLN(max); + SERIAL_PROTOCOLPAIR(MSG_BIAS, bias); + SERIAL_PROTOCOLPAIR(MSG_D, d); + SERIAL_PROTOCOLPAIR(MSG_T_MIN, min); + SERIAL_PROTOCOLPAIR(MSG_T_MAX, max); if (cycles > 2) { Ku = (4.0 * d) / (3.14159265 * (max - min) / 2.0); Tu = ((float)(t_low + t_high) / 1000.0); - SERIAL_PROTOCOLPGM(MSG_KU); SERIAL_PROTOCOL(Ku); - SERIAL_PROTOCOLPGM(MSG_TU); SERIAL_PROTOCOLLN(Tu); + SERIAL_PROTOCOLPAIR(MSG_KU, Ku); + SERIAL_PROTOCOLPAIR(MSG_TU, Tu); workKp = 0.6 * Ku; workKi = 2 * workKp / Tu; workKd = workKp * Tu / 8; SERIAL_PROTOCOLLNPGM(MSG_CLASSIC_PID); - SERIAL_PROTOCOLPGM(MSG_KP); SERIAL_PROTOCOLLN(workKp); - SERIAL_PROTOCOLPGM(MSG_KI); SERIAL_PROTOCOLLN(workKi); - SERIAL_PROTOCOLPGM(MSG_KD); SERIAL_PROTOCOLLN(workKd); + SERIAL_PROTOCOLPAIR(MSG_KP, workKp); + SERIAL_PROTOCOLPAIR(MSG_KI, workKi); + SERIAL_PROTOCOLPAIR(MSG_KD, workKd); /** workKp = 0.33*Ku; workKi = workKp/Tu; workKd = workKp*Tu/3; - SERIAL_PROTOCOLLNPGM(" Some overshoot "); - SERIAL_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(workKp); - SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(workKi); - SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(workKd); + SERIAL_PROTOCOLLNPGM(" Some overshoot"); + SERIAL_PROTOCOLPAIR(" Kp: ", workKp); + SERIAL_PROTOCOLPAIR(" Ki: ", workKi); + SERIAL_PROTOCOLPAIR(" Kd: ", workKd); workKp = 0.2*Ku; workKi = 2*workKp/Tu; workKd = workKp*Tu/3; - SERIAL_PROTOCOLLNPGM(" No overshoot "); - SERIAL_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(workKp); - SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(workKi); - SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(workKd); + SERIAL_PROTOCOLLNPGM(" No overshoot"); + SERIAL_PROTOCOLPAIR(" Kp: ", workKp); + SERIAL_PROTOCOLPAIR(" Ki: ", workKi); + SERIAL_PROTOCOLPAIR(" Kd: ", workKd); */ } } @@ -377,17 +377,17 @@ unsigned char Temperature::soft_pwm[HOTENDS]; #if HAS_PID_FOR_BOTH const char* estring = hotend < 0 ? "bed" : ""; - SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Kp "); SERIAL_PROTOCOLLN(workKp); - SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Ki "); SERIAL_PROTOCOLLN(workKi); - SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Kd "); SERIAL_PROTOCOLLN(workKd); + SERIAL_PROTOCOLPAIR("#define DEFAULT_", estring); SERIAL_PROTOCOLPAIR("Kp ", workKp); + SERIAL_PROTOCOLPAIR("#define DEFAULT_", estring); SERIAL_PROTOCOLPAIR("Ki ", workKi); + SERIAL_PROTOCOLPAIR("#define DEFAULT_", estring); SERIAL_PROTOCOLPAIR("Kd ", workKd); #elif ENABLED(PIDTEMP) - SERIAL_PROTOCOLPGM("#define DEFAULT_Kp "); SERIAL_PROTOCOLLN(workKp); - SERIAL_PROTOCOLPGM("#define DEFAULT_Ki "); SERIAL_PROTOCOLLN(workKi); - SERIAL_PROTOCOLPGM("#define DEFAULT_Kd "); SERIAL_PROTOCOLLN(workKd); + SERIAL_PROTOCOLPAIR("#define DEFAULT_Kp ", workKp); + SERIAL_PROTOCOLPAIR("#define DEFAULT_Ki ", workKi); + SERIAL_PROTOCOLPAIR("#define DEFAULT_Kd ", workKd); #else - SERIAL_PROTOCOLPGM("#define DEFAULT_bedKp "); SERIAL_PROTOCOLLN(workKp); - SERIAL_PROTOCOLPGM("#define DEFAULT_bedKi "); SERIAL_PROTOCOLLN(workKi); - SERIAL_PROTOCOLPGM("#define DEFAULT_bedKd "); SERIAL_PROTOCOLLN(workKd); + SERIAL_PROTOCOLPAIR("#define DEFAULT_bedKp ", workKp); + SERIAL_PROTOCOLPAIR("#define DEFAULT_bedKi ", workKi); + SERIAL_PROTOCOLPAIR("#define DEFAULT_bedKd ", workKd); #endif #define _SET_BED_PID() \ @@ -626,16 +626,16 @@ float Temperature::get_pid_output(int e) { #if ENABLED(PID_BED_DEBUG) SERIAL_ECHO_START; - SERIAL_ECHO(" PID_BED_DEBUG "); - SERIAL_ECHO(": Input "); + SERIAL_ECHOPGM(" PID_BED_DEBUG "); + SERIAL_ECHOPGM(": Input "); SERIAL_ECHO(current_temperature_bed); - SERIAL_ECHO(" Output "); + SERIAL_ECHOPGM(" Output "); SERIAL_ECHO(pid_output); - SERIAL_ECHO(" pTerm "); + SERIAL_ECHOPGM(" pTerm "); SERIAL_ECHO(pTerm_bed); - SERIAL_ECHO(" iTerm "); + SERIAL_ECHOPGM(" iTerm "); SERIAL_ECHO(iTerm_bed); - SERIAL_ECHO(" dTerm "); + SERIAL_ECHOPGM(" dTerm "); SERIAL_ECHOLN(dTerm_bed); #endif //PID_BED_DEBUG diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index ea8d8c700..7fd0e9f25 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -2266,14 +2266,11 @@ void lcd_update() { #if ENABLED(ENCODER_RATE_MULTIPLIER_DEBUG) SERIAL_ECHO_START; - SERIAL_ECHO("Enc Step Rate: "); - SERIAL_ECHO(encoderStepRate); - SERIAL_ECHO(" Multiplier: "); - SERIAL_ECHO(encoderMultiplier); - SERIAL_ECHO(" ENCODER_10X_STEPS_PER_SEC: "); - SERIAL_ECHO(ENCODER_10X_STEPS_PER_SEC); - SERIAL_ECHO(" ENCODER_100X_STEPS_PER_SEC: "); - SERIAL_ECHOLN(ENCODER_100X_STEPS_PER_SEC); + SERIAL_ECHOPAIR("Enc Step Rate: ", encoderStepRate); + SERIAL_ECHOPAIR(" Multiplier: ", encoderMultiplier); + SERIAL_ECHOPAIR(" ENCODER_10X_STEPS_PER_SEC: ", ENCODER_10X_STEPS_PER_SEC); + SERIAL_ECHOPAIR(" ENCODER_100X_STEPS_PER_SEC: ", ENCODER_100X_STEPS_PER_SEC); + SERIAL_EOL; #endif //ENCODER_RATE_MULTIPLIER_DEBUG }