mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-26 21:36:21 +00:00
🚸 Expose sub-options for E3V2 Enhanced (#23099)
This commit is contained in:
parent
99df0b86fb
commit
b4b16b63ff
@ -1280,7 +1280,7 @@
|
||||
|
||||
#endif // HAS_LCD_MENU
|
||||
|
||||
#if HAS_DISPLAY
|
||||
#if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED)
|
||||
// The timeout (in ms) to return to the status screen from sub-menus
|
||||
//#define LCD_TIMEOUT_TO_STATUS 15000
|
||||
|
||||
|
@ -1559,7 +1559,6 @@ void setup() {
|
||||
HMI_Init();
|
||||
HMI_SetLanguageCache();
|
||||
HMI_StartFrame(true);
|
||||
DWIN_StatusChanged(GET_TEXT_F(WELCOME_MSG));
|
||||
#endif
|
||||
|
||||
#if HAS_SERVICE_INTERVALS && !HAS_DWIN_E3V2_BASIC
|
||||
|
@ -170,6 +170,7 @@ select_t select_page{0}, select_file{0}, select_print{0};
|
||||
uint8_t index_file = MROWS;
|
||||
|
||||
bool dwin_abort_flag = false; // Flag to reset feedrate, return to Home
|
||||
bool hash_changed = true; // Flag to know if message status was changed
|
||||
|
||||
constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE;
|
||||
constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION;
|
||||
@ -610,6 +611,86 @@ void Popup_window_PauseOrStop() {
|
||||
|
||||
#endif
|
||||
|
||||
// Draw status line
|
||||
void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char *text, const bool center = true) {
|
||||
DWIN_Draw_Rectangle(1, bgcolor, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20);
|
||||
if (text) {
|
||||
if (center) DWINUI::Draw_CenteredString(color, STATUS_Y + 2, text);
|
||||
else DWINUI::Draw_String(color, 0, STATUS_Y + 2, text);
|
||||
}
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
void DWIN_DrawStatusLine(const char *text, const bool center = true) {
|
||||
DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, text, center);
|
||||
}
|
||||
|
||||
// Clear & reset status line
|
||||
void DWIN_ResetStatusLine() {
|
||||
ui.status_message[0] = 0;
|
||||
DWIN_CheckStatusMessage();
|
||||
}
|
||||
|
||||
// Djb2 hash algorithm
|
||||
void DWIN_CheckStatusMessage() {
|
||||
static uint32_t old_hash = 0;
|
||||
char * str = &ui.status_message[0];
|
||||
uint32_t hash = 5381;
|
||||
char c;
|
||||
while ((c = *str++)) hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
|
||||
hash_changed = hash != old_hash;
|
||||
old_hash = hash;
|
||||
};
|
||||
|
||||
void DWIN_DrawStatusMessage() {
|
||||
const uint8_t max_status_chars = DWIN_WIDTH / DWINUI::fontWidth(DWINUI::font);
|
||||
|
||||
#if ENABLED(STATUS_MESSAGE_SCROLLING)
|
||||
|
||||
// Get the UTF8 character count of the string
|
||||
uint8_t slen = utf8_strlen(ui.status_message);
|
||||
|
||||
// If the string fits the status line do not scroll it
|
||||
if (slen <= max_status_chars) {
|
||||
if (hash_changed) {
|
||||
DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, ui.status_message);
|
||||
hash_changed = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// String is larger than the available line space
|
||||
|
||||
// Get a pointer to the next valid UTF8 character
|
||||
// and the string remaining length
|
||||
uint8_t rlen;
|
||||
const char *stat = MarlinUI::status_and_len(rlen);
|
||||
DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20);
|
||||
DWINUI::MoveTo(0, STATUS_Y + 2);
|
||||
DWINUI::Draw_String(stat, max_status_chars);
|
||||
|
||||
// If the string doesn't completely fill the line...
|
||||
if (rlen < max_status_chars) {
|
||||
DWINUI::Draw_Char('.'); // Always at 1+ spaces left, draw a dot
|
||||
uint8_t chars = max_status_chars - rlen; // Amount of space left in characters
|
||||
if (--chars) { // Draw a second dot if there's space
|
||||
DWINUI::Draw_Char('.');
|
||||
if (--chars)
|
||||
DWINUI::Draw_String(ui.status_message, chars); // Print a second copy of the message
|
||||
}
|
||||
}
|
||||
MarlinUI::advance_status_scroll();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
if (hash_changed) {
|
||||
ui.status_message[max_status_chars] = 0;
|
||||
DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, ui.status_message);
|
||||
hash_changed = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void Draw_Print_Labels() {
|
||||
if (HMI_IsChinese()) {
|
||||
Title.FrameCopy(30, 1, 42, 14); // "Printing"
|
||||
@ -713,7 +794,7 @@ void Draw_Main_Menu() {
|
||||
|
||||
void Goto_Main_Menu() {
|
||||
checkkey = MainMenu;
|
||||
DWIN_StatusChanged();
|
||||
ui.reset_status(true);
|
||||
Draw_Main_Menu();
|
||||
}
|
||||
|
||||
@ -1077,6 +1158,7 @@ void Draw_Status_Area(const bool with_update) {
|
||||
|
||||
void HMI_StartFrame(const bool with_update) {
|
||||
Goto_Main_Menu();
|
||||
DWIN_DrawStatusLine(nullptr);
|
||||
Draw_Status_Area(with_update);
|
||||
}
|
||||
|
||||
@ -1474,7 +1556,7 @@ void DWIN_Update() {
|
||||
}
|
||||
|
||||
void EachMomentUpdate() {
|
||||
static millis_t next_var_update_ms = 0, next_rts_update_ms = 0;
|
||||
static millis_t next_var_update_ms = 0, next_rts_update_ms = 0, next_status_update_ms = 0;
|
||||
|
||||
const millis_t ms = millis();
|
||||
if (ELAPSED(ms, next_var_update_ms)) {
|
||||
@ -1482,6 +1564,11 @@ void EachMomentUpdate() {
|
||||
update_variable();
|
||||
}
|
||||
|
||||
if (ELAPSED(ms, next_status_update_ms)) {
|
||||
next_status_update_ms = ms + 500;
|
||||
DWIN_DrawStatusMessage();
|
||||
}
|
||||
|
||||
if (PENDING(ms, next_rts_update_ms)) return;
|
||||
next_rts_update_ms = ms + DWIN_SCROLL_UPDATE_INTERVAL;
|
||||
|
||||
@ -1745,7 +1832,7 @@ void Draw_Title(TitleClass* title) {
|
||||
void Draw_Menu(MenuClass* menu) {
|
||||
DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color);
|
||||
DWIN_Draw_Rectangle(1, DWINUI::backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1);
|
||||
ui.set_status("");
|
||||
DWIN_ResetStatusLine();
|
||||
}
|
||||
|
||||
// Startup routines
|
||||
@ -1758,23 +1845,6 @@ void DWIN_Startup() {
|
||||
HMI_SetLanguage();
|
||||
}
|
||||
|
||||
void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char * const text/*=nullptr*/) {
|
||||
DWIN_Draw_Rectangle(1, bgcolor, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20);
|
||||
if (text) DWINUI::Draw_CenteredString(color, STATUS_Y + 2, text);
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
|
||||
// Update Status line
|
||||
void DWIN_StatusChanged(const char * const cstr/*=nullptr*/) {
|
||||
DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, cstr);
|
||||
}
|
||||
|
||||
void DWIN_StatusChanged(FSTR_P const fstr) {
|
||||
char str[strlen_P(FTOP(fstr)) + 1];
|
||||
strcpy_P(str, FTOP(fstr));
|
||||
DWIN_StatusChanged(str);
|
||||
}
|
||||
|
||||
// Started a Print Job
|
||||
void DWIN_Print_Started(const bool sd) {
|
||||
sdprint = card.isPrinting() || sd;
|
||||
@ -1866,7 +1936,6 @@ void DWIN_RebootScreen() {
|
||||
|
||||
void DWIN_Redraw_screen() {
|
||||
Draw_Main_Area();
|
||||
DWIN_StatusChanged(ui.status_message);
|
||||
Draw_Status_Area(false);
|
||||
}
|
||||
|
||||
|
@ -174,9 +174,7 @@ void EachMomentUpdate();
|
||||
void update_variable();
|
||||
void DWIN_HandleScreen();
|
||||
void DWIN_Update();
|
||||
void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char *text=nullptr);
|
||||
void DWIN_StatusChanged(const char * const cstr=nullptr);
|
||||
void DWIN_StatusChanged(FSTR_P const fstr);
|
||||
void DWIN_CheckStatusMessage();
|
||||
void DWIN_StartHoming();
|
||||
void DWIN_CompletedHoming();
|
||||
#if HAS_MESH
|
||||
|
@ -49,6 +49,7 @@ MarlinUI ui;
|
||||
#if ENABLED(DWIN_CREALITY_LCD)
|
||||
#include "e3v2/creality/dwin.h"
|
||||
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
|
||||
#include "fontutils.h"
|
||||
#include "e3v2/enhanced/dwin.h"
|
||||
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
|
||||
#include "e3v2/jyersui/dwin.h"
|
||||
@ -69,7 +70,7 @@ MarlinUI ui;
|
||||
constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
|
||||
|
||||
#if HAS_STATUS_MESSAGE
|
||||
#if BOTH(HAS_WIRED_LCD, STATUS_MESSAGE_SCROLLING)
|
||||
#if ENABLED(STATUS_MESSAGE_SCROLLING) && EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_ENHANCED)
|
||||
uint8_t MarlinUI::status_scroll_offset; // = 0
|
||||
#endif
|
||||
char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1];
|
||||
@ -1481,11 +1482,9 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
|
||||
|
||||
void MarlinUI::finish_status(const bool persist) {
|
||||
|
||||
#if HAS_WIRED_LCD
|
||||
UNUSED(persist);
|
||||
|
||||
#if !(BASIC_PROGRESS_BAR && (PROGRESS_MSG_EXPIRE) > 0)
|
||||
UNUSED(persist);
|
||||
#endif
|
||||
#if HAS_WIRED_LCD
|
||||
|
||||
#if BASIC_PROGRESS_BAR || BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
|
||||
const millis_t ms = millis();
|
||||
@ -1502,13 +1501,15 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
|
||||
next_filament_display = ms + 5000UL; // Show status message for 5s
|
||||
#endif
|
||||
|
||||
TERN_(STATUS_MESSAGE_SCROLLING, status_scroll_offset = 0);
|
||||
#else // HAS_WIRED_LCD
|
||||
UNUSED(persist);
|
||||
#endif
|
||||
|
||||
#if ENABLED(STATUS_MESSAGE_SCROLLING) && EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_ENHANCED)
|
||||
status_scroll_offset = 0;
|
||||
#endif
|
||||
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(status_message));
|
||||
TERN_(HAS_DWIN_E3V2_BASIC, DWIN_StatusChanged(status_message));
|
||||
TERN_(DWIN_CREALITY_LCD, DWIN_StatusChanged(status_message));
|
||||
TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_CheckStatusMessage());
|
||||
TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWIN.Update_Status(status_message));
|
||||
}
|
||||
|
||||
|
@ -356,6 +356,9 @@ public:
|
||||
|
||||
#if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED)
|
||||
static void kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component);
|
||||
#if DISABLED(LIGHTWEIGHT_UI)
|
||||
static void draw_status_message(const bool blink);
|
||||
#endif
|
||||
#else
|
||||
static inline void kill_screen(FSTR_P const, FSTR_P const) {}
|
||||
#endif
|
||||
@ -444,10 +447,6 @@ public:
|
||||
static inline void completion_feedback(const bool=true) { TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); }
|
||||
#endif
|
||||
|
||||
#if DISABLED(LIGHTWEIGHT_UI)
|
||||
static void draw_status_message(const bool blink);
|
||||
#endif
|
||||
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
static void draw_hotend_status(const uint8_t row, const uint8_t extruder);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user