diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 6c80f58406db..da801bb9d48d 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -524,18 +524,12 @@ //#define MIN_BED_POWER 0 //#define PID_BED_DEBUG // Sends debug data to the serial port. - //120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) - //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) + // 120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) + // from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) #define DEFAULT_bedKp 10.00 #define DEFAULT_bedKi .023 #define DEFAULT_bedKd 305.4 - //120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) - //from pidautotune - //#define DEFAULT_bedKp 97.1 - //#define DEFAULT_bedKi 1.41 - //#define DEFAULT_bedKd 1675.16 - // FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles. #endif // PIDTEMPBED diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 959cf2fdf15b..dfb675a67608 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3252,7 +3252,7 @@ */ //#define MMU_EXTRUDER_SENSOR #if ENABLED(MMU_EXTRUDER_SENSOR) - #define MMU_LOADING_ATTEMPTS_NR 5 //max. number of attempts to load filament if first load fail + #define MMU_LOADING_ATTEMPTS_NR 5 // max. number of attempts to load filament if first load fail #endif /** diff --git a/Marlin/src/feature/mmu2/mmu2.cpp b/Marlin/src/feature/mmu2/mmu2.cpp index 31b179a3e5e9..31fa529d56b1 100644 --- a/Marlin/src/feature/mmu2/mmu2.cpp +++ b/Marlin/src/feature/mmu2/mmu2.cpp @@ -838,8 +838,7 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) { if (move_axes && all_axes_homed()) { LCD_MESSAGEPGM(MSG_MMU2_RESUMING); - BUZZ(200, 404); - BUZZ(200, 404); + BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404); // Move XY to starting position, then Z do_blocking_move_to_xy(resume_position, feedRate_t(NOZZLE_PARK_XY_FEEDRATE)); @@ -848,8 +847,7 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) { do_blocking_move_to_z(resume_position.z, feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); } else { - BUZZ(200, 404); - BUZZ(200, 404); + BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404); LCD_MESSAGEPGM(MSG_MMU2_RESUMING); } } diff --git a/Marlin/src/gcode/config/M302.cpp b/Marlin/src/gcode/config/M302.cpp index 14fbd9f57202..afdc6c9e8506 100644 --- a/Marlin/src/gcode/config/M302.cpp +++ b/Marlin/src/gcode/config/M302.cpp @@ -37,7 +37,7 @@ * * M302 ; report current cold extrusion state * M302 P0 ; enable cold extrusion checking - * M302 P1 ; disables cold extrusion checking + * M302 P1 ; disable cold extrusion checking * M302 S0 ; always allow extrusion (disables checking) * M302 S170 ; only allow extrusion above 170 * M302 S170 P1 ; set min extrude temp to 170 but leave disabled diff --git a/Marlin/src/gcode/sd/M24_M25.cpp b/Marlin/src/gcode/sd/M24_M25.cpp index c27e03862cbf..bdb37f605cbf 100644 --- a/Marlin/src/gcode/sd/M24_M25.cpp +++ b/Marlin/src/gcode/sd/M24_M25.cpp @@ -98,7 +98,9 @@ void GcodeSuite::M25() { print_job_timer.pause(); - TERN(DWIN_CREALITY_LCD,,ui.reset_status()); + #if DISABLED(DWIN_CREALITY_LCD) + ui.reset_status(); + #endif #if ENABLED(HOST_ACTION_COMMANDS) TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("Pause SD"), PSTR("Resume"))); diff --git a/Marlin/src/gcode/sd/M524.cpp b/Marlin/src/gcode/sd/M524.cpp index b27814cc38be..089d2e2f0c41 100644 --- a/Marlin/src/gcode/sd/M524.cpp +++ b/Marlin/src/gcode/sd/M524.cpp @@ -34,6 +34,8 @@ void GcodeSuite::M524() { if (IS_SD_PRINTING()) card.flag.abort_sd_printing = true; + else if (card.isMounted()) + card.closefile(); } diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index a06ea4fe5a5f..4431dadce09c 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-09-27" + #define STRING_DISTRIBUTION_DATE "2020-09-28" #endif /** diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 131c96bef1e1..c0096d379de6 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -494,6 +494,16 @@ inline void Draw_Back_First(const bool is_sel=true) { if (is_sel) Draw_Menu_Cursor(0); } +inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, auto &valref) { + if (encoder_diffState == ENCODER_DIFF_CW) + valref += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + valref -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) + return true; + return false; +} + // // Draw Menus // @@ -1099,7 +1109,7 @@ void Goto_PrintProcess() { // Copy into filebuf string before entry char * const name = card.longest_filename(); - const int8_t npos = _MAX(0, DWIN_WIDTH - strlen(name) * MENU_CHR_W) / 2; + const int8_t npos = _MAX(0U, DWIN_WIDTH - strlen(name) * MENU_CHR_W) / 2; DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, npos, 60, name); DWIN_ICON_Show(ICON, ICON_PrintTime, 17, 193); @@ -1146,13 +1156,7 @@ inline ENCODER_DiffState get_encoder_state() { void HMI_Move_X() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { - if (encoder_diffState == ENCODER_DIFF_CW) { - HMI_ValueStruct.Move_X_scale += EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - HMI_ValueStruct.Move_X_scale -= EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_X_scale)) { checkkey = AxisMove; EncoderRate.enabled = false; DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); @@ -1175,13 +1179,7 @@ void HMI_Move_X() { void HMI_Move_Y() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { - if (encoder_diffState == ENCODER_DIFF_CW) { - HMI_ValueStruct.Move_Y_scale += EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - HMI_ValueStruct.Move_Y_scale -= EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Y_scale)) { checkkey = AxisMove; EncoderRate.enabled = false; DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); @@ -1204,13 +1202,7 @@ void HMI_Move_Y() { void HMI_Move_Z() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { - if (encoder_diffState == ENCODER_DIFF_CW) { - HMI_ValueStruct.Move_Z_scale += EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - HMI_ValueStruct.Move_Z_scale -= EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Z_scale)) { checkkey = AxisMove; EncoderRate.enabled = false; DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); @@ -1236,13 +1228,7 @@ void HMI_Move_Z() { static float last_E_scale = 0; ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { - if (encoder_diffState == ENCODER_DIFF_CW) { - HMI_ValueStruct.Move_E_scale += EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - HMI_ValueStruct.Move_E_scale -= EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_E_scale)) { checkkey = AxisMove; EncoderRate.enabled = false; last_E_scale = HMI_ValueStruct.Move_E_scale; @@ -1278,11 +1264,7 @@ void HMI_Move_Z() { case -4: zoff_line = PREPARE_CASE_ZOFF + MROWS - index_prepare; break; default: zoff_line = TUNE_CASE_ZOFF + MROWS - index_tune; } - if (encoder_diffState == ENCODER_DIFF_CW) - HMI_ValueStruct.offset_value += EncoderRate.encoderMoveValue; - else if (encoder_diffState == ENCODER_DIFF_CCW) - HMI_ValueStruct.offset_value -= EncoderRate.encoderMoveValue; - else if (encoder_diffState == ENCODER_DIFF_ENTER) { + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.offset_value)) { EncoderRate.enabled = false; #if HAS_BED_PROBE probe.offset.z = dwin_zoffset; @@ -1326,13 +1308,7 @@ void HMI_Move_Z() { case -3: temp_line = PREHEAT_CASE_TEMP; break; default: temp_line = TUNE_CASE_TEMP + MROWS - index_tune; } - if (encoder_diffState == ENCODER_DIFF_CW) { - HMI_ValueStruct.E_Temp += EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - HMI_ValueStruct.E_Temp -= EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.E_Temp)) { EncoderRate.enabled = false; if (HMI_ValueStruct.show_mode == -1) { // temperature checkkey = TemperatureID; @@ -1379,13 +1355,7 @@ void HMI_Move_Z() { case -3: bed_line = PREHEAT_CASE_BED; break; default: bed_line = TUNE_CASE_BED + MROWS - index_tune; } - if (encoder_diffState == ENCODER_DIFF_CW) { - HMI_ValueStruct.Bed_Temp += EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - HMI_ValueStruct.Bed_Temp -= EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Bed_Temp)) { EncoderRate.enabled = false; if (HMI_ValueStruct.show_mode == -1) { checkkey = TemperatureID; @@ -1433,13 +1403,7 @@ void HMI_Move_Z() { default: fan_line = TUNE_CASE_FAN + MROWS - index_tune; } - if (encoder_diffState == ENCODER_DIFF_CW) { - HMI_ValueStruct.Fan_speed += EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - HMI_ValueStruct.Fan_speed -= EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Fan_speed)) { EncoderRate.enabled = false; if (HMI_ValueStruct.show_mode == -1) { checkkey = TemperatureID; @@ -1477,13 +1441,7 @@ void HMI_Move_Z() { void HMI_PrintSpeed() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { - if (encoder_diffState == ENCODER_DIFF_CW) { - HMI_ValueStruct.print_speed += EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - HMI_ValueStruct.print_speed -= EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.print_speed)) { checkkey = Tune; EncoderRate.enabled = false; feedrate_percentage = HMI_ValueStruct.print_speed; @@ -1501,13 +1459,7 @@ void HMI_PrintSpeed() { void HMI_MaxFeedspeedXYZE() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { - if (encoder_diffState == ENCODER_DIFF_CW) { - HMI_ValueStruct.Max_Feedspeed += EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - HMI_ValueStruct.Max_Feedspeed -= EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Feedspeed)) { checkkey = MaxSpeed; EncoderRate.enabled = false; if (WITHIN(HMI_flag.feedspeed_axis, X_AXIS, E_AXIS)) @@ -1527,9 +1479,7 @@ void HMI_MaxFeedspeedXYZE() { void HMI_MaxAccelerationXYZE() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { - if (encoder_diffState == ENCODER_DIFF_CW) { HMI_ValueStruct.Max_Acceleration += EncoderRate.encoderMoveValue;} - else if (encoder_diffState == ENCODER_DIFF_CCW) { HMI_ValueStruct.Max_Acceleration -= EncoderRate.encoderMoveValue;} - else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Acceleration)) { checkkey = MaxAcceleration; EncoderRate.enabled = false; if (HMI_flag.acc_axis == X_AXIS) planner.set_max_acceleration(X_AXIS, HMI_ValueStruct.Max_Acceleration); @@ -1555,11 +1505,7 @@ void HMI_MaxAccelerationXYZE() { void HMI_MaxJerkXYZE() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { - if (encoder_diffState == ENCODER_DIFF_CW) - HMI_ValueStruct.Max_Jerk += EncoderRate.encoderMoveValue; - else if (encoder_diffState == ENCODER_DIFF_CCW) - HMI_ValueStruct.Max_Jerk -= EncoderRate.encoderMoveValue; - else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Jerk)) { checkkey = MaxJerk; EncoderRate.enabled = false; if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS)) @@ -1581,13 +1527,7 @@ void HMI_MaxAccelerationXYZE() { void HMI_StepXYZE() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { - if (encoder_diffState == ENCODER_DIFF_CW) { - HMI_ValueStruct.Max_Step += EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - HMI_ValueStruct.Max_Step -= EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Step)) { checkkey = Step; EncoderRate.enabled = false; if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS)) @@ -1787,7 +1727,7 @@ inline void Draw_SDItem(const uint16_t item, int16_t row=-1) { inline void Draw_SDItem_Shifted(int8_t &shift) { // Limit to the number of chars past the cutoff const size_t len = strlen(shift_name); - NOMORE(shift, _MAX((signed)len - MENU_CHAR_LIMIT, 0)); + NOMORE(shift, _MAX(len - MENU_CHAR_LIMIT, 0U)); // Shorten to the available space const size_t lastchar = _MIN((signed)len, shift + MENU_CHAR_LIMIT); @@ -1813,11 +1753,17 @@ inline void Redraw_SD_List() { Draw_Back_First(); - // As many files as will fit - LOOP_L_N(i, _MIN(nr_sd_menu_items(), MROWS)) - Draw_SDItem(i, i + 1); + if (card.isMounted()) { + // As many files as will fit + LOOP_L_N(i, _MIN(nr_sd_menu_items(), MROWS)) + Draw_SDItem(i, i + 1); - TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift()); + TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift()); + } + else { + DWIN_Draw_Rectangle(1, Color_Bg_Red, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4)); + DWIN_Draw_String(false, false, font16x32, Color_Yellow, Color_Bg_Red, ((DWIN_WIDTH) - 8 * 16) / 2, MBASE(3), F("No Media")); + } } bool DWIN_lcd_sd_status = false; @@ -1842,7 +1788,7 @@ void HMI_SDCardUpdate() { if (DWIN_lcd_sd_status != card.isMounted()) { DWIN_lcd_sd_status = card.isMounted(); // SERIAL_ECHOLNPAIR("HMI_SDCardUpdate: ", int(DWIN_lcd_sd_status)); - if (card.isMounted()) { + if (DWIN_lcd_sd_status) { if (checkkey == SelectFile) Redraw_SD_List(); } @@ -1863,10 +1809,11 @@ void HMI_SDCardUpdate() { } } -/* Start Frame */ - -void HMI_StartFrame(const bool with_update) { - Goto_MainMenu(); +// +// The status area is always on-screen, except during +// full-screen modal dialogs. (TODO: Keep alive during dialogs) +// +void Draw_Status_Area(const bool with_update) { // Clear the bottom area of the screen DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1); @@ -1906,6 +1853,11 @@ void HMI_StartFrame(const bool with_update) { } } +void HMI_StartFrame(const bool with_update) { + Goto_MainMenu(); + Draw_Status_Area(with_update); +} + inline void Draw_Info_Menu() { Clear_Main_Window(); @@ -2233,12 +2185,10 @@ void HMI_PauseOrStop() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_CW) { + if (encoder_diffState == ENCODER_DIFF_CW) Draw_Select_Highlight(false); - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { + else if (encoder_diffState == ENCODER_DIFF_CCW) Draw_Select_Highlight(true); - } else if (encoder_diffState == ENCODER_DIFF_ENTER) { if (select_print.now == 1) { // pause window if (HMI_flag.select_flag) { diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.h b/Marlin/src/lcd/dwin/e3v2/dwin.h index 7b759d9cbfea..1b2cb273e3f8 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.h +++ b/Marlin/src/lcd/dwin/e3v2/dwin.h @@ -215,9 +215,11 @@ enum processID : uint8_t { // Color #define Color_White 0xFFFF +#define Color_Yellow 0xFF0F #define Color_Bg_Window 0x31E8 // Popup background color #define Color_Bg_Blue 0x1125 // Dark blue background color #define Color_Bg_Black 0x0841 // Black background color +#define Color_Bg_Red 0xF00F // Red background color #define Popup_Text_Color 0xD6BA // Popup font background color #define Line_Color 0x3A6A // Split line color #define Rectangle_Color 0xEE2F // Blue square cursor color @@ -335,8 +337,8 @@ void Icon_temperature(bool value); void Icon_leveling(bool value); // Other -bool Pause_HeatStatus(); -void HMI_StartFrame(const bool with_update); // Startup screen +void Draw_Status_Area(const bool with_update); // Status Area +void HMI_StartFrame(const bool with_update); // Prepare the menu view void HMI_MainMenu(); // Main process screen void HMI_SelectFile(); // File page void HMI_Printing(); // Print page diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 538fca3c881f..37af4a368846 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -53,7 +53,7 @@ #include "../feature/pause.h" #endif -#define DEBUG_OUT ENABLED(DEBUG_CARDREADER) +#define DEBUG_OUT EITHER(DEBUG_CARDREADER, MARLIN_DEV_MODE) #include "../core/debug_out.h" // public: @@ -716,7 +716,7 @@ void CardReader::beginautostart() { cdroot(); } -void CardReader::closefile(const bool store_location) { +void CardReader::closefile(const bool store_location/*=false*/) { file.sync(); file.close(); flag.saving = flag.logging = false; @@ -810,7 +810,7 @@ const char* CardReader::diveToFile(const bool update_cwd, SdFile*& curDir, const // Open curDir if (!sub->open(curDir, dosSubdirname, O_READ)) { - SERIAL_ECHOLNPAIR(STR_SD_OPEN_FILE_FAIL, dosSubdirname, "."); + openFailed(dosSubdirname); return nullptr; }