diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 03cc8910fe00..e92c5efdb119 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2821,8 +2821,7 @@ static void clean_up_after_endstop_or_probe_move() { } - static void print_bilinear_leveling_grid() - { + static void print_bilinear_leveling_grid() { SERIAL_ECHOLNPGM("Bilinear Leveling Grid:"); print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 3, [](const uint8_t ix, const uint8_t iy) { return z_values[ix][iy]; } @@ -5977,17 +5976,14 @@ void home_all_axes() { gcode_G28(true); } /** * G92: Set current position to given X Y Z E */ -inline void gcode_G92() -{ +inline void gcode_G92() { bool didXYZ = false, didE = parser.seenval('E'); if (!didE) stepper.synchronize(); - LOOP_XYZE(i) - { - if (parser.seenval(axis_codes[i])) - { + LOOP_XYZE(i) { + if (parser.seenval(axis_codes[i])) { #if IS_SCARA current_position[i] = parser.value_axis_units((AxisEnum)i); if (i != E_AXIS) didXYZ = true; @@ -5999,11 +5995,9 @@ inline void gcode_G92() current_position[i] = v; - if (i != E_AXIS) - { + if (i != E_AXIS) { didXYZ = true; - if (i == Z_AXIS) - { + if (i == Z_AXIS) { axis_known_position[Z_AXIS] = true; } #if HAS_POSITION_SHIFT @@ -6535,8 +6529,7 @@ inline void gcode_M17() { /** * M21: Init SD Card */ - inline void gcode_M21() - { + inline void gcode_M21() { card.initsd(); #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE) init_power_off_info(); @@ -6560,8 +6553,7 @@ inline void gcode_M17() { /** * M24: Start or Resume SD Print */ - inline void gcode_M24() - { + inline void gcode_M24() { #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE) card.removePowerOffFile(); #endif @@ -7342,8 +7334,7 @@ inline void gcode_M77() { print_job_timer.stop(); } /** * M104: Set hot end temperature */ -inline void gcode_M104() -{ +inline void gcode_M104() { if (get_target_extruder_from_command(104)) return; if (DEBUGGING(DRYRUN)) return; @@ -7351,8 +7342,7 @@ inline void gcode_M104() if (target_extruder != active_extruder) return; #endif - if (parser.seenval('S')) - { + if (parser.seenval('S')) { const int16_t temp = parser.value_celsius(); thermalManager.setTargetHotend(temp, target_extruder); @@ -7368,18 +7358,14 @@ inline void gcode_M104() * standby mode, for instance in a dual extruder setup, without affecting * the running print timer. */ - if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2) - { + if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2) { print_job_timer.stop(); LCD_MESSAGEPGM(WELCOME_MSG); } #endif if (parser.value_celsius() > thermalManager.degHotend(target_extruder)) - { - // lcd_status_printf_P(0, PSTR("E%i %s"), target_extruder + 1, MSG_HEATING); - lcd_status_printf_P(0, PSTR("Extruder %s"), MSG_HEATING); - } + lcd_status_printf_P(0, PSTR("Extruder %s"), MSG_HEATING); } #if ENABLED(AUTOTEMP) @@ -7565,8 +7551,8 @@ inline void gcode_M105() { #define MIN_COOLING_SLOPE_TIME 60 #endif -inline void gcode_M109() -{ +inline void gcode_M109() { + if (get_target_extruder_from_command(109)) return; if (DEBUGGING(DRYRUN)) return; @@ -7575,8 +7561,7 @@ inline void gcode_M109() #endif const bool no_wait_for_cooling = parser.seenval('S'); - if (no_wait_for_cooling || parser.seenval('R')) - { + if (no_wait_for_cooling || parser.seenval('R')) { const int16_t temp = parser.value_celsius(); thermalManager.setTargetHotend(temp, target_extruder); @@ -7591,8 +7576,7 @@ inline void gcode_M109() * standby mode, (e.g., in a dual extruder setup) without affecting * the running print timer. */ - if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2) - { + if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2) { print_job_timer.stop(); LCD_MESSAGEPGM(WELCOME_MSG); } @@ -7600,8 +7584,7 @@ inline void gcode_M109() print_job_timer.start(); #endif - if (thermalManager.isHeatingHotend(target_extruder)) - { + if (thermalManager.isHeatingHotend(target_extruder)) { // lcd_status_printf_P(0, PSTR("E%i %s"), target_extruder + 1, MSG_HEATING); lcd_status_printf_P(0, PSTR("Extruder %s"), MSG_HEATING); } @@ -7635,11 +7618,9 @@ inline void gcode_M109() uint8_t old_blue = 0; #endif - do - { + do { // Target temperature might be changed during the loop - if (target_temp != thermalManager.degTargetHotend(target_extruder)) - { + if (target_temp != thermalManager.degTargetHotend(target_extruder)) { wants_to_cool = thermalManager.isCoolingHotend(target_extruder); target_temp = thermalManager.degTargetHotend(target_extruder); @@ -7648,9 +7629,7 @@ inline void gcode_M109() } now = millis(); - if (ELAPSED(now, next_temp_ms)) - { - // Print temp & remaining time every 1s while waiting + if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting next_temp_ms = now + 1000UL; print_heaterstates(); #if TEMP_RESIDENCY_TIME > 0 @@ -7670,11 +7649,9 @@ inline void gcode_M109() #if ENABLED(PRINTER_EVENT_LEDS) // Gradually change LED strip from violet to red as nozzle heats up - if (!wants_to_cool) - { + if (!wants_to_cool) { const uint8_t blue = map(constrain(temp, start_temp, target_temp), start_temp, target_temp, 255, 0); - if (blue != old_blue) - { + if (blue != old_blue) { old_blue = blue; set_led_color(255, 0, blue #if ENABLED(NEOPIXEL_LED) @@ -7693,13 +7670,11 @@ inline void gcode_M109() const float temp_diff = FABS(target_temp - temp); - if (!residency_start_ms) - { + if (!residency_start_ms) { // Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time. if (temp_diff < TEMP_WINDOW) residency_start_ms = now; } - else if (temp_diff > TEMP_HYSTERESIS) - { + else if (temp_diff > TEMP_HYSTERESIS) { // Restart the timer whenever the temperature falls outside the hysteresis. residency_start_ms = now; } @@ -7707,12 +7682,10 @@ inline void gcode_M109() #endif // Prevent a wait-forever situation if R is misused i.e. M109 R0 - if (wants_to_cool) - { + if (wants_to_cool) { // break after MIN_COOLING_SLOPE_TIME seconds // if the temperature did not drop at least MIN_COOLING_SLOPE_DEG - if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) - { + if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) { if (old_temp - temp < MIN_COOLING_SLOPE_DEG) break; next_cool_check_ms = now + 1000UL * MIN_COOLING_SLOPE_TIME; old_temp = temp; @@ -7721,8 +7694,7 @@ inline void gcode_M109() } while (wait_for_heatup && TEMP_CONDITIONS); - if (wait_for_heatup) - { + if (wait_for_heatup) { LCD_MESSAGEPGM(MSG_HEATING_COMPLETE); #if ENABLED(PRINTER_EVENT_LEDS) #if ENABLED(RGB_LED) || ENABLED(BLINKM) || ENABLED(PCA9632) || ENABLED(RGBW_LED) @@ -7752,14 +7724,12 @@ inline void gcode_M109() * M190: Sxxx Wait for bed current temp to reach target temp. Waits only when heating * Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling */ - inline void gcode_M190() - { + inline void gcode_M190() { if (DEBUGGING(DRYRUN)) return; LCD_MESSAGEPGM(MSG_BED_HEATING); const bool no_wait_for_cooling = parser.seenval('S'); - if (no_wait_for_cooling || parser.seenval('R')) - { + if (no_wait_for_cooling || parser.seenval('R')) { thermalManager.setTargetBed(parser.value_celsius()); #if ENABLED(PRINTJOB_TIMER_AUTOSTART) if (parser.value_celsius() > BED_MINTEMP) @@ -7804,9 +7774,7 @@ inline void gcode_M109() } now = millis(); - if (ELAPSED(now, next_temp_ms)) - { - // Print Temp Reading every 1 second while heating up. + if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up. next_temp_ms = now + 1000UL; print_heaterstates(); #if TEMP_BED_RESIDENCY_TIME > 0 @@ -7826,11 +7794,9 @@ inline void gcode_M109() #if ENABLED(PRINTER_EVENT_LEDS) // Gradually change LED strip from blue to violet as bed heats up - if (!wants_to_cool) - { + if (!wants_to_cool) { const uint8_t red = map(constrain(temp, start_temp, target_temp), start_temp, target_temp, 0, 255); - if (red != old_red) - { + if (red != old_red) { old_red = red; set_led_color(red, 0, 255 #if ENABLED(NEOPIXEL_LED) @@ -7848,13 +7814,11 @@ inline void gcode_M109() const float temp_diff = FABS(target_temp - temp); - if (!residency_start_ms) - { + if (!residency_start_ms) { // Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time. if (temp_diff < TEMP_BED_WINDOW) residency_start_ms = now; } - else if (temp_diff > TEMP_BED_HYSTERESIS) - { + else if (temp_diff > TEMP_BED_HYSTERESIS) { // Restart the timer whenever the temperature falls outside the hysteresis. residency_start_ms = now; } @@ -7862,12 +7826,10 @@ inline void gcode_M109() #endif // TEMP_BED_RESIDENCY_TIME > 0 // Prevent a wait-forever situation if R is misused i.e. M190 R0 - if (wants_to_cool) - { + if (wants_to_cool) { // Break after MIN_COOLING_SLOPE_TIME_BED seconds // if the temperature did not drop at least MIN_COOLING_SLOPE_DEG_BED - if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) - { + if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) { if (old_temp - temp < MIN_COOLING_SLOPE_DEG_BED) break; next_cool_check_ms = now + 1000UL * MIN_COOLING_SLOPE_TIME_BED; old_temp = temp; @@ -13953,22 +13915,20 @@ void setup() { * - Call endstop manager * - Call LCD update */ -void loop() -{ +void loop() { if (commands_in_queue < BUFSIZE) get_available_commands(); #if ENABLED(SDSUPPORT) card.checkautostart(false); #endif - if (commands_in_queue) - { + if (commands_in_queue) { + #if ENABLED(SDSUPPORT) - if (card.saving) - { + + if (card.saving) { char* command = command_queue[cmd_queue_index_r]; - if (strstr_P(command, PSTR("M29"))) - { + if (strstr_P(command, PSTR("M29"))) { // M29 closes the file card.closefile(); SERIAL_PROTOCOLLNPGM(MSG_FILE_SAVED); @@ -13983,8 +13943,7 @@ void loop() ok_to_send(); } - else - { + else { // Write the string from the read buffer to SD card.write_command(command); if (card.logging) @@ -13993,8 +13952,7 @@ void loop() ok_to_send(); } } - else - { + else { process_next_command(); #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE) save_power_off_info(); @@ -14008,13 +13966,9 @@ void loop() #endif // SDSUPPORT // The queue may be reset by a command handler or by code invoked by idle() within a handler - if (commands_in_queue) - { + if (commands_in_queue) { --commands_in_queue; - if (++cmd_queue_index_r >= BUFSIZE) - { - cmd_queue_index_r = 0; - } + if (++cmd_queue_index_r >= BUFSIZE) cmd_queue_index_r = 0; } } endstops.report_state(); diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp index c0b51b8929ca..953cb6399fb7 100644 --- a/Marlin/cardreader.cpp +++ b/Marlin/cardreader.cpp @@ -918,20 +918,16 @@ void CardReader::updir() { #endif // SDCARD_SORT_ALPHA -void CardReader::printingHasFinished() -{ +void CardReader::printingHasFinished() { stepper.synchronize(); file.close(); - if (file_subcall_ctr > 0) - { - // Heading up to a parent file that called current as a procedure. + if (file_subcall_ctr > 0) { // Heading up to a parent file that called current as a procedure. file_subcall_ctr--; openFile(proc_filenames[file_subcall_ctr], true, true); setIndex(filespos[file_subcall_ctr]); startFileprint(); } - else - { + else { sdprinting = false; #if ENABLED(POWEROFF_SAVE_SD_FILE) openPowerOffFile(power_off_info.power_off_filename, O_CREAT | O_WRITE | O_TRUNC | O_SYNC); diff --git a/Marlin/configuration_store.cpp b/Marlin/configuration_store.cpp index 955d54a37d64..4fa9db910da7 100644 --- a/Marlin/configuration_store.cpp +++ b/Marlin/configuration_store.cpp @@ -545,8 +545,7 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(volumetric_enabled); // Save filament sizes - for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) - { + for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) { if (q < COUNT(filament_size)) dummy = filament_size[q]; EEPROM_WRITE(dummy); } @@ -931,8 +930,7 @@ void MarlinSettings::postprocess() { EEPROM_READ(volumetric_enabled); - for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) - { + for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) { EEPROM_READ(dummy); if (q < COUNT(filament_size)) filament_size[q] = dummy; } diff --git a/Marlin/dogm_bitmaps.h b/Marlin/dogm_bitmaps.h index 092fda3c7b78..7963fd3ca886 100644 --- a/Marlin/dogm_bitmaps.h +++ b/Marlin/dogm_bitmaps.h @@ -226,8 +226,7 @@ #define START_BMPBYTEWIDTH 7 #define START_BMPBYTES 133 // START_BMPWIDTH * START_BMPHEIGHT / 8 - const unsigned char start_bmp[START_BMPBYTES] PROGMEM = - { + const unsigned char start_bmp[START_BMPBYTES] PROGMEM = { 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, @@ -246,9 +245,7 @@ 0x8C, 0x30, 0xC7, 0x7C, 0x03, 0x8F, 0x19, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, - 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8 - - }; + 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8 }; #endif #endif @@ -314,8 +311,7 @@ #define STATUS_SCREENWIDTH 125 //Width in pixels #define STATUS_SCREENHEIGHT 19 //Height in pixels #define STATUS_SCREENBYTEWIDTH 15 //Width in bytes - const unsigned char status_screen0_bmp[] PROGMEM = - { + const unsigned char status_screen0_bmp[] PROGMEM = { // AVR-GCC, WinAVR // chuangxiang 3D /* diff --git a/Marlin/language.h b/Marlin/language.h index e68ca795211c..0ff6badefb49 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -177,20 +177,20 @@ #define MSG_SOFT_MAX " Max: " #define MSG_SD_CANT_OPEN_SUBDIR "Cannot open subdir " -#define MSG_SD_INIT_FAIL "TF init fail" +#define MSG_SD_INIT_FAIL "SD init fail" #define MSG_SD_VOL_INIT_FAIL "volume.init failed" #define MSG_SD_OPENROOT_FAIL "openRoot failed" -#define MSG_SD_CARD_OK "TF card ok" +#define MSG_SD_CARD_OK "SD card ok" #define MSG_SD_WORKDIR_FAIL "workDir open failed" #define MSG_SD_OPEN_FILE_FAIL "open failed, File: " #define MSG_SD_FILE_OPENED "File opened: " #define MSG_SD_SIZE " Size: " #define MSG_SD_FILE_SELECTED "File selected" #define MSG_SD_WRITE_TO_FILE "Writing to file: " -#define MSG_SD_PRINTING_BYTE "TF printing byte " -#define MSG_SD_NOT_PRINTING "Not TF printing" +#define MSG_SD_PRINTING_BYTE "SD printing byte " +#define MSG_SD_NOT_PRINTING "Not SD printing" #define MSG_SD_ERR_WRITE_TO_FILE "error writing to file" -#define MSG_SD_ERR_READ "TF read error" +#define MSG_SD_ERR_READ "SD read error" #define MSG_SD_CANT_ENTER_SUBDIR "Cannot enter subdir: " #define MSG_STEPPER_TOO_HIGH "Steprate too high: " diff --git a/Marlin/language_en.h b/Marlin/language_en.h index 11a9f31350bd..96b686349b4a 100644 --- a/Marlin/language_en.h +++ b/Marlin/language_en.h @@ -564,10 +564,10 @@ #define MSG_STOP_PRINT _UxGT("Stop print") #endif #ifndef MSG_CARD_MENU - #define MSG_CARD_MENU _UxGT("Print from TF") + #define MSG_CARD_MENU _UxGT("Print from SD") #endif #ifndef MSG_NO_CARD - #define MSG_NO_CARD _UxGT("No TF card") + #define MSG_NO_CARD _UxGT("No SD card") #endif #ifndef MSG_DWELL #define MSG_DWELL _UxGT("Sleep...") @@ -621,10 +621,10 @@ #define MSG_FILAMENTCHANGE _UxGT("Change filament") #endif #ifndef MSG_INIT_SDCARD - #define MSG_INIT_SDCARD _UxGT("Init. TF card") + #define MSG_INIT_SDCARD _UxGT("Init. SD card") #endif #ifndef MSG_CNG_SDCARD - #define MSG_CNG_SDCARD _UxGT("Change TF card") + #define MSG_CNG_SDCARD _UxGT("Change SD card") #endif #ifndef MSG_ZPROBE_OUT #define MSG_ZPROBE_OUT _UxGT("Z probe out. bed") diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 1c47fb2d504d..e2ea537841ef 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -506,42 +506,26 @@ int Temperature::getHeaterPower(int heater) { // // Temperature Error Handlers // -void Temperature::_temp_error(const int8_t e, const char * const serial_msg, const char * const lcd_msg) -{ +void Temperature::_temp_error(const int8_t e, const char * const serial_msg, const char * const lcd_msg) { static bool killed = false; - if (IsRunning()) - { + if (IsRunning()) { SERIAL_ERROR_START(); serialprintPGM(serial_msg); SERIAL_ERRORPGM(MSG_STOPPED_HEATER); - if (e >= 0) - { - SERIAL_ERRORLN((int)e); - } - else - { - SERIAL_ERRORLNPGM(MSG_HEATER_BED); - } + if (e >= 0) SERIAL_ERRORLN((int)e); else SERIAL_ERRORLNPGM(MSG_HEATER_BED); } #if DISABLED(BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE) - if (!killed) - { - // Generate error temperature, close firmware. + if (!killed) { Running = false; killed = true; - // Diabale lcd message display kill(lcd_msg); } else - { - // paranoia prohibits all heating. - disable_all_heaters(); - } + disable_all_heaters(); // paranoia #endif } -void Temperature::max_temp_error(const int8_t e) -{ +void Temperature::max_temp_error(const int8_t e) { #if HAS_TEMP_BED _temp_error(e, PSTR(MSG_T_MAXTEMP), e >= 0 ? PSTR(MSG_ERR_MAXTEMP) : PSTR(MSG_ERR_MAXTEMP_BED)); #else @@ -551,8 +535,7 @@ void Temperature::max_temp_error(const int8_t e) #endif #endif } -void Temperature::min_temp_error(const int8_t e) -{ +void Temperature::min_temp_error(const int8_t e) { #if HAS_TEMP_BED _temp_error(e, PSTR(MSG_T_MINTEMP), e >= 0 ? PSTR(MSG_ERR_MINTEMP) : PSTR(MSG_ERR_MINTEMP_BED)); #else diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 77698ba199d1..5c0322c76949 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -758,8 +758,7 @@ void kill_screen(const char* lcd_msg) { int mytemphot = 0; int mytempbed = 0; float pause_z = 0; - void lcd_sdcard_pause() - { + void lcd_sdcard_pause() { card.pauseSDPrint(); print_job_timer.pause(); @@ -779,8 +778,7 @@ void kill_screen(const char* lcd_msg) { lcd_setstatusPGM(PSTR(MSG_PRINT_PAUSED), -1); } - void lcd_sdcard_resume() - { + void lcd_sdcard_resume() { char cmd1[30]; char pause_str_Z[16]; @@ -789,8 +787,7 @@ void kill_screen(const char* lcd_msg) { SERIAL_PROTOCOLLN(pause_str_Z); SERIAL_PROTOCOLLN("lcd_sdcard_resume() pause_str_Z"); #if ENABLED(POWEROFF_SAVE_SD_FILE) - if (power_off_commands_count > 0) - { + if (power_off_commands_count > 0) { sprintf_P(cmd1, PSTR("M190 S%i"), power_off_info.target_temperature_bed); enqueue_and_echo_command(cmd1); sprintf_P(cmd1, PSTR("M109 S%i"), power_off_info.target_temperature[0]); @@ -800,8 +797,7 @@ void kill_screen(const char* lcd_msg) { // enqueue_and_echo_command(cmd1); power_off_type_yes = 1; } - else - { + else { sprintf_P(cmd1, PSTR("M140 S%i"), mytempbed); enqueue_and_echo_command(cmd1); sprintf_P(cmd1, PSTR("M109 S%i"), mytemphot); @@ -828,8 +824,7 @@ void kill_screen(const char* lcd_msg) { lcd_reset_status(); } - void lcd_sdcard_stop() - { + void lcd_sdcard_stop() { card.stopSDPrint(); clear_command_queue(); quickstop_stepper(); @@ -839,8 +834,7 @@ void kill_screen(const char* lcd_msg) { card.openPowerOffFile(power_off_info.power_off_filename, O_CREAT | O_WRITE | O_TRUNC | O_SYNC); power_off_info.valid_head = 0; power_off_info.valid_foot = 0; - if (card.savePowerOffInfo(&power_off_info, sizeof(power_off_info)) == -1) - { + if (card.savePowerOffInfo(&power_off_info, sizeof(power_off_info)) == -1) { SERIAL_PROTOCOLLN("Stop to Write power off file failed."); } card.closePowerOffFile(); @@ -918,10 +912,6 @@ void kill_screen(const char* lcd_msg) { MENU_ITEM(gcode, MSG_BLTOUCH_SELFTEST, PSTR("M280 P" STRINGIFY(Z_ENDSTOP_SERVO_NR) " S" STRINGIFY(BLTOUCH_SELFTEST))); MENU_ITEM(gcode, MSG_BLTOUCH_DEPLOY, PSTR("M280 P" STRINGIFY(Z_ENDSTOP_SERVO_NR) " S" STRINGIFY(BLTOUCH_DEPLOY))); MENU_ITEM(gcode, MSG_BLTOUCH_STOW, PSTR("M280 P" STRINGIFY(Z_ENDSTOP_SERVO_NR) " S" STRINGIFY(BLTOUCH_STOW))); - // BLTouch has no physical response under these instructions, so delete the control display to avoid user misunderstanding - // MENU_ITEM(gcode, MSG_BLTOUCH_SW_MODE, PSTR("M280 P" STRINGIFY(Z_ENDSTOP_SERVO_NR) " S" STRINGIFY(BLTOUCH_SW_MODE))); - // MENU_ITEM(gcode, MSG_BLTOUCH_5V_MODE, PSTR("M280 P" STRINGIFY(Z_ENDSTOP_SERVO_NR) " S" STRINGIFY(BLTOUCH_5V_MODE))); - // MENU_ITEM(gcode, MSG_BLTOUCH_OD_MODE, PSTR("M280 P" STRINGIFY(Z_ENDSTOP_SERVO_NR) " S" STRINGIFY(BLTOUCH_OD_MODE))); END_MENU(); } @@ -1031,8 +1021,7 @@ void kill_screen(const char* lcd_msg) { * */ - void lcd_main_menu() - { + void lcd_main_menu() { START_MENU(); MENU_BACK(MSG_WATCH); @@ -1051,54 +1040,41 @@ void kill_screen(const char* lcd_msg) { // Set Case light on/off/brightness // #if ENABLED(MENU_ITEM_CASE_LIGHT) - if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) - { + if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) { MENU_ITEM(submenu, MSG_CASE_LIGHT, case_light_menu); } else - { MENU_ITEM_EDIT_CALLBACK(bool, MSG_CASE_LIGHT, (bool*)&case_light_on, update_case_light); - } #endif - if (planner.movesplanned() || IS_SD_PRINTING) - { + if (planner.movesplanned() || IS_SD_PRINTING) { MENU_ITEM(submenu, MSG_TUNE, lcd_tune_menu); } - else - { + else { MENU_ITEM(submenu, MSG_PREPARE, lcd_prepare_menu); } MENU_ITEM(submenu, MSG_CONTROL, lcd_control_menu); #if ENABLED(SDSUPPORT) - if (card.cardOK) - { - if (card.isFileOpen()) - { + if (card.cardOK) { + if (card.isFileOpen()) { #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE) - if (power_off_commands_count > 0) - { + if (power_off_commands_count > 0) { // MENU_ITEM(submenu, MSG_RESUME_PRINT_OK, lcd_resume_ok_menu); - if (card.sdprinting) - { + if (card.sdprinting) { MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause); } - else - { + else { MENU_ITEM(function, MSG_RESUME_PRINT, lcd_sdcard_resume); } MENU_ITEM(function, MSG_STOP_PRINT, lcd_sdcard_stop); } - else - { + else { #endif - if (card.sdprinting) - { + if (card.sdprinting) { MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause); } - else - { + else { MENU_ITEM(function, MSG_RESUME_PRINT, lcd_sdcard_resume); } MENU_ITEM(function, MSG_STOP_PRINT, lcd_sdcard_stop); @@ -1106,16 +1082,14 @@ void kill_screen(const char* lcd_msg) { } #endif } - else - { + else { MENU_ITEM(submenu, MSG_CARD_MENU, lcd_sdcard_menu); #if !PIN_EXISTS(SD_DETECT) MENU_ITEM(gcode, MSG_CNG_SDCARD, PSTR("M21")); // SD-card changed by user #endif } } - else - { + else { MENU_ITEM(submenu, MSG_NO_CARD, lcd_sdcard_menu); #if !PIN_EXISTS(SD_DETECT) MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface @@ -2671,8 +2645,7 @@ static void lcd_autohome() // // Auto Home // - // MENU_ITEM(gcode, msg_auto_home(), PSTR("G28")); - MENU_ITEM(function, MSG_AUTO_HOME, lcd_autohome); + MENU_ITEM(function, MSG_AUTO_HOME, lcd_autohome); #if ENABLED(INDIVIDUAL_AXIS_HOMING_MENU) MENU_ITEM(gcode, MSG_AUTO_HOME_X, PSTR("G28 X")); MENU_ITEM(gcode, MSG_AUTO_HOME_Y, PSTR("G28 Y")); @@ -3489,6 +3462,7 @@ static void lcd_autohome() #endif // !PID_PARAMS_PER_HOTEND || HOTENDS == 1 #endif // PIDTEMP + */ // // Preheat Material 1 conf @@ -4641,8 +4615,7 @@ void lcd_update() { lcd_buttons_update(); #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE) - if ((power_off_type_yes == 0) && (power_off_commands_count > 0)) - { + if ((power_off_type_yes == 0) && (power_off_commands_count > 0)) { currentScreen = lcd_resume_ok_menu; } #endif @@ -4654,51 +4627,37 @@ void lcd_update() { #endif // If the action button is pressed... - if (UBL_CONDITION && LCD_CLICKED) - { - if (!wait_for_unclick) - { - // If not waiting for a debounce release: - wait_for_unclick = true; // Set debounce flag to ignore continous clicks - lcd_clicked = !wait_for_user; // Keep the click if not waiting for a user-click - wait_for_user = false; // Any click clears wait for user - lcd_quick_feedback(); // Always make a click sound + if (UBL_CONDITION && LCD_CLICKED) { + if (!wait_for_unclick) { // If not waiting for a debounce release: + wait_for_unclick = true; // Set debounce flag to ignore continous clicks + lcd_clicked = !wait_for_user; // Keep the click if not waiting for a user-click + wait_for_user = false; // Any click clears wait for user + lcd_quick_feedback(); // Always make a click sound } } - else - { - wait_for_unclick = false; - } + else wait_for_unclick = false; #endif #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) const bool sd_status = IS_SD_INSERTED; - if (sd_status != lcd_sd_status && lcd_detected()) - { - if (sd_status) - { + if (sd_status != lcd_sd_status && lcd_detected()) { + + if (sd_status) { card.initsd(); - if (lcd_sd_status != 2) - { - LCD_MESSAGEPGM(MSG_SD_INSERTED); - } + if (lcd_sd_status != 2) LCD_MESSAGEPGM(MSG_SD_INSERTED); #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE) init_power_off_info(); #endif } else { card.release(); - if (lcd_sd_status != 2) - { - LCD_MESSAGEPGM(MSG_SD_REMOVED); - } + if (lcd_sd_status != 2) LCD_MESSAGEPGM(MSG_SD_REMOVED); } lcd_sd_status = sd_status; lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; - // to maybe revive the LCD if static electricity killed it. - lcd_implementation_init( + lcd_implementation_init( // to maybe revive the LCD if static electricity killed it. #if ENABLED(LCD_PROGRESS_BAR) currentScreen == lcd_status_screen #endif @@ -4729,9 +4688,7 @@ void lcd_update() { #if ENABLED(ADC_KEYPAD) if (handle_adc_keypad()) - { return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS; - } #elif ENABLED(REPRAPWORLD_KEYPAD) @@ -4740,32 +4697,22 @@ void lcd_update() { #endif bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP); - if (encoderPastThreshold || lcd_clicked) - { - if (encoderPastThreshold) - { + if (encoderPastThreshold || lcd_clicked) { + if (encoderPastThreshold) { int32_t encoderMultiplier = 1; #if ENABLED(ENCODER_RATE_MULTIPLIER) - if (encoderRateMultiplierEnabled) - { + if (encoderRateMultiplierEnabled) { int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP; - if (lastEncoderMovementMillis) - { + if (lastEncoderMovementMillis) { // Note that the rate is always calculated between two passes through the // loop and that the abs of the encoderDiff value is tracked. float encoderStepRate = float(encoderMovementSteps) / float(ms - lastEncoderMovementMillis) * 1000.0; - if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) - { - encoderMultiplier = 100; - } - else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) - { - encoderMultiplier = 10; - } + if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = 100; + else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10; #if ENABLED(ENCODER_RATE_MULTIPLIER_DEBUG) SERIAL_ECHO_START(); @@ -4797,8 +4744,7 @@ void lcd_update() { currentScreen == lcd_status_screen && #endif !lcd_status_update_delay-- - ) - { + ) { lcd_status_update_delay = 9 #if ENABLED(DOGLCD) + 3 @@ -4821,8 +4767,7 @@ void lcd_update() { if (!drawing_screen) #endif { - switch (lcdDrawUpdate) - { + switch (lcdDrawUpdate) { case LCDVIEW_CALL_NO_REDRAW: lcdDrawUpdate = LCDVIEW_NONE; break; @@ -4846,16 +4791,14 @@ void lcd_update() { #endif #if ENABLED(DOGLCD) // Changes due to different driver architecture of the DOGM display - if (!drawing_screen) - { + if (!drawing_screen) { u8g.firstPage(); drawing_screen = 1; } lcd_setFont(FONT_MENU); u8g.setColorIndex(1); CURRENTSCREEN(); - if (drawing_screen && (drawing_screen = u8g.nextPage())) - { + if (drawing_screen && (drawing_screen = u8g.nextPage())) { NOLESS(max_display_update_time, millis() - ms); return; } @@ -4869,13 +4812,9 @@ void lcd_update() { // Return to Status Screen after a timeout if (currentScreen == lcd_status_screen || defer_return_to_status) - { return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS; - } else if (ELAPSED(ms, return_to_status_ms)) - { lcd_return_to_status(); - } #endif // ULTIPANEL @@ -4883,8 +4822,7 @@ void lcd_update() { if (!drawing_screen) #endif { - switch (lcdDrawUpdate) - { + switch (lcdDrawUpdate) { case LCDVIEW_CLEAR_CALL_REDRAW: lcd_implementation_clear(); case LCDVIEW_CALL_REDRAW_NEXT: diff --git a/Marlin/ultralcd_impl_DOGM.h b/Marlin/ultralcd_impl_DOGM.h index ff00bf483e3a..189bef705723 100644 --- a/Marlin/ultralcd_impl_DOGM.h +++ b/Marlin/ultralcd_impl_DOGM.h @@ -291,12 +291,11 @@ void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) { #endif // SHOW_CUSTOM_BOOTSCREEN - void lcd_bootscreen() - { + void lcd_bootscreen() { + static bool show_bootscreen = true; - if (show_bootscreen) - { + if (show_bootscreen) { show_bootscreen = false; #if ENABLED(START_BMPHIGH) @@ -326,8 +325,7 @@ void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) { #endif // SHOW_BOOTSCREEN // Initialize or re-initialize the LCD -static void lcd_implementation_init() -{ +static void lcd_implementation_init() { #if PIN_EXISTS(LCD_BACKLIGHT) // Enable LCD backlight OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH); #endif @@ -479,10 +477,9 @@ inline void lcd_implementation_status_message(const bool blink) { #endif } -// #define DOGM_SD_PERCENT +//#define DOGM_SD_PERCENT -static void lcd_implementation_status_screen() -{ +static void lcd_implementation_status_screen() { const bool blink = lcd_blink(); @@ -493,8 +490,7 @@ static void lcd_implementation_status_screen() // Fan Animation // - if (PAGE_UNDER(STATUS_SCREENHEIGHT + 1)) - { + if (PAGE_UNDER(STATUS_SCREENHEIGHT + 1)) { // u8g.drawBitmapP(9, 1, STATUS_SCREENBYTEWIDTH, STATUS_SCREENHEIGHT, u8g.drawBitmapP(0, 1, STATUS_SCREENBYTEWIDTH, STATUS_SCREENHEIGHT, #if HAS_FAN0 @@ -510,8 +506,7 @@ static void lcd_implementation_status_screen() // Temperature Graphics and Info // - if (PAGE_UNDER(28)) - { + if (PAGE_UNDER(28)) { // Extruders // HOTEND_LOOP() _draw_heater_status(5 + e * 25, e, blink); for(int e = 0; e < 1; e++) _draw_heater_status(38 + e * 25, e, blink); @@ -522,12 +517,10 @@ static void lcd_implementation_status_screen() #endif #if HAS_FAN0 - if (PAGE_CONTAINS(20, 27)) - { + if (PAGE_CONTAINS(20, 27)) { // Fan const int16_t per = ((fanSpeeds[0] + 1) * 100) / 256; - if (per) - { + if (per) { u8g.setPrintPos(104, 27); lcd_print(itostr3(per)); u8g.print('%'); @@ -542,8 +535,7 @@ static void lcd_implementation_status_screen() // SD Card Symbol // - if (PAGE_CONTAINS(42 - (TALL_FONT_CORRECTION), 51 - (TALL_FONT_CORRECTION))) - { + if (PAGE_CONTAINS(42 - (TALL_FONT_CORRECTION), 51 - (TALL_FONT_CORRECTION))) { // Upper box u8g.drawBox(42, 42 - (TALL_FONT_CORRECTION), 8, 7); // 42-48 (or 41-47) // Right edge @@ -603,8 +595,7 @@ static void lcd_implementation_status_screen() #define SD_DURATION_X (LCD_PIXEL_WIDTH - len * DOG_CHAR_WIDTH) #endif - if (PAGE_CONTAINS(41, 48)) - { + if (PAGE_CONTAINS(41, 48)) { char buffer[10]; duration_t elapsed = print_job_timer.duration(); @@ -613,16 +604,14 @@ static void lcd_implementation_status_screen() u8g.setPrintPos(60, 48); lcd_print(buffer); - if(previous_cmd_ms != 0) - { + if(previous_cmd_ms != 0) { // Displays the percentage of printing. uint16_t progresssum=card.percentDone(); u8g.setPrintPos(104,51); u8g.print(itostr3(progresssum)); u8g.print('%'); } - else - { + else { // Shows the percentage of print progress. u8g.setPrintPos(104,51); u8g.print(itostr3(0)); @@ -666,8 +655,7 @@ static void lcd_implementation_status_screen() #endif // At the first page, regenerate the XYZ strings - if (page.page == 0) - { + if (page.page == 0) { strcpy(xstring, ftostr4sign(current_position[X_AXIS])); strcpy(ystring, ftostr4sign(current_position[Y_AXIS])); strcpy(zstring, ftostr52sp(FIXFLOAT(current_position[Z_AXIS]))); @@ -716,8 +704,7 @@ static void lcd_implementation_status_screen() // Feedrate // - if (PAGE_CONTAINS(51 - INFO_FONT_HEIGHT, 49)) - { + if (PAGE_CONTAINS(51 - INFO_FONT_HEIGHT, 49)) { lcd_setFont(FONT_MENU); u8g.setPrintPos(3, 50); lcd_print(LCD_STR_FEEDRATE[0]); @@ -750,18 +737,14 @@ static void lcd_implementation_status_screen() #define STATUS_BASELINE (55 + INFO_FONT_HEIGHT) - if (PAGE_CONTAINS(STATUS_BASELINE - (INFO_FONT_HEIGHT - 1), STATUS_BASELINE)) - { + if (PAGE_CONTAINS(STATUS_BASELINE - (INFO_FONT_HEIGHT - 1), STATUS_BASELINE)) { u8g.setPrintPos(0, STATUS_BASELINE); #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT) - if (PENDING(millis(), previous_lcd_status_ms + 5000UL)) - { - //Display both Status message line and Filament display on the last line + if (PENDING(millis(), previous_lcd_status_ms + 5000UL)) { //Display both Status message line and Filament display on the last line lcd_implementation_status_message(blink); } - else - { + else { lcd_printPGM(PSTR(LCD_STR_FILAM_DIA)); u8g.print(':'); lcd_print(ftostr12ns(filament_width_meas));