|
@@ -170,6 +170,7 @@ select_t select_page{0}, select_file{0}, select_print{0};
|
170
|
170
|
uint8_t index_file = MROWS;
|
171
|
171
|
|
172
|
172
|
bool dwin_abort_flag = false; // Flag to reset feedrate, return to Home
|
|
173
|
+bool hash_changed = true; // Flag to know if message status was changed
|
173
|
174
|
|
174
|
175
|
constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE;
|
175
|
176
|
constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION;
|
|
@@ -610,6 +611,86 @@ void Popup_window_PauseOrStop() {
|
610
|
611
|
|
611
|
612
|
#endif
|
612
|
613
|
|
|
614
|
+// Draw status line
|
|
615
|
+void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char *text, const bool center = true) {
|
|
616
|
+ DWIN_Draw_Rectangle(1, bgcolor, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20);
|
|
617
|
+ if (text) {
|
|
618
|
+ if (center) DWINUI::Draw_CenteredString(color, STATUS_Y + 2, text);
|
|
619
|
+ else DWINUI::Draw_String(color, 0, STATUS_Y + 2, text);
|
|
620
|
+ }
|
|
621
|
+ DWIN_UpdateLCD();
|
|
622
|
+}
|
|
623
|
+void DWIN_DrawStatusLine(const char *text, const bool center = true) {
|
|
624
|
+ DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, text, center);
|
|
625
|
+}
|
|
626
|
+
|
|
627
|
+// Clear & reset status line
|
|
628
|
+void DWIN_ResetStatusLine() {
|
|
629
|
+ ui.status_message[0] = 0;
|
|
630
|
+ DWIN_CheckStatusMessage();
|
|
631
|
+}
|
|
632
|
+
|
|
633
|
+// Djb2 hash algorithm
|
|
634
|
+void DWIN_CheckStatusMessage() {
|
|
635
|
+ static uint32_t old_hash = 0;
|
|
636
|
+ char * str = &ui.status_message[0];
|
|
637
|
+ uint32_t hash = 5381;
|
|
638
|
+ char c;
|
|
639
|
+ while ((c = *str++)) hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
|
|
640
|
+ hash_changed = hash != old_hash;
|
|
641
|
+ old_hash = hash;
|
|
642
|
+};
|
|
643
|
+
|
|
644
|
+void DWIN_DrawStatusMessage() {
|
|
645
|
+ const uint8_t max_status_chars = DWIN_WIDTH / DWINUI::fontWidth(DWINUI::font);
|
|
646
|
+
|
|
647
|
+ #if ENABLED(STATUS_MESSAGE_SCROLLING)
|
|
648
|
+
|
|
649
|
+ // Get the UTF8 character count of the string
|
|
650
|
+ uint8_t slen = utf8_strlen(ui.status_message);
|
|
651
|
+
|
|
652
|
+ // If the string fits the status line do not scroll it
|
|
653
|
+ if (slen <= max_status_chars) {
|
|
654
|
+ if (hash_changed) {
|
|
655
|
+ DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, ui.status_message);
|
|
656
|
+ hash_changed = false;
|
|
657
|
+ }
|
|
658
|
+ }
|
|
659
|
+ else {
|
|
660
|
+ // String is larger than the available line space
|
|
661
|
+
|
|
662
|
+ // Get a pointer to the next valid UTF8 character
|
|
663
|
+ // and the string remaining length
|
|
664
|
+ uint8_t rlen;
|
|
665
|
+ const char *stat = MarlinUI::status_and_len(rlen);
|
|
666
|
+ DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20);
|
|
667
|
+ DWINUI::MoveTo(0, STATUS_Y + 2);
|
|
668
|
+ DWINUI::Draw_String(stat, max_status_chars);
|
|
669
|
+
|
|
670
|
+ // If the string doesn't completely fill the line...
|
|
671
|
+ if (rlen < max_status_chars) {
|
|
672
|
+ DWINUI::Draw_Char('.'); // Always at 1+ spaces left, draw a dot
|
|
673
|
+ uint8_t chars = max_status_chars - rlen; // Amount of space left in characters
|
|
674
|
+ if (--chars) { // Draw a second dot if there's space
|
|
675
|
+ DWINUI::Draw_Char('.');
|
|
676
|
+ if (--chars)
|
|
677
|
+ DWINUI::Draw_String(ui.status_message, chars); // Print a second copy of the message
|
|
678
|
+ }
|
|
679
|
+ }
|
|
680
|
+ MarlinUI::advance_status_scroll();
|
|
681
|
+ }
|
|
682
|
+
|
|
683
|
+ #else
|
|
684
|
+
|
|
685
|
+ if (hash_changed) {
|
|
686
|
+ ui.status_message[max_status_chars] = 0;
|
|
687
|
+ DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, ui.status_message);
|
|
688
|
+ hash_changed = false;
|
|
689
|
+ }
|
|
690
|
+
|
|
691
|
+ #endif
|
|
692
|
+}
|
|
693
|
+
|
613
|
694
|
void Draw_Print_Labels() {
|
614
|
695
|
if (HMI_IsChinese()) {
|
615
|
696
|
Title.FrameCopy(30, 1, 42, 14); // "Printing"
|
|
@@ -713,7 +794,7 @@ void Draw_Main_Menu() {
|
713
|
794
|
|
714
|
795
|
void Goto_Main_Menu() {
|
715
|
796
|
checkkey = MainMenu;
|
716
|
|
- DWIN_StatusChanged();
|
|
797
|
+ ui.reset_status(true);
|
717
|
798
|
Draw_Main_Menu();
|
718
|
799
|
}
|
719
|
800
|
|
|
@@ -1077,6 +1158,7 @@ void Draw_Status_Area(const bool with_update) {
|
1077
|
1158
|
|
1078
|
1159
|
void HMI_StartFrame(const bool with_update) {
|
1079
|
1160
|
Goto_Main_Menu();
|
|
1161
|
+ DWIN_DrawStatusLine(nullptr);
|
1080
|
1162
|
Draw_Status_Area(with_update);
|
1081
|
1163
|
}
|
1082
|
1164
|
|
|
@@ -1474,7 +1556,7 @@ void DWIN_Update() {
|
1474
|
1556
|
}
|
1475
|
1557
|
|
1476
|
1558
|
void EachMomentUpdate() {
|
1477
|
|
- static millis_t next_var_update_ms = 0, next_rts_update_ms = 0;
|
|
1559
|
+ static millis_t next_var_update_ms = 0, next_rts_update_ms = 0, next_status_update_ms = 0;
|
1478
|
1560
|
|
1479
|
1561
|
const millis_t ms = millis();
|
1480
|
1562
|
if (ELAPSED(ms, next_var_update_ms)) {
|
|
@@ -1482,6 +1564,11 @@ void EachMomentUpdate() {
|
1482
|
1564
|
update_variable();
|
1483
|
1565
|
}
|
1484
|
1566
|
|
|
1567
|
+ if (ELAPSED(ms, next_status_update_ms)) {
|
|
1568
|
+ next_status_update_ms = ms + 500;
|
|
1569
|
+ DWIN_DrawStatusMessage();
|
|
1570
|
+ }
|
|
1571
|
+
|
1485
|
1572
|
if (PENDING(ms, next_rts_update_ms)) return;
|
1486
|
1573
|
next_rts_update_ms = ms + DWIN_SCROLL_UPDATE_INTERVAL;
|
1487
|
1574
|
|
|
@@ -1745,7 +1832,7 @@ void Draw_Title(TitleClass* title) {
|
1745
|
1832
|
void Draw_Menu(MenuClass* menu) {
|
1746
|
1833
|
DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color);
|
1747
|
1834
|
DWIN_Draw_Rectangle(1, DWINUI::backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1);
|
1748
|
|
- ui.set_status("");
|
|
1835
|
+ DWIN_ResetStatusLine();
|
1749
|
1836
|
}
|
1750
|
1837
|
|
1751
|
1838
|
// Startup routines
|
|
@@ -1758,23 +1845,6 @@ void DWIN_Startup() {
|
1758
|
1845
|
HMI_SetLanguage();
|
1759
|
1846
|
}
|
1760
|
1847
|
|
1761
|
|
-void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char * const text/*=nullptr*/) {
|
1762
|
|
- DWIN_Draw_Rectangle(1, bgcolor, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20);
|
1763
|
|
- if (text) DWINUI::Draw_CenteredString(color, STATUS_Y + 2, text);
|
1764
|
|
- DWIN_UpdateLCD();
|
1765
|
|
-}
|
1766
|
|
-
|
1767
|
|
-// Update Status line
|
1768
|
|
-void DWIN_StatusChanged(const char * const cstr/*=nullptr*/) {
|
1769
|
|
- DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, cstr);
|
1770
|
|
-}
|
1771
|
|
-
|
1772
|
|
-void DWIN_StatusChanged(FSTR_P const fstr) {
|
1773
|
|
- char str[strlen_P(FTOP(fstr)) + 1];
|
1774
|
|
- strcpy_P(str, FTOP(fstr));
|
1775
|
|
- DWIN_StatusChanged(str);
|
1776
|
|
-}
|
1777
|
|
-
|
1778
|
1848
|
// Started a Print Job
|
1779
|
1849
|
void DWIN_Print_Started(const bool sd) {
|
1780
|
1850
|
sdprint = card.isPrinting() || sd;
|
|
@@ -1866,7 +1936,6 @@ void DWIN_RebootScreen() {
|
1866
|
1936
|
|
1867
|
1937
|
void DWIN_Redraw_screen() {
|
1868
|
1938
|
Draw_Main_Area();
|
1869
|
|
- DWIN_StatusChanged(ui.status_message);
|
1870
|
1939
|
Draw_Status_Area(false);
|
1871
|
1940
|
}
|
1872
|
1941
|
|