From d04ea859fb3a55e04dadc1025abbae7db9e5a56e Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 2 Jul 2021 22:22:52 +0200 Subject: [PATCH] Consolidate "Unknown X-Code" to save 16 bytes --- Firmware/Marlin_main.cpp | 6 +++--- Firmware/messages.c | 1 + Firmware/messages.h | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index d0b7522c..8131c4a9 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5810,7 +5810,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) fCheckModeInit(); // alternatively invoke printer reset break; default: - printf_P(PSTR("Unknown G code: %s\n"), cmdbuffer + bufindr + CMDHDRSIZE); + printf_P(MSG_UNKNOWN_CODE, 'G', cmdbuffer + bufindr + CMDHDRSIZE); } // printf_P(_N("END G-CODE=%u\n"), gcode_in_progress); gcode_in_progress = 0; @@ -8936,7 +8936,7 @@ Sigma_Exit: #### End of M-Commands */ default: - printf_P(PSTR("Unknown M code: %s\n"), cmdbuffer + bufindr + CMDHDRSIZE); + printf_P(MSG_UNKNOWN_CODE, 'M', cmdbuffer + bufindr + CMDHDRSIZE); } // printf_P(_N("END M-CODE=%u\n"), mcode_in_progress); mcode_in_progress = 0; @@ -9523,7 +9523,7 @@ Sigma_Exit: #endif //DEBUG_DCODES default: - printf_P(PSTR("Unknown D code: %s\n"), cmdbuffer + bufindr + CMDHDRSIZE); + printf_P(MSG_UNKNOWN_CODE, 'D', cmdbuffer + bufindr + CMDHDRSIZE); } } diff --git a/Firmware/messages.c b/Firmware/messages.c index 6248cbe8..486d78cc 100644 --- a/Firmware/messages.c +++ b/Firmware/messages.c @@ -204,3 +204,4 @@ const char MSG_M112_KILL[] PROGMEM_N1 = "M112 called. Emergency Stop."; ////c=20 const char MSG_ADVANCE_K[] PROGMEM_N1 = "Advance K:"; ////c=13 const char MSG_POWERPANIC_DETECTED[] PROGMEM_N1 = "POWER PANIC DETECTED"; ////c=20 const char MSG_LCD_STATUS_CHANGED[] PROGMEM_N1 = "LCD status changed"; +const char MSG_UNKNOWN_CODE[] PROGMEM_N1 = "Unknown %c code: %s\n"; diff --git a/Firmware/messages.h b/Firmware/messages.h index dfac1c7c..e12a4d18 100644 --- a/Firmware/messages.h +++ b/Firmware/messages.h @@ -204,6 +204,7 @@ extern const char MSG_M112_KILL[]; extern const char MSG_ADVANCE_K[]; extern const char MSG_POWERPANIC_DETECTED[]; extern const char MSG_LCD_STATUS_CHANGED[]; +extern const char MSG_UNKNOWN_CODE[]; #if defined(__cplusplus) }