Selaa lähdekoodia

🐛 Fix JyersUI scrolling filename, etc. (#23082)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
dwzg 3 vuotta sitten
vanhempi
commit
30a69f76a3
No account linked to committer's email address
1 muutettua tiedostoa jossa 26 lisäystä ja 24 poistoa
  1. 26
    24
      Marlin/src/lcd/e3v2/jyersui/dwin.cpp

+ 26
- 24
Marlin/src/lcd/e3v2/jyersui/dwin.cpp Näytä tiedosto

@@ -678,31 +678,31 @@ void CrealityDWINClass::Draw_Print_Filename(const bool reset/*=false*/) {
678 678
   static uint8_t namescrl = 0;
679 679
   if (reset) namescrl = 0;
680 680
   if (process == Print) {
681
-    size_t len = strlen(filename);
682
-    int8_t pos = len;
683
-    if (pos > 30) {
684
-      pos -= namescrl;
685
-      len = _MIN(pos, 30);
686
-      char dispname[len + 1];
681
+    constexpr int8_t maxlen = 30;
682
+    char *outstr = filename;
683
+    size_t slen = strlen(filename);
684
+    int8_t outlen = slen;
685
+    if (slen > maxlen) {
686
+      char dispname[maxlen + 1];
687
+      int8_t pos = slen - namescrl, len = maxlen;
687 688
       if (pos >= 0) {
689
+        NOMORE(len, pos);
688 690
         LOOP_L_N(i, len) dispname[i] = filename[i + namescrl];
689 691
       }
690 692
       else {
691
-        LOOP_L_N(i, 30 + pos) dispname[i] = ' ';
692
-        LOOP_S_L_N(i, 30 + pos, 30) dispname[i] = filename[i - (30 + pos)];
693
+        const int8_t mp = maxlen + pos;
694
+        LOOP_L_N(i, mp) dispname[i] = ' ';
695
+        LOOP_S_L_N(i, mp, maxlen) dispname[i] = filename[i - mp];
696
+        if (mp <= 0) namescrl = 0;
693 697
       }
694 698
       dispname[len] = '\0';
695
-      DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80);
696
-      const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2;
697
-      DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, dispname);
698
-      if (-pos >= 30) namescrl = 0;
699
+      outstr = dispname;
700
+      outlen = maxlen;
699 701
       namescrl++;
700 702
     }
701
-    else {
702
-      DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80);
703
-      const int8_t npos = (DWIN_WIDTH - strlen(filename) * MENU_CHR_W) / 2;
704
-      DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, filename);
705
-    }
703
+    DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80);
704
+    const int8_t npos = (DWIN_WIDTH - outlen * MENU_CHR_W) / 2;
705
+    DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, outstr);
706 706
   }
707 707
 }
708 708
 
@@ -4702,7 +4702,7 @@ void CrealityDWINClass::Update_Status(const char * const text) {
4702 4702
   char header[4];
4703 4703
   LOOP_L_N(i, 3) header[i] = text[i];
4704 4704
   header[3] = '\0';
4705
-  if (strcmp_P(header,"<F>") == 0) {
4705
+  if (strcmp_P(header, PSTR("<F>")) == 0) {
4706 4706
     LOOP_L_N(i, _MIN((size_t)LONG_FILENAME_LENGTH, strlen(text))) filename[i] = text[i + 3];
4707 4707
     filename[_MIN((size_t)LONG_FILENAME_LENGTH - 1, strlen(text))] = '\0';
4708 4708
     Draw_Print_Filename(true);
@@ -4798,22 +4798,23 @@ void CrealityDWINClass::State_Update() {
4798 4798
 }
4799 4799
 
4800 4800
 void CrealityDWINClass::Screen_Update() {
4801
+  const millis_t ms = millis();
4801 4802
   static millis_t scrltime = 0;
4802
-  if (ELAPSED(millis(), scrltime)) {
4803
-    scrltime = millis() + 200;
4803
+  if (ELAPSED(ms, scrltime)) {
4804
+    scrltime = ms + 200;
4804 4805
     Update_Status_Bar();
4805 4806
     if (process == Print) Draw_Print_Filename();
4806 4807
   }
4807 4808
 
4808 4809
   static millis_t statustime = 0;
4809
-  if (ELAPSED(millis(), statustime)) {
4810
-    statustime = millis() + 500;
4810
+  if (ELAPSED(ms, statustime)) {
4811
+    statustime = ms + 500;
4811 4812
     Draw_Status_Area();
4812 4813
   }
4813 4814
 
4814 4815
   static millis_t printtime = 0;
4815
-  if (ELAPSED(millis(), printtime)) {
4816
-    printtime = millis() + 1000;
4816
+  if (ELAPSED(ms, printtime)) {
4817
+    printtime = ms + 1000;
4817 4818
     if (process == Print) {
4818 4819
       Draw_Print_ProgressBar();
4819 4820
       Draw_Print_ProgressElapsed();
@@ -5000,6 +5001,7 @@ void MarlinUI::init() {
5000 5001
   void MarlinUI::pause_show_message(const PauseMessage message, const PauseMode mode/*=PAUSE_MODE_SAME*/, const uint8_t extruder/*=active_extruder*/) {
5001 5002
     switch (message) {
5002 5003
       case PAUSE_MESSAGE_INSERT:  CrealityDWIN.Confirm_Handler(FilInsert);  break;
5004
+      case PAUSE_MESSAGE_PURGE:
5003 5005
       case PAUSE_MESSAGE_OPTION:  CrealityDWIN.Popup_Handler(PurgeMore);    break;
5004 5006
       case PAUSE_MESSAGE_HEAT:    CrealityDWIN.Confirm_Handler(HeaterTime); break;
5005 5007
       case PAUSE_MESSAGE_WAITING: CrealityDWIN.Draw_Print_Screen();         break;

Loading…
Peruuta
Tallenna