Merge pull request #8988 from tcm0116/1.1.x_ubl

[1.1.x] Fix UBL compilation warnings
This commit is contained in:
Scott Lahteine 2018-01-02 21:37:59 -06:00 committed by GitHub
commit c893a90d64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 18 deletions

View File

@ -201,6 +201,16 @@ bool enqueue_and_echo_command(const char* cmd, bool say_ok=false); // Add a sing
void enqueue_and_echo_commands_P(const char * const cmd); // Set one or more commands to be prioritized over the next Serial/SD command.
void clear_command_queue();
#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
// 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
void enqueue_and_echo_commands_P_now(const char * const cmd);
#endif
#endif
extern millis_t previous_cmd_ms;
inline void refresh_cmd_timeout() { previous_cmd_ms = millis(); }

View File

@ -850,7 +850,7 @@ 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)
}
/**
@ -896,6 +896,18 @@ bool enqueue_and_echo_command(const char* cmd, bool say_ok/*=false*/) {
return false;
}
#if HAS_QUEUE_NOW
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
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
void setup_killpin() {
#if HAS_KILL
SET_INPUT_PULLUP(KILL_PIN);

View File

@ -282,7 +282,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"));
}

View File

@ -1333,7 +1333,7 @@ void MarlinSettings::postprocess() {
void MarlinSettings::store_mesh(const int8_t slot) {
#if ENABLED(AUTO_BED_LEVELING_UBL)
const uint16_t a = calc_num_meshes();
const int16_t a = calc_num_meshes();
if (!WITHIN(slot, 0, a - 1)) {
#if ENABLED(EEPROM_CHITCHAT)
ubl_invalid_slot(a);
@ -1367,7 +1367,7 @@ void MarlinSettings::postprocess() {
#if ENABLED(AUTO_BED_LEVELING_UBL)
const uint16_t a = settings.calc_num_meshes();
const int16_t a = settings.calc_num_meshes();
if (!WITHIN(slot, 0, a - 1)) {
#if ENABLED(EEPROM_CHITCHAT)

View File

@ -1680,9 +1680,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;
}
@ -2011,10 +2017,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"));
}
@ -2045,7 +2051,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);
}
/**
@ -2096,8 +2102,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);
}
/**
@ -2130,7 +2136,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);
}
/**
@ -2171,7 +2177,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);
}
/**
@ -2263,7 +2269,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 "."));
}
@ -2273,7 +2279,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 "."));
}
@ -2324,7 +2330,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);
}
/**
@ -3205,7 +3211,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
@ -4111,7 +4117,7 @@ void kill_screen(const char* lcd_msg) {
char cmd[11];
sprintf_P(cmd, _change_filament_temp_command(), _change_filament_temp_extruder);
thermalManager.setTargetHotend(index == 1 ? PREHEAT_1_TEMP_HOTEND : PREHEAT_2_TEMP_HOTEND, _change_filament_temp_extruder);
lcd_enqueue_command_sram(cmd);
lcd_enqueue_command(cmd);
}
void _lcd_change_filament_temp_1_menu() { _change_filament_temp(1); }
void _lcd_change_filament_temp_2_menu() { _change_filament_temp(2); }