From 900302e5126abfde41c006f403275b58fd9ca3fd Mon Sep 17 00:00:00 2001 From: Marcio Teixeira Date: Mon, 19 Aug 2019 16:29:31 -0600 Subject: [PATCH 1/9] Make sure LCD_TIMEOUT_TO_STATUS is expressed in ms --- Marlin/src/lcd/extensible_ui/lib/lulzbot/config.h | 5 ++--- .../lcd/extensible_ui/lib/lulzbot/screens/base_screen.cpp | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Marlin/src/lcd/extensible_ui/lib/lulzbot/config.h b/Marlin/src/lcd/extensible_ui/lib/lulzbot/config.h index fe41f58e543b..5313bb947ff1 100644 --- a/Marlin/src/lcd/extensible_ui/lib/lulzbot/config.h +++ b/Marlin/src/lcd/extensible_ui/lib/lulzbot/config.h @@ -80,9 +80,8 @@ // This is a recommended for smaller displays. //#define TOUCH_UI_PASSCODE -// Define number of seconds after which the menu screens -// timeout and returns the user to the status screen -//#define LCD_TIMEOUT_TO_STATUS 120 +// The timeout (in ms) to return to the status screen from sub-menus +//#define LCD_TIMEOUT_TO_STATUS 15000 // Enable this to debug the event framework //#define UI_FRAMEWORK_DEBUG diff --git a/Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/base_screen.cpp b/Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/base_screen.cpp index 2a041bf77be1..3dc356c530e7 100644 --- a/Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/base_screen.cpp +++ b/Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/base_screen.cpp @@ -63,7 +63,7 @@ bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t void BaseScreen::onIdle() { #ifdef LCD_TIMEOUT_TO_STATUS const uint32_t elapsed = millis() - last_interaction; - if (elapsed > uint32_t(LCD_TIMEOUT_TO_STATUS) * 1000) { + if (elapsed > uint32_t(LCD_TIMEOUT_TO_STATUS)) { reset_menu_timeout(); GOTO_SCREEN(StatusScreen); } From a3ce5e025ef7346f7ce7eb46eb4b63c6f9b69a6a Mon Sep 17 00:00:00 2001 From: Marcio Teixeira Date: Mon, 19 Aug 2019 16:42:00 -0600 Subject: [PATCH 2/9] Use ENABLED consistently --- .../extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/commands.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/commands.cpp b/Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/commands.cpp index fc296c8ebcaf..ad34f4f19119 100644 --- a/Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/commands.cpp +++ b/Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/commands.cpp @@ -1160,7 +1160,7 @@ void CLCD::default_display_orientation() { cmd.execute(); } else { - #ifdef TOUCH_UI_INVERTED + #if ENABLED(TOUCH_UI_INVERTED) mem_write_32(REG::ROTATE, 1); #endif } From 9ce0c796f6b703c9a2ffcebba740833ebaea7e3a Mon Sep 17 00:00:00 2001 From: Marcio Teixeira Date: Tue, 20 Aug 2019 09:17:15 -0600 Subject: [PATCH 3/9] Ensure the code in ftdi_eve_lib is portable - Make sure the library code still works outside of Marlin --- Marlin/src/lcd/extensible_ui/lib/lulzbot/compat.h | 13 +++---------- .../extensible_ui/lib/lulzbot/ftdi_eve_lib/compat.h | 8 ++++++++ .../lib/lulzbot/screens/endstop_state_screen.cpp | 6 ------ 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Marlin/src/lcd/extensible_ui/lib/lulzbot/compat.h b/Marlin/src/lcd/extensible_ui/lib/lulzbot/compat.h index c595692bd20f..ee4beb4de39e 100644 --- a/Marlin/src/lcd/extensible_ui/lib/lulzbot/compat.h +++ b/Marlin/src/lcd/extensible_ui/lib/lulzbot/compat.h @@ -40,16 +40,9 @@ #include "pin_mappings.h" #else // Messages that are declared in Marlin - #define WELCOME_MSG "Printer Ready" - #define MSG_SD_INSERTED "Media Inserted" - #define MSG_SD_REMOVED "Media Removed" - - // Define macros for compatibility - #define EXTENSIBLE_UI - #define _CAT(a, ...) a ## __VA_ARGS__ - #define SWITCH_ENABLED_ 1 - #define ENABLED(b) _CAT(SWITCH_ENABLED_, b) - #define DISABLED(b) !ENABLED(b) + #define WELCOME_MSG "Printer Ready" + #define MSG_MEDIA_INSERTED "Media Inserted" + #define MSG_MEDIA_REMOVED "Media Removed" namespace UI { static inline uint32_t safe_millis() {return millis();}; diff --git a/Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/compat.h b/Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/compat.h index 992f19a3b347..cf48ffa63029 100644 --- a/Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/compat.h +++ b/Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/compat.h @@ -200,6 +200,14 @@ #define safe_delay delay + // Define macros for compatibility + + #define _CAT(a, ...) a ## __VA_ARGS__ + #define SWITCH_ENABLED_ 1 + #define ENABLED(b) _CAT(SWITCH_ENABLED_, b) + #define DISABLED(b) !ENABLED(b) + #define ANY(A,B) ENABLED(A) || ENABLED(B) + // Remove compiler warning on an unused variable #ifndef UNUSED #if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) diff --git a/Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/endstop_state_screen.cpp b/Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/endstop_state_screen.cpp index 389ce3e3f1ff..f1e13d3a9a6c 100644 --- a/Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/endstop_state_screen.cpp +++ b/Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/endstop_state_screen.cpp @@ -32,16 +32,10 @@ using namespace ExtUI; void EndstopStatesScreen::onEntry() { BaseScreen::onEntry(); - #ifdef LULZBOT_SET_PROBE_PINS_STATE - LULZBOT_SET_PROBE_PINS_STATE(true) - #endif } void EndstopStatesScreen::onExit() { BaseScreen::onExit(); - #ifdef LULZBOT_SET_PROBE_PINS_STATE - LULZBOT_SET_PROBE_PINS_STATE(false) - #endif } void EndstopStatesScreen::onRedraw(draw_mode_t) { From a220fbafec66927d8d141924ab1caa98dd68b821 Mon Sep 17 00:00:00 2001 From: Marcio Teixeira Date: Tue, 20 Aug 2019 10:53:36 -0600 Subject: [PATCH 4/9] Make include guards consistent. --- .../extensible_ui/lib/lulzbot/archim2-flash/flash_storage.h | 2 +- .../lib/lulzbot/archim2-flash/media_file_reader.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/flash_storage.h b/Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/flash_storage.h index 85863320bf4f..219a0046874c 100644 --- a/Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/flash_storage.h +++ b/Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/flash_storage.h @@ -20,7 +20,7 @@ * location: . * ****************************************************************************/ -#ifdef LULZBOT_TOUCH_UI +#if ENABLED(LULZBOT_TOUCH_UI) class SPIFlash { public: diff --git a/Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/media_file_reader.h b/Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/media_file_reader.h index 59a73ffbcc3a..cfade3e331a4 100644 --- a/Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/media_file_reader.h +++ b/Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/media_file_reader.h @@ -22,6 +22,8 @@ #pragma once +#if ENABLED(LULZBOT_TOUCH_UI) + #include "../../../../../sd/SdFile.h" #include "../../../../../sd/cardreader.h" @@ -42,3 +44,5 @@ class MediaFileReader { static int16_t read(void *obj, void *buff, size_t bytes); }; + +#endif // LULZBOT_TOUCH_UI From edf6ca44ad7ef53e2db24f93f2e0df44e2e25a62 Mon Sep 17 00:00:00 2001 From: Marcio Teixeira Date: Tue, 20 Aug 2019 11:30:50 -0600 Subject: [PATCH 5/9] Fixed incorrect path --- .../src/lcd/extensible_ui/lib/lulzbot/screens/status_screen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/status_screen.cpp b/Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/status_screen.cpp index ebd52548d959..420ac2b43096 100644 --- a/Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/status_screen.cpp +++ b/Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/status_screen.cpp @@ -30,7 +30,7 @@ #include "../archim2-flash/flash_storage.h" #if ENABLED(SDSUPPORT) && defined(LULZBOT_MANUAL_USB_STARTUP) - #include "../../../../sd/cardreader.h" + #include "../../../../../sd/cardreader.h" #endif using namespace FTDI; From 21cdd8f4300c5f6e874be6941e8de4a400dd6d0c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 21 Aug 2019 03:55:02 -0500 Subject: [PATCH 6/9] Rather than wrapping header, don't include it --- .../lib/lulzbot/archim2-flash/media_file_reader.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/media_file_reader.h b/Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/media_file_reader.h index cfade3e331a4..d64182fd5b0b 100644 --- a/Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/media_file_reader.h +++ b/Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/media_file_reader.h @@ -22,10 +22,12 @@ #pragma once -#if ENABLED(LULZBOT_TOUCH_UI) +#include "../../../../../inc/MarlinConfigPre.h" -#include "../../../../../sd/SdFile.h" -#include "../../../../../sd/cardreader.h" +#if ENABLED(SDSUPPORT) + #include "../../../../../sd/SdFile.h" + #include "../../../../../sd/cardreader.h" +#endif class MediaFileReader { private: @@ -44,5 +46,3 @@ class MediaFileReader { static int16_t read(void *obj, void *buff, size_t bytes); }; - -#endif // LULZBOT_TOUCH_UI From 5221ceedc981532c1e2fc76cb63b90deaecd70d0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 21 Aug 2019 04:04:29 -0500 Subject: [PATCH 7/9] Don't wrap headers, just don't include them Headers should (almost) always include their dependencies. In this case both `` and the header defining `progmem_str` should have explicit `#include` lines in this file. --- .../extensible_ui/lib/lulzbot/archim2-flash/flash_storage.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/flash_storage.h b/Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/flash_storage.h index 219a0046874c..d211f48b38d3 100644 --- a/Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/flash_storage.h +++ b/Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/flash_storage.h @@ -20,8 +20,6 @@ * location: . * ****************************************************************************/ -#if ENABLED(LULZBOT_TOUCH_UI) - class SPIFlash { public: static constexpr uint32_t erase_unit_size = 4 * 1024; // Minimum erase unit @@ -106,5 +104,3 @@ class UIFlashStorage::BootMediaReader { static int16_t read(void *obj, void *buffer, const size_t size); }; - -#endif // LULZBOT_TOUCH_UI From 50bb8980766e74674445c9aa046042235d58e0a7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 21 Aug 2019 04:12:42 -0500 Subject: [PATCH 8/9] Update compat.h --- Marlin/src/lcd/extensible_ui/lib/lulzbot/compat.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Marlin/src/lcd/extensible_ui/lib/lulzbot/compat.h b/Marlin/src/lcd/extensible_ui/lib/lulzbot/compat.h index ee4beb4de39e..ae74bcd126e5 100644 --- a/Marlin/src/lcd/extensible_ui/lib/lulzbot/compat.h +++ b/Marlin/src/lcd/extensible_ui/lib/lulzbot/compat.h @@ -35,9 +35,8 @@ #endif #ifdef __MARLIN_FIRMWARE__ - // If __MARLIN_FIRMWARE__ exists, then we are being - // compiled inside Marlin. - #include "pin_mappings.h" + // __MARLIN_FIRMWARE__ exists when compiled within Marlin. + #include "pin_mappings.h" #else // Messages that are declared in Marlin #define WELCOME_MSG "Printer Ready" From 6dd4eb4e9ccb1f8afa6e9e32d4239cebab0c1b6f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 21 Aug 2019 04:13:44 -0500 Subject: [PATCH 9/9] Update compat.h --- .../lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/compat.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/compat.h b/Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/compat.h index cf48ffa63029..9ef90f7a9e33 100644 --- a/Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/compat.h +++ b/Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/compat.h @@ -20,13 +20,15 @@ #include "../config.h" #ifdef __MARLIN_FIRMWARE__ - // Marlin will define the I/O functions for us + // Marlin will define the I/O functions for us #if ENABLED(LULZBOT_TOUCH_UI) #define FTDI_BASIC #define FTDI_EXTENDED #endif -#else + +#else // !__MARLIN_FIRMWARE__ + #include "Arduino.h" #if !defined(CLCD_USE_SOFT_SPI) @@ -216,4 +218,5 @@ #define UNUSED(x) ((void)(x)) #endif #endif -#endif //!defined(__MARLIN_FIRMWARE__) + +#endif // !__MARLIN_FIRMWARE__