Group status methods, share reset_status with Extensible UI (#12414)
* Group status methods, share reset_status with Extensible UI * Move common DOGM code to headers
This commit is contained in:
@ -38,166 +38,6 @@
|
||||
#include "../libs/buzzer.h"
|
||||
#endif
|
||||
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
|
||||
#ifndef LCD_PIXEL_WIDTH
|
||||
#define LCD_PIXEL_WIDTH 128
|
||||
#endif
|
||||
#ifndef LCD_PIXEL_HEIGHT
|
||||
#define LCD_PIXEL_HEIGHT 64
|
||||
#endif
|
||||
|
||||
// LCD selection
|
||||
#if ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
|
||||
#define U8G_CLASS U8GLIB_ST7920_128X64_4X
|
||||
#if DISABLED(SDSUPPORT) && (LCD_PINS_D4 == SCK_PIN) && (LCD_PINS_ENABLE == MOSI_PIN)
|
||||
#define U8G_PARAM LCD_PINS_RS
|
||||
#else
|
||||
#define U8G_PARAM LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS
|
||||
#endif
|
||||
|
||||
#elif ENABLED(U8GLIB_ST7920)
|
||||
// RepRap Discount Full Graphics Smart Controller
|
||||
#if DISABLED(SDSUPPORT) && (LCD_PINS_D4 == SCK_PIN) && (LCD_PINS_ENABLE == MOSI_PIN)
|
||||
#define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL
|
||||
#define U8G_PARAM LCD_PINS_RS // 2 stripes, HW SPI (shared with SD card, on AVR does not use standard LCD adapter)
|
||||
#else
|
||||
//#define U8G_CLASS U8GLIB_ST7920_128X64_4X
|
||||
//#define U8G_PARAM LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS // Original u8glib device. 2 stripes, SW SPI
|
||||
#define U8G_CLASS U8GLIB_ST7920_128X64_RRD
|
||||
#define U8G_PARAM LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS // Number of stripes can be adjusted in ultralcd_st7920_u8glib_rrd.h with PAGE_HEIGHT
|
||||
// AVR version ignores these pin settings
|
||||
// HAL version uses these pin settings
|
||||
#endif
|
||||
|
||||
#elif ENABLED(CARTESIO_UI)
|
||||
// The CartesioUI display
|
||||
//#define U8G_CLASS U8GLIB_DOGM128_2X
|
||||
//#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0 // 4 stripes
|
||||
#define U8G_CLASS U8GLIB_DOGM128_2X
|
||||
#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // 4 stripes
|
||||
|
||||
#elif ENABLED(U8GLIB_LM6059_AF)
|
||||
// Based on the Adafruit ST7565 (http://www.adafruit.com/products/250)
|
||||
//#define U8G_CLASS U8GLIB_LM6059
|
||||
//#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // 8 stripes
|
||||
#define U8G_CLASS U8GLIB_LM6059_2X
|
||||
#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // 4 stripes
|
||||
|
||||
#elif ENABLED(U8GLIB_ST7565_64128N)
|
||||
// The MaKrPanel, Mini Viki, Viki 2.0 & AZSMZ 12864 ST7565 controller
|
||||
#define SMART_RAMPS (MB(RAMPS_SMART_EFB) || MB(RAMPS_SMART_EEB) || MB(RAMPS_SMART_EFF) || MB(RAMPS_SMART_EEF) || MB(RAMPS_SMART_SF))
|
||||
#if DOGLCD_SCK == SCK_PIN && DOGLCD_MOSI == MOSI_PIN && !SMART_RAMPS
|
||||
#define U8G_CLASS U8GLIB_64128N_2X_HAL
|
||||
#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // using HW-SPI
|
||||
#else
|
||||
#define U8G_CLASS U8GLIB_64128N_2X_HAL
|
||||
#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0 // using SW-SPI
|
||||
#endif
|
||||
|
||||
#elif ENABLED(MKS_12864OLED_SSD1306)
|
||||
// MKS 128x64 (SSD1306) OLED I2C LCD
|
||||
#define U8G_CLASS U8GLIB_SSD1306_128X64
|
||||
#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0 // 8 stripes
|
||||
//#define U8G_CLASS U8GLIB_SSD1306_128X64_2X
|
||||
//#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0 // 4 stripes
|
||||
|
||||
#elif ENABLED(U8GLIB_SSD1306)
|
||||
// Generic support for SSD1306 OLED I2C LCDs
|
||||
//#define U8G_CLASS U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE
|
||||
//#define U8G_PARAM (U8G_I2C_OPT_NONE | U8G_I2C_OPT_FAST) // 4 stripes
|
||||
#define U8G_CLASS U8GLIB_SSD1306_128X64_2X
|
||||
#define U8G_PARAM (U8G_I2C_OPT_NONE | U8G_I2C_OPT_FAST) // 4 stripes
|
||||
|
||||
#elif ENABLED(MKS_12864OLED)
|
||||
// MKS 128x64 (SH1106) OLED I2C LCD
|
||||
#define U8G_CLASS U8GLIB_SH1106_128X64
|
||||
#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0 // 8 stripes
|
||||
//#define U8G_CLASS U8GLIB_SH1106_128X64_2X
|
||||
//#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0 // 4 stripes
|
||||
#elif ENABLED(U8GLIB_SH1106)
|
||||
// Generic support for SH1106 OLED I2C LCDs
|
||||
//#define U8G_CLASS U8GLIB_SH1106_128X64_2X_I2C_2_WIRE
|
||||
//#define U8G_PARAM (U8G_I2C_OPT_NONE | U8G_I2C_OPT_FAST) // 4 stripes
|
||||
#define U8G_CLASS U8GLIB_SH1106_128X64_2X
|
||||
#define U8G_PARAM (U8G_I2C_OPT_NONE | U8G_I2C_OPT_FAST) // 4 stripes
|
||||
#elif ENABLED(U8GLIB_SSD1309)
|
||||
// Generic support for SSD1309 OLED I2C LCDs
|
||||
#define U8G_CLASS U8GLIB_SSD1309_128X64
|
||||
#define U8G_PARAM (U8G_I2C_OPT_NONE | U8G_I2C_OPT_FAST)
|
||||
#elif ENABLED(MINIPANEL)
|
||||
// The MINIPanel display
|
||||
//#define U8G_CLASS U8GLIB_MINI12864
|
||||
//#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // 8 stripes
|
||||
#define U8G_CLASS U8GLIB_MINI12864_2X
|
||||
#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // 4 stripes
|
||||
#elif ENABLED(U8GLIB_SH1106_EINSTART)
|
||||
// Connected via motherboard header
|
||||
#define U8G_CLASS U8GLIB_SH1106_128X64
|
||||
#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, LCD_PINS_DC, LCD_PINS_RS
|
||||
#else
|
||||
// for regular DOGM128 display with HW-SPI
|
||||
//#define U8G_CLASS U8GLIB_DOGM128
|
||||
//#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // HW-SPI Com: CS, A0 // 8 stripes
|
||||
#define U8G_CLASS U8GLIB_DOGM128_2X
|
||||
#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // HW-SPI Com: CS, A0 // 4 stripes
|
||||
#endif
|
||||
|
||||
#include <U8glib.h>
|
||||
#include "dogm/HAL_LCD_class_defines.h"
|
||||
extern U8G_CLASS u8g;
|
||||
|
||||
// For selective rendering within a Y range
|
||||
#define PAGE_UNDER(yb) (u8g.getU8g()->current_page.y0 <= (yb))
|
||||
#define PAGE_CONTAINS(ya, yb) (PAGE_UNDER(yb) && u8g.getU8g()->current_page.y1 >= (ya))
|
||||
|
||||
// Only Western languages support big / small fonts
|
||||
#if DISABLED(DISPLAY_CHARSET_ISO10646_1)
|
||||
#undef USE_BIG_EDIT_FONT
|
||||
#undef USE_SMALL_INFOFONT
|
||||
#endif
|
||||
|
||||
#define MENU_FONT_NAME ISO10646_1_5x7
|
||||
#define MENU_FONT_WIDTH 6
|
||||
#define MENU_FONT_ASCENT 10
|
||||
#define MENU_FONT_DESCENT 2
|
||||
#define MENU_FONT_HEIGHT (MENU_FONT_ASCENT + MENU_FONT_DESCENT)
|
||||
|
||||
#if ENABLED(USE_BIG_EDIT_FONT)
|
||||
#define EDIT_FONT_NAME u8g_font_9x18
|
||||
#define EDIT_FONT_WIDTH 9
|
||||
#define EDIT_FONT_ASCENT 10
|
||||
#define EDIT_FONT_DESCENT 3
|
||||
#else
|
||||
#define EDIT_FONT_NAME MENU_FONT_NAME
|
||||
#define EDIT_FONT_WIDTH MENU_FONT_WIDTH
|
||||
#define EDIT_FONT_ASCENT MENU_FONT_ASCENT
|
||||
#define EDIT_FONT_DESCENT MENU_FONT_DESCENT
|
||||
#endif
|
||||
#define EDIT_FONT_HEIGHT (EDIT_FONT_ASCENT + EDIT_FONT_DESCENT)
|
||||
|
||||
// Get the Ascent, Descent, and total Height for the Info Screen font
|
||||
#if ENABLED(USE_SMALL_INFOFONT)
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x9[];
|
||||
#define INFO_FONT_ASCENT 7
|
||||
#else
|
||||
#define INFO_FONT_ASCENT 8
|
||||
#endif
|
||||
#define INFO_FONT_DESCENT 2
|
||||
#define INFO_FONT_HEIGHT (INFO_FONT_ASCENT + INFO_FONT_DESCENT)
|
||||
|
||||
enum MarlinFont : uint8_t {
|
||||
FONT_STATUSMENU = 1,
|
||||
FONT_EDIT,
|
||||
FONT_MENU
|
||||
};
|
||||
|
||||
#if ENABLED(LIGHTWEIGHT_UI)
|
||||
void lcd_in_status(const bool inStatus);
|
||||
#endif
|
||||
|
||||
#endif // HAS_GRAPHICAL_LCD
|
||||
|
||||
#define HAS_ENCODER_ACTION (HAS_LCD_MENU || ENABLED(ULTIPANEL_FEEDMULTIPLY))
|
||||
|
||||
#if HAS_SPI_LCD
|
||||
@ -364,6 +204,14 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
enum MarlinFont : uint8_t {
|
||||
FONT_STATUSMENU = 1,
|
||||
FONT_EDIT,
|
||||
FONT_MENU
|
||||
};
|
||||
#endif
|
||||
|
||||
#define LCD_MESSAGEPGM(x) ui.setstatusPGM(PSTR(x))
|
||||
#define LCD_ALERTMESSAGEPGM(x) ui.setalertstatusPGM(PSTR(x))
|
||||
|
||||
@ -397,12 +245,10 @@ public:
|
||||
#if HAS_SPI_LCD || ENABLED(MALYAN_LCD) || ENABLED(EXTENSIBLE_UI)
|
||||
static void init();
|
||||
static void update();
|
||||
static bool detected();
|
||||
static void setalertstatusPGM(PGM_P message);
|
||||
#else // NO LCD
|
||||
static inline void init() {}
|
||||
static inline void update() {}
|
||||
static constexpr bool detected() { return true; }
|
||||
static inline void setalertstatusPGM(PGM_P message) { UNUSED(message); }
|
||||
#endif
|
||||
|
||||
@ -410,6 +256,8 @@ public:
|
||||
|
||||
#if HAS_SPI_LCD
|
||||
|
||||
static bool detected();
|
||||
|
||||
static LCDViewAction lcdDrawUpdate;
|
||||
static inline bool should_draw() { return bool(lcdDrawUpdate); }
|
||||
static inline void refresh(const LCDViewAction type) { lcdDrawUpdate = type; }
|
||||
@ -455,6 +303,7 @@ public:
|
||||
#if ENABLED(STATUS_MESSAGE_SCROLLING)
|
||||
static uint8_t status_scroll_offset;
|
||||
#endif
|
||||
static bool hasstatus();
|
||||
|
||||
static uint8_t lcd_status_update_delay;
|
||||
static uint8_t status_message_level; // Higher levels block lower levels
|
||||
@ -495,15 +344,15 @@ public:
|
||||
|
||||
#else
|
||||
|
||||
static void refresh();
|
||||
static void reset_alert_level();
|
||||
static void refresh() {}
|
||||
static inline void reset_alert_level() {}
|
||||
static constexpr bool hasstatus() { return true; }
|
||||
|
||||
#endif
|
||||
|
||||
static bool get_blink();
|
||||
static void kill_screen(PGM_P const lcd_msg);
|
||||
static void draw_kill_screen();
|
||||
static bool hasstatus();
|
||||
static void setstatus(const char* const message, const bool persist=false);
|
||||
static void setstatusPGM(PGM_P const message, const int8_t level=0);
|
||||
static void status_printf_P(const uint8_t level, PGM_P const fmt, ...);
|
||||
@ -512,12 +361,12 @@ public:
|
||||
#else // MALYAN_LCD or NO LCD
|
||||
|
||||
static inline void refresh() {}
|
||||
static constexpr bool hasstatus() { return false; }
|
||||
static inline void setstatus(const char* const message, const bool persist=false) { UNUSED(message); UNUSED(persist); }
|
||||
static inline void setstatusPGM(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); }
|
||||
static inline void reset_status() {}
|
||||
static inline void reset_alert_level() {}
|
||||
static constexpr bool hasstatus() { return false; }
|
||||
|
||||
#endif
|
||||
|
||||
@ -563,6 +412,10 @@ public:
|
||||
static inline bool on_status_screen() { return currentScreen == status_screen; }
|
||||
static inline void run_current_screen() { (*currentScreen)(); }
|
||||
|
||||
#if ENABLED(LIGHTWEIGHT_UI)
|
||||
static void lcd_in_status(const bool inStatus);
|
||||
#endif
|
||||
|
||||
static inline void defer_status_screen(const bool defer) {
|
||||
#if LCD_TIMEOUT_TO_STATUS
|
||||
defer_return_to_status = defer;
|
||||
@ -636,13 +489,13 @@ public:
|
||||
static inline void encoder_direction_menus() { encoderDirection = -(ENCODERBASE); }
|
||||
#else
|
||||
static constexpr int8_t encoderDirection = ENCODERBASE;
|
||||
static inline void encoder_direction_normal() { }
|
||||
static inline void encoder_direction_menus() { }
|
||||
static inline void encoder_direction_normal() {}
|
||||
static inline void encoder_direction_menus() {}
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
static inline void update_buttons() { }
|
||||
static inline void update_buttons() {}
|
||||
|
||||
#endif
|
||||
|
||||
@ -660,6 +513,8 @@ private:
|
||||
#endif
|
||||
static void draw_status_screen();
|
||||
static void finishstatus(const bool persist);
|
||||
#else
|
||||
static inline void finishstatus(const bool persist) { UNUSED(persist); refresh(); }
|
||||
#endif
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user