From 23ec6504103a99a0d769346e2a503a1d1764cf7b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 7 May 2019 20:32:50 -0500 Subject: [PATCH] Consolidate Malyan LCD and ExtUI --- Marlin/src/Marlin.cpp | 2 +- Marlin/src/inc/Conditionals_LCD.h | 9 +++-- Marlin/src/lcd/malyanlcd.cpp | 56 +++++++++---------------------- Marlin/src/lcd/ultralcd.cpp | 6 ++-- Marlin/src/lcd/ultralcd.h | 17 ++++------ 5 files changed, 33 insertions(+), 57 deletions(-) diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index f9edc472c7..bb1f68d12b 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -733,7 +733,7 @@ void kill(PGM_P const lcd_msg/*=NULL*/) { SERIAL_ERROR_MSG(MSG_ERR_KILLED); - #if HAS_SPI_LCD || ENABLED(EXTENSIBLE_UI) + #if HAS_DISPLAY ui.kill_screen(lcd_msg ? lcd_msg : PSTR(MSG_KILLED)); #else UNUSED(lcd_msg); diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 752e399d7f..e447e06a51 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -329,8 +329,14 @@ #define ULTRA_LCD #endif +// Extensible UI serial touch screens. (See src/lcd/extensible_ui) +#if ENABLED(MALYAN_LCD) + #define EXTENSIBLE_UI +#endif + // Aliases for LCD features #define HAS_SPI_LCD ENABLED(ULTRA_LCD) +#define HAS_DISPLAY (HAS_SPI_LCD || ENABLED(EXTENSIBLE_UI)) #define HAS_GRAPHICAL_LCD ENABLED(DOGLCD) #define HAS_CHARACTER_LCD (HAS_SPI_LCD && !HAS_GRAPHICAL_LCD) #define HAS_LCD_MENU (ENABLED(ULTIPANEL) && DISABLED(NO_LCD_MENUS)) @@ -513,9 +519,6 @@ #define GRID_MAX_POINTS ((GRID_MAX_POINTS_X) * (GRID_MAX_POINTS_Y)) #endif -#if ENABLED(MALYAN_LCD) - #define EXTENSIBLE_UI -#endif #define HAS_SOFTWARE_ENDSTOPS EITHER(MIN_SOFTWARE_ENDSTOPS, MAX_SOFTWARE_ENDSTOPS) #define HAS_RESUME_CONTINUE ANY(EXTENSIBLE_UI, NEWPANEL, EMERGENCY_PARSER) #define HAS_COLOR_LEDS ANY(BLINKM, RGB_LED, RGBW_LED, PCA9632, PCA9533, NEOPIXEL_LED) diff --git a/Marlin/src/lcd/malyanlcd.cpp b/Marlin/src/lcd/malyanlcd.cpp index 8a6d611bd9..a3462d295d 100644 --- a/Marlin/src/lcd/malyanlcd.cpp +++ b/Marlin/src/lcd/malyanlcd.cpp @@ -474,52 +474,28 @@ namespace ExtUI { #endif } - void onPrinterKilled(PGM_P const msg) {} - void onMediaInserted() {}; - void onMediaError() {}; - void onMediaRemoved() {}; - void onPlayTone(const uint16_t frequency, const uint16_t duration) {} - void onPrintTimerStarted() {} - void onPrintTimerPaused() {} - void onPrintTimerStopped() {} - void onFilamentRunout() {} - void onUserConfirmRequired(const char * const msg) {} void onStatusChanged(const char * const msg) { write_to_lcd_P(PSTR("{E:")); write_to_lcd(msg); write_to_lcd_P("}"); } + + // Not needed for Malyan LCD + void onPrinterKilled(PGM_P const msg) { UNUSED(msg); } + void onMediaInserted() {}; + void onMediaError() {}; + void onMediaRemoved() {}; + void onPlayTone(const uint16_t frequency, const uint16_t duration) { UNUSED(frequency); UNUSED(duration); } + void onPrintTimerStarted() {} + void onPrintTimerPaused() {} + void onPrintTimerStopped() {} + void onFilamentRunout() {} + void onUserConfirmRequired(const char * const msg) { UNUSED(msg); } void onFactoryReset() {} - - void onStoreSettings(char *buff) { - // This is called when saving to EEPROM (i.e. M500). If the ExtUI needs - // permanent data to be stored, it can write up to eeprom_data_size bytes - // into buff. - - // Example: - // static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size); - // memcpy(buff, &myDataStruct, sizeof(myDataStruct)); - } - - void onLoadSettings(const char *buff) { - // This is called while loading settings from EEPROM. If the ExtUI - // needs to retrieve data, it should copy up to eeprom_data_size bytes - // from buff - - // Example: - // static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size); - // memcpy(&myDataStruct, buff, sizeof(myDataStruct)); - } - - void onConfigurationStoreWritten(bool success) { - // This is called after the entire EEPROM has been written, - // whether successful or not. - } - - void onConfigurationStoreRead(bool success) { - // This is called after the entire EEPROM has been read, - // whether successful or not. - } + void onStoreSettings(char *buff) { UNUSED(buff); } + void onLoadSettings(const char *buff) { UNUSED(buff); } + void onConfigurationStoreWritten(bool success) { UNUSED(success); } + void onConfigurationStoreRead(bool success) { UNUSED(success); } } #endif // MALYAN_LCD diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 2208b6b1bf..b17c4c6e03 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -23,7 +23,7 @@ #include "../inc/MarlinConfigPre.h" // These displays all share the MarlinUI class -#if HAS_SPI_LCD || ENABLED(EXTENSIBLE_UI) +#if HAS_DISPLAY #include "ultralcd.h" #include "fontutils.h" MarlinUI ui; @@ -1192,7 +1192,7 @@ void MarlinUI::update() { #endif // HAS_SPI_LCD -#if HAS_SPI_LCD || ENABLED(EXTENSIBLE_UI) +#if HAS_DISPLAY #if ENABLED(EXTENSIBLE_UI) #include "extensible_ui/ui_api.h" @@ -1376,4 +1376,4 @@ void MarlinUI::update() { } #endif -#endif // HAS_SPI_LCD || EXTENSIBLE_UI +#endif // HAS_DISPLAY diff --git a/Marlin/src/lcd/ultralcd.h b/Marlin/src/lcd/ultralcd.h index 2ea7f45279..95235d031a 100644 --- a/Marlin/src/lcd/ultralcd.h +++ b/Marlin/src/lcd/ultralcd.h @@ -268,17 +268,11 @@ public: static void clear_lcd(); static void init_lcd(); - #if HAS_SPI_LCD || EITHER(MALYAN_LCD, EXTENSIBLE_UI) + #if HAS_DISPLAY + static void init(); static void update(); static void set_alert_status_P(PGM_P message); - #else // NO LCD - static inline void init() {} - static inline void update() {} - static inline void set_alert_status_P(PGM_P message) { UNUSED(message); } - #endif - - #if HAS_SPI_LCD || ENABLED(EXTENSIBLE_UI) static char status_message[]; static bool has_status(); @@ -375,9 +369,12 @@ public: static void status_printf_P(const uint8_t level, PGM_P const fmt, ...); static void reset_status(); - #else // MALYAN_LCD or NO LCD + #else // No LCD + static inline void init() {} + static inline void update() {} static inline void refresh() {} + static inline void set_alert_status_P(PGM_P message) { UNUSED(message); } static inline void set_status(const char* const message, const bool persist=false) { UNUSED(message); UNUSED(persist); } static inline void set_status_P(PGM_P const message, const int8_t level=0) { UNUSED(message); UNUSED(level); } static inline void status_printf_P(const uint8_t level, PGM_P const fmt, ...) { UNUSED(level); UNUSED(fmt); } @@ -529,7 +526,7 @@ private: static void _synchronize(); - #if HAS_SPI_LCD || ENABLED(EXTENSIBLE_UI) + #if HAS_DISPLAY static void finish_status(const bool persist); #endif