From 8afc4f8d9d629781f847b628ca1708e44be83725 Mon Sep 17 00:00:00 2001 From: Thomas Moore Date: Tue, 2 Jan 2018 21:00:06 -0600 Subject: [PATCH] Fix UBL compilation warnings --- Marlin/src/feature/pause.h | 2 +- Marlin/src/gcode/queue.cpp | 20 +++++++++++++- Marlin/src/gcode/queue.h | 16 ++++++++++++ Marlin/src/lcd/ultralcd.cpp | 32 ++++++++++++++--------- Marlin/src/module/configuration_store.cpp | 4 ++- Marlin/src/sd/cardreader.cpp | 2 +- 6 files changed, 59 insertions(+), 17 deletions(-) diff --git a/Marlin/src/feature/pause.h b/Marlin/src/feature/pause.h index c17a7a44da..2bceaa2912 100644 --- a/Marlin/src/feature/pause.h +++ b/Marlin/src/feature/pause.h @@ -30,7 +30,7 @@ #include "../libs/nozzle.h" -extern bool did_pause_print; +extern uint8_t did_pause_print; bool pause_print(const float &retract, const point_t &park_point, const float &unload_length=0, const int8_t max_beep_count=0, const bool show_lcd=false diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 9f404f9473..ab25fe5a49 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -147,9 +147,27 @@ static bool drain_injected_commands_P() { */ void enqueue_and_echo_commands_P(const char * const pgcode) { injected_commands_P = pgcode; - drain_injected_commands_P(); // first command executed asap (when possible) + (void)drain_injected_commands_P(); // first command executed asap (when possible) } +#if HAS_QUEUE_NOW + /** + * Enqueue and return only when commands are actually enqueued + */ + void enqueue_and_echo_command_now(const char* cmd, bool say_ok/*=false*/) { + while (!enqueue_and_echo_command(cmd, say_ok)) idle(); + } + #if HAS_LCD_QUEUE_NOW + /** + * Enqueue from program memory and return only when commands are actually enqueued + */ + void enqueue_and_echo_commands_P_now(const char * const pgcode) { + enqueue_and_echo_commands_P(pgcode); + while (drain_injected_commands_P()) idle(); + } + #endif +#endif + /** * Send an "ok" message to the host, indicating * that a command was successfully processed. diff --git a/Marlin/src/gcode/queue.h b/Marlin/src/gcode/queue.h index 65086739b8..f2e2ef7074 100644 --- a/Marlin/src/gcode/queue.h +++ b/Marlin/src/gcode/queue.h @@ -90,6 +90,22 @@ void enqueue_and_echo_commands_P(const char * const pgcode); */ bool enqueue_and_echo_command(const char* cmd, bool say_ok=false); +#define HAS_LCD_QUEUE_NOW (ENABLED(ULTIPANEL) && (ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(PID_AUTOTUNE_MENU) || ENABLED(ADVANCED_PAUSE_FEATURE))) +#define HAS_QUEUE_NOW (ENABLED(SDSUPPORT) || HAS_LCD_QUEUE_NOW) + +#if HAS_QUEUE_NOW + /** + * Enqueue and return only when commands are actually enqueued + */ + void enqueue_and_echo_command_now(const char* cmd, bool say_ok=false); + #if HAS_LCD_QUEUE_NOW + /** + * Enqueue from program memory and return only when commands are actually enqueued + */ + void enqueue_and_echo_commands_P_now(const char * const cmd); + #endif +#endif + /** * Add to the circular command queue the next command from: * - The command-injection queue (injected_commands_P) diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 840f1bbb90..e93fdfa0e5 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -1751,9 +1751,15 @@ void kill_screen(const char* lcd_msg) { * If the queue is full, the command will fail, so we have to loop * with idle() to make sure the command has been enqueued. */ - void lcd_enqueue_command_sram(char * const cmd) { + void lcd_enqueue_command(char * const cmd) { no_reentry = true; - while (enqueue_and_echo_command(cmd)) idle(); + enqueue_and_echo_command_now(cmd); + no_reentry = false; + } + + void lcd_enqueue_commands_P(const char * const cmd) { + no_reentry = true; + enqueue_and_echo_commands_P_now(cmd); no_reentry = false; } @@ -2082,10 +2088,10 @@ void kill_screen(const char* lcd_msg) { enqueue_and_echo_commands_P(PSTR("G28")); #if HAS_TEMP_BED sprintf_P(UBL_LCD_GCODE, PSTR("M190 S%i"), custom_bed_temp); - lcd_enqueue_command_sram(UBL_LCD_GCODE); + lcd_enqueue_command(UBL_LCD_GCODE); #endif sprintf_P(UBL_LCD_GCODE, PSTR("M109 S%i"), custom_hotend_temp); - lcd_enqueue_command_sram(UBL_LCD_GCODE); + lcd_enqueue_command(UBL_LCD_GCODE); enqueue_and_echo_commands_P(PSTR("G29 P1")); } @@ -2116,7 +2122,7 @@ void kill_screen(const char* lcd_msg) { const int ind = ubl_height_amount > 0 ? 9 : 10; strcpy_P(UBL_LCD_GCODE, PSTR("G29 P6 C -")); sprintf_P(&UBL_LCD_GCODE[ind], PSTR(".%i"), abs(ubl_height_amount)); - lcd_enqueue_command_sram(UBL_LCD_GCODE); + lcd_enqueue_command(UBL_LCD_GCODE); } /** @@ -2167,8 +2173,8 @@ void kill_screen(const char* lcd_msg) { #endif ; sprintf_P(UBL_LCD_GCODE, PSTR("G26 C B%i H%i P"), temp, custom_hotend_temp); - lcd_enqueue_command_sram("G28"); - lcd_enqueue_command_sram(UBL_LCD_GCODE); + lcd_enqueue_commands_P(PSTR("G28")); + lcd_enqueue_command(UBL_LCD_GCODE); } /** @@ -2201,7 +2207,7 @@ void kill_screen(const char* lcd_msg) { void _lcd_ubl_grid_level_cmd() { char UBL_LCD_GCODE[10]; sprintf_P(UBL_LCD_GCODE, PSTR("G29 J%i"), side_points); - lcd_enqueue_command_sram(UBL_LCD_GCODE); + lcd_enqueue_command(UBL_LCD_GCODE); } /** @@ -2242,7 +2248,7 @@ void kill_screen(const char* lcd_msg) { void _lcd_ubl_fillin_amount_cmd() { char UBL_LCD_GCODE[16]; sprintf_P(UBL_LCD_GCODE, PSTR("G29 P3 R C.%i"), ubl_fillin_amount); - lcd_enqueue_command_sram(UBL_LCD_GCODE); + lcd_enqueue_command(UBL_LCD_GCODE); } /** @@ -2334,7 +2340,7 @@ void kill_screen(const char* lcd_msg) { void _lcd_ubl_load_mesh_cmd() { char UBL_LCD_GCODE[10]; sprintf_P(UBL_LCD_GCODE, PSTR("G29 L%i"), ubl_storage_slot); - lcd_enqueue_command_sram(UBL_LCD_GCODE); + lcd_enqueue_command(UBL_LCD_GCODE); enqueue_and_echo_commands_P(PSTR("M117 " MSG_MESH_LOADED ".")); } @@ -2344,7 +2350,7 @@ void kill_screen(const char* lcd_msg) { void _lcd_ubl_save_mesh_cmd() { char UBL_LCD_GCODE[10]; sprintf_P(UBL_LCD_GCODE, PSTR("G29 S%i"), ubl_storage_slot); - lcd_enqueue_command_sram(UBL_LCD_GCODE); + lcd_enqueue_command(UBL_LCD_GCODE); enqueue_and_echo_commands_P(PSTR("M117 " MSG_MESH_SAVED ".")); } @@ -2395,7 +2401,7 @@ void kill_screen(const char* lcd_msg) { dtostrf(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]), 0, 2, str); dtostrf(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]), 0, 2, str2); snprintf_P(UBL_LCD_GCODE, sizeof(UBL_LCD_GCODE), PSTR("G29 P4 X%s Y%s R%i"), str, str2, n_edit_pts); - lcd_enqueue_command_sram(UBL_LCD_GCODE); + lcd_enqueue_command(UBL_LCD_GCODE); } /** @@ -3290,7 +3296,7 @@ void kill_screen(const char* lcd_msg) { autotune_temp[e] #endif ); - lcd_enqueue_command_sram(cmd); + lcd_enqueue_command(cmd); } #endif // PID_AUTOTUNE_MENU diff --git a/Marlin/src/module/configuration_store.cpp b/Marlin/src/module/configuration_store.cpp index f5f8684847..e5088e0777 100644 --- a/Marlin/src/module/configuration_store.cpp +++ b/Marlin/src/module/configuration_store.cpp @@ -759,7 +759,9 @@ void MarlinSettings::postprocess() { } else { float dummy = 0; - bool dummyb; + #if DISABLED(AUTO_BED_LEVELING_UBL) || DISABLED(FWRETRACT) + bool dummyb; + #endif working_crc = 0; // Init to 0. Accumulated by EEPROM_READ diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index dd26b0bc06..7d5959d10f 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -287,7 +287,7 @@ void CardReader::openAndPrintFile(const char *name) { char cmd[4 + strlen(name) + 1]; // Room for "M23 ", filename, and null sprintf_P(cmd, PSTR("M23 %s"), name); for (char *c = &cmd[4]; *c; c++) *c = tolower(*c); - enqueue_and_echo_command(cmd); + enqueue_and_echo_command_now(cmd); enqueue_and_echo_commands_P(PSTR("M24")); }