0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-02-27 19:36:58 +00:00

🚸 MarlinUI:: clear_for_drawing

This commit is contained in:
Scott Lahteine 2024-06-26 18:27:05 -05:00
parent bf1995140a
commit 1f9fc665ec
21 changed files with 61 additions and 24 deletions

View file

@ -1099,6 +1099,9 @@
* - poweroff (for PSU_CONTROL and HAS_MARLINUI_MENU) * - poweroff (for PSU_CONTROL and HAS_MARLINUI_MENU)
* *
* ...and implements these MarlinUI methods: * ...and implements these MarlinUI methods:
* - init_lcd
* - clear_lcd
* - clear_for_drawing
* - zoffset_overlay (if BABYSTEP_GFX_OVERLAY or MESH_EDIT_GFX_OVERLAY are supported) * - zoffset_overlay (if BABYSTEP_GFX_OVERLAY or MESH_EDIT_GFX_OVERLAY are supported)
* - draw_kill_screen * - draw_kill_screen
* - kill_screen * - kill_screen

View file

@ -557,8 +557,8 @@
#endif #endif
#endif #endif
#if HAS_SD_DETECT && NONE(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT, IS_DWIN_MARLINUI, EXTENSIBLE_UI, HAS_DWIN_E3V2, HAS_U8GLIB_I2C_OLED) #if HAS_SD_DETECT && NONE(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT, IS_DWIN_MARLINUI, EXTENSIBLE_UI, HAS_DWIN_E3V2)
#define REINIT_NOISY_SPI_LCD 1 // Have LCDs with shared SPI re-init on SD insertion #define REINIT_NOISY_LCD 1 // Have the LCD re-init on SD insertion
#endif #endif
#endif // HAS_MEDIA #endif // HAS_MEDIA

View file

@ -467,6 +467,7 @@ bool MarlinUI::detected() {
#endif #endif
void MarlinUI::clear_lcd() { lcd.clear(); } void MarlinUI::clear_lcd() { lcd.clear(); }
void MarlinUI::clear_for_drawing() { clear_lcd(); }
#if ENABLED(SHOW_BOOTSCREEN) #if ENABLED(SHOW_BOOTSCREEN)
@ -1515,7 +1516,7 @@ void MarlinUI::draw_status_screen() {
lower_right.column = 0; lower_right.column = 0;
lower_right.row = 0; lower_right.row = 0;
clear_lcd(); clear_for_drawing();
x_map_pixels = (HD44780_CHAR_WIDTH) * (MESH_MAP_COLS) - 2; // Minus 2 because we are drawing a box around the map x_map_pixels = (HD44780_CHAR_WIDTH) * (MESH_MAP_COLS) - 2; // Minus 2 because we are drawing a box around the map
y_map_pixels = (HD44780_CHAR_HEIGHT) * (MESH_MAP_ROWS) - 2; y_map_pixels = (HD44780_CHAR_HEIGHT) * (MESH_MAP_ROWS) - 2;

View file

@ -376,6 +376,8 @@ void MarlinUI::clear_lcd() {
lcd.clear_buffer(); lcd.clear_buffer();
} }
void MarlinUI::clear_for_drawing() { clear_lcd(); }
#if HAS_LCD_CONTRAST #if HAS_LCD_CONTRAST
void MarlinUI::_set_contrast() { lcd.setContrast(contrast); } void MarlinUI::_set_contrast() { lcd.setContrast(contrast); }
#endif #endif

View file

@ -374,7 +374,19 @@ void MarlinUI::draw_kill_screen() {
} while (u8g.nextPage()); } while (u8g.nextPage());
} }
void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop // Erase the LCD contents by drawing an empty box.
void MarlinUI::clear_lcd() {
u8g.setColorIndex(0);
u8g.firstPage();
do {
u8g.drawBox(0, 0, u8g.getWidth(), u8g.getHeight());
} while (u8g.nextPage());
}
// U8G displays are drawn over multiple loops so must do their own clearing.
void MarlinUI::clear_for_drawing() {
// Automatically cleared by Picture Loop
}
#if HAS_DISPLAY_SLEEP #if HAS_DISPLAY_SLEEP
void MarlinUI::sleep_display(const bool sleep/*=true*/) { void MarlinUI::sleep_display(const bool sleep/*=true*/) {

View file

@ -1816,6 +1816,8 @@ void hmiSDCardInit() { card.cdroot(); }
// Initialize or re-initialize the LCD // Initialize or re-initialize the LCD
void MarlinUI::init_lcd() { dwinStartup(); } void MarlinUI::init_lcd() { dwinStartup(); }
void MarlinUI::clear_lcd() {}
void MarlinUI::update() { void MarlinUI::update() {
eachMomentUpdate(); // Status update eachMomentUpdate(); // Status update
hmiSDCardUpdate(); // SD card update hmiSDCardUpdate(); // SD card update

View file

@ -5155,6 +5155,8 @@ void MarlinUI::init_lcd() {
jyersDWIN.redrawScreen(); jyersDWIN.redrawScreen();
} }
void MarlinUI::clear_lcd() {}
#if ENABLED(ADVANCED_PAUSE_FEATURE) #if ENABLED(ADVANCED_PAUSE_FEATURE)
void MarlinUI::pause_show_message(const PauseMessage message, const PauseMode mode/*=PAUSE_MODE_SAME*/, const uint8_t extruder/*=active_extruder*/) { void MarlinUI::pause_show_message(const PauseMessage message, const PauseMode mode/*=PAUSE_MODE_SAME*/, const uint8_t extruder/*=active_extruder*/) {
if (mode != PAUSE_MODE_SAME) pause_mode = mode; if (mode != PAUSE_MODE_SAME) pause_mode = mode;

View file

@ -90,6 +90,8 @@ void MarlinUI::clear_lcd() {
did_first_redraw = false; did_first_redraw = false;
} }
void MarlinUI::clear_for_drawing() { clear_lcd(); }
#if ENABLED(SHOW_BOOTSCREEN) #if ENABLED(SHOW_BOOTSCREEN)
void MarlinUI::show_bootscreen() { void MarlinUI::show_bootscreen() {
@ -111,7 +113,7 @@ void MarlinUI::clear_lcd() {
dwinDrawString(false, font10x20, COLOR_YELLOW, COLOR_BG_BLACK, INFO_CENTER - (dwin_string.length * 10) / 2, VERSION_Y, S(dwin_string.string())); dwinDrawString(false, font10x20, COLOR_YELLOW, COLOR_BG_BLACK, INFO_CENTER - (dwin_string.length * 10) / 2, VERSION_Y, S(dwin_string.string()));
TERN_(SHOW_CUSTOM_BOOTSCREEN, safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT)); TERN_(SHOW_CUSTOM_BOOTSCREEN, safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT));
clear_lcd(); clear_for_drawing();
dwinIconShow(BOOT_ICON, ICON_MarlinBoot, LOGO_CENTER - 266 / 2, 15); dwinIconShow(BOOT_ICON, ICON_MarlinBoot, LOGO_CENTER - 266 / 2, 15);
#if ENABLED(DWIN_MARLINUI_PORTRAIT) #if ENABLED(DWIN_MARLINUI_PORTRAIT)
@ -132,7 +134,7 @@ void MarlinUI::clear_lcd() {
void MarlinUI::bootscreen_completion(const millis_t sofar) { void MarlinUI::bootscreen_completion(const millis_t sofar) {
if ((BOOTSCREEN_TIMEOUT) > sofar) safe_delay((BOOTSCREEN_TIMEOUT) - sofar); if ((BOOTSCREEN_TIMEOUT) > sofar) safe_delay((BOOTSCREEN_TIMEOUT) - sofar);
clear_lcd(); clear_for_drawing();
} }
#endif #endif

View file

@ -1913,6 +1913,8 @@ void MarlinUI::init_lcd() {
dwinJPGCacheTo1(Language_English); dwinJPGCacheTo1(Language_English);
} }
void MarlinUI::clear_lcd() {}
void dwinInitScreen() { void dwinInitScreen() {
dwinSetColorDefaults(); dwinSetColorDefaults();
hmiInit(); // Draws boot screen hmiInit(); // Draws boot screen

View file

@ -195,6 +195,7 @@ namespace ExtUI {
void onPIDTuning(const pidresult_t rst) { void onPIDTuning(const pidresult_t rst) {
// Called for temperature PID tuning result // Called for temperature PID tuning result
switch (rst) { switch (rst) {
default: break;
#if ENABLED(PIDTEMP) #if ENABLED(PIDTEMP)
case PID_STARTED: dwinPIDTuning(PIDTEMP_START); break; case PID_STARTED: dwinPIDTuning(PIDTEMP_START); break;
#endif #endif

View file

@ -1279,6 +1279,9 @@ namespace ExtUI {
#if DISABLED(HAS_DWIN_E3V2) #if DISABLED(HAS_DWIN_E3V2)
void MarlinUI::init_lcd() { ExtUI::onStartup(); } void MarlinUI::init_lcd() { ExtUI::onStartup(); }
void MarlinUI::clear_lcd() {}
void MarlinUI::clear_for_drawing() {}
void MarlinUI::update() { ExtUI::onIdle(); } void MarlinUI::update() { ExtUI::onIdle(); }
void MarlinUI::kill_screen(FSTR_P const error, FSTR_P const component) { void MarlinUI::kill_screen(FSTR_P const error, FSTR_P const component) {

View file

@ -226,6 +226,7 @@ void MarlinUI::init() {
#endif #endif
init_lcd(); init_lcd();
clear_lcd();
#if BUTTON_EXISTS(EN1) #if BUTTON_EXISTS(EN1)
SET_INPUT_PULLUP(BTN_EN1); SET_INPUT_PULLUP(BTN_EN1);
@ -1204,7 +1205,7 @@ void MarlinUI::init() {
// Change state of drawing flag between screen updates // Change state of drawing flag between screen updates
if (!drawing_screen) switch (lcdDrawUpdate) { if (!drawing_screen) switch (lcdDrawUpdate) {
case LCDVIEW_CLEAR_CALL_REDRAW: case LCDVIEW_CLEAR_CALL_REDRAW:
clear_lcd(); break; clear_for_drawing(); break;
case LCDVIEW_REDRAW_NOW: case LCDVIEW_REDRAW_NOW:
refresh(LCDVIEW_NONE); refresh(LCDVIEW_NONE);
case LCDVIEW_NONE: case LCDVIEW_NONE:

View file

@ -207,11 +207,14 @@ public:
#if HAS_DISPLAY || HAS_DWIN_E3V2 #if HAS_DISPLAY || HAS_DWIN_E3V2
static void init_lcd(); static void init_lcd();
// Erase the LCD contents. Do the lowest-level thing required to clear the LCD.
static void clear_lcd();
#else #else
static void init_lcd() {} static void init_lcd() {}
static void clear_lcd() {}
#endif #endif
static void reinit_lcd() { TERN_(REINIT_NOISY_SPI_LCD, init_lcd()); } static void reinit_lcd() { TERN_(REINIT_NOISY_LCD, init_lcd()); }
#if HAS_WIRED_LCD #if HAS_WIRED_LCD
static bool detected(); static bool detected();
@ -246,9 +249,6 @@ public:
static void update_indicators(); static void update_indicators();
#endif #endif
// LCD implementations
static void clear_lcd();
#if ALL(HAS_MARLINUI_MENU, TOUCH_SCREEN_CALIBRATION) #if ALL(HAS_MARLINUI_MENU, TOUCH_SCREEN_CALIBRATION)
static void check_touch_calibration() { static void check_touch_calibration() {
if (touch_calibration.need_calibration()) currentScreen = touch_calibration_screen; if (touch_calibration.need_calibration()) currentScreen = touch_calibration_screen;
@ -520,6 +520,9 @@ public:
#if HAS_DISPLAY #if HAS_DISPLAY
// Clear the LCD before new drawing. Some LCDs do nothing because they redraw frequently.
static void clear_for_drawing();
static void abort_print(); static void abort_print();
static void pause_print(); static void pause_print();
static void resume_print(); static void resume_print();
@ -630,6 +633,7 @@ public:
#else // No LCD #else // No LCD
static void clear_for_drawing() {}
static void kill_screen(FSTR_P const, FSTR_P const) {} static void kill_screen(FSTR_P const, FSTR_P const) {}
#endif #endif

View file

@ -209,7 +209,7 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
TERN_(AUTO_BED_LEVELING_UBL, bedlevel.lcd_map_control = false); TERN_(AUTO_BED_LEVELING_UBL, bedlevel.lcd_map_control = false);
} }
clear_lcd(); clear_for_drawing();
// Re-initialize custom characters that may be re-used // Re-initialize custom characters that may be re-used
#if HAS_MARLINUI_HD44780 #if HAS_MARLINUI_HD44780

View file

@ -96,7 +96,7 @@ void _lcd_mesh_fine_tune(FSTR_P const fmsg) {
// To capture encoder events UBL will also call ui.capture and ui.release. // To capture encoder events UBL will also call ui.capture and ui.release.
// //
void MarlinUI::ubl_mesh_edit_start(const_float_t initial) { void MarlinUI::ubl_mesh_edit_start(const_float_t initial) {
TERN_(HAS_GRAPHICAL_TFT, clear_lcd()); TERN_(HAS_GRAPHICAL_TFT, clear_for_drawing());
mesh_edit_accumulator = initial; mesh_edit_accumulator = initial;
goto_screen([]{ _lcd_mesh_fine_tune(GET_TEXT_F(MSG_MESH_EDIT_Z)); }); goto_screen([]{ _lcd_mesh_fine_tune(GET_TEXT_F(MSG_MESH_EDIT_Z)); });
} }

View file

@ -184,7 +184,7 @@ void Touch::touch(touch_control_t *control) {
case HEATER: case HEATER:
int8_t heater; int8_t heater;
heater = control->data; heater = control->data;
ui.clear_lcd(); ui.clear_for_drawing();
#if HAS_HOTEND #if HAS_HOTEND
if (heater >= 0) { // HotEnd if (heater >= 0) { // HotEnd
#if HOTENDS == 1 #if HOTENDS == 1
@ -213,20 +213,20 @@ void Touch::touch(touch_control_t *control) {
break; break;
case FAN: case FAN:
ui.clear_lcd(); ui.clear_for_drawing();
static uint8_t fan, fan_speed; static uint8_t fan, fan_speed;
fan = 0; fan = 0;
fan_speed = thermalManager.fan_speed[fan]; fan_speed = thermalManager.fan_speed[fan];
MenuItem_percent::action(GET_TEXT_F(MSG_FIRST_FAN_SPEED), &fan_speed, 0, 255, []{ thermalManager.set_fan_speed(fan, fan_speed); TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_BIT_SYNC_FANS));}); MenuItem_percent::action(GET_TEXT_F(MSG_FIRST_FAN_SPEED), &fan_speed, 0, 255, []{ thermalManager.set_fan_speed(fan, fan_speed); TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_BIT_SYNC_FANS));});
break; break;
case FEEDRATE: case FEEDRATE:
ui.clear_lcd(); ui.clear_for_drawing();
MenuItem_int3::action(GET_TEXT_F(MSG_SPEED), &feedrate_percentage, SPEED_EDIT_MIN, SPEED_EDIT_MAX); MenuItem_int3::action(GET_TEXT_F(MSG_SPEED), &feedrate_percentage, SPEED_EDIT_MIN, SPEED_EDIT_MAX);
break; break;
#if HAS_EXTRUDERS #if HAS_EXTRUDERS
case FLOWRATE: case FLOWRATE:
ui.clear_lcd(); ui.clear_for_drawing();
MenuItemBase::itemIndex = control->data; MenuItemBase::itemIndex = control->data;
#if EXTRUDERS == 1 #if EXTRUDERS == 1
MenuItem_int3::action(GET_TEXT_F(MSG_FLOW), &planner.flow_percentage[MenuItemBase::itemIndex], FLOW_EDIT_MIN, FLOW_EDIT_MAX, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }); MenuItem_int3::action(GET_TEXT_F(MSG_FLOW), &planner.flow_percentage[MenuItemBase::itemIndex], FLOW_EDIT_MIN, FLOW_EDIT_MAX, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); });

View file

@ -79,7 +79,7 @@ void MarlinUI::tft_idle() {
void MarlinUI::bootscreen_completion(const millis_t sofar) { void MarlinUI::bootscreen_completion(const millis_t sofar) {
if ((BOOTSCREEN_TIMEOUT) > sofar) safe_delay((BOOTSCREEN_TIMEOUT) - sofar); if ((BOOTSCREEN_TIMEOUT) > sofar) safe_delay((BOOTSCREEN_TIMEOUT) - sofar);
clear_lcd(); clear_for_drawing();
} }
#endif #endif

View file

@ -199,7 +199,7 @@ void moveAxis(const AxisEnum axis, const int8_t direction) {
tft.queue.reset(); tft.queue.reset();
if (!sleepCleared) { if (!sleepCleared) {
sleepCleared = true; sleepCleared = true;
ui.clear_lcd(); ui.clear_for_drawing();
tft.queue.async(); tft.queue.async();
} }
touch.idle(); touch.idle();
@ -407,7 +407,7 @@ void MarlinUI::init_lcd() {
tft.add_glyphs(EXTRA_FONT_NAME); tft.add_glyphs(EXTRA_FONT_NAME);
#endif #endif
TERN_(TOUCH_SCREEN, touch.init()); TERN_(TOUCH_SCREEN, touch.init());
clear_lcd(); clear_for_drawing();
} }
void MarlinUI::clear_lcd() { void MarlinUI::clear_lcd() {
@ -421,6 +421,8 @@ void MarlinUI::clear_lcd() {
cursor.set(0, 0); cursor.set(0, 0);
} }
void MarlinUI::clear_for_drawing() { clear_lcd(); }
#if HAS_LCD_BRIGHTNESS #if HAS_LCD_BRIGHTNESS
void MarlinUI::_set_brightness() { void MarlinUI::_set_brightness() {
@ -441,7 +443,7 @@ void MarlinUI::clear_lcd() {
if (stage == CALIBRATION_NONE) { if (stage == CALIBRATION_NONE) {
defer_status_screen(true); defer_status_screen(true);
clear_lcd(); clear_for_drawing();
stage = touch_calibration.calibration_start(); stage = touch_calibration.calibration_start();
} }
else { else {

View file

@ -133,7 +133,7 @@ void MarlinUI::move_axis_screen() {
motionAxisState.blocked = false; motionAxisState.blocked = false;
TERN_(TOUCH_SCREEN, touch.enable()); TERN_(TOUCH_SCREEN, touch.enable());
ui.clear_lcd(); ui.clear_for_drawing();
TERN_(TOUCH_SCREEN, touch.clear()); TERN_(TOUCH_SCREEN, touch.clear());

View file

@ -146,7 +146,7 @@ void MarlinUI::move_axis_screen() {
motionAxisState.blocked = false; motionAxisState.blocked = false;
TERN_(TOUCH_SCREEN, touch.enable()); TERN_(TOUCH_SCREEN, touch.enable());
ui.clear_lcd(); ui.clear_for_drawing();
TERN_(TOUCH_SCREEN, touch.clear()); TERN_(TOUCH_SCREEN, touch.clear());

View file

@ -146,7 +146,7 @@ void MarlinUI::move_axis_screen() {
motionAxisState.blocked = false; motionAxisState.blocked = false;
TERN_(TOUCH_SCREEN, touch.enable()); TERN_(TOUCH_SCREEN, touch.enable());
ui.clear_lcd(); ui.clear_for_drawing();
TERN_(TOUCH_SCREEN, touch.clear()); TERN_(TOUCH_SCREEN, touch.clear());