Procházet zdrojové kódy

🎨 Misc. DGUS cleanup

Scott Lahteine před 3 roky
rodič
revize
3d2b2ca790

+ 17
- 11
Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp Zobrazit soubor

@@ -46,6 +46,12 @@
46 46
 
47 47
 DGUSDisplay dgusdisplay;
48 48
 
49
+#ifdef DEBUG_DGUSLCD_COMM
50
+  #define DEBUGLCDCOMM_ECHOPGM DEBUG_ECHOPGM
51
+#else
52
+  #define DEBUGLCDCOMM_ECHOPGM(...) NOOP
53
+#endif
54
+
49 55
 // Preamble... 2 Bytes, usually 0x5A 0xA5, but configurable
50 56
 constexpr uint8_t DGUS_HEADER1 = 0x5A;
51 57
 constexpr uint8_t DGUS_HEADER2 = 0xA5;
@@ -154,19 +160,19 @@ void DGUSDisplay::ProcessRx() {
154 160
 
155 161
       case DGUS_IDLE: // Waiting for the first header byte
156 162
         receivedbyte = LCD_SERIAL.read();
157
-        //DEBUG_ECHOPGM("< ",x);
163
+        //DEBUGLCDCOMM_ECHOPGM("< ", receivedbyte);
158 164
         if (DGUS_HEADER1 == receivedbyte) rx_datagram_state = DGUS_HEADER1_SEEN;
159 165
         break;
160 166
 
161 167
       case DGUS_HEADER1_SEEN: // Waiting for the second header byte
162 168
         receivedbyte = LCD_SERIAL.read();
163
-        //DEBUG_ECHOPGM(" ",x);
169
+        //DEBUGLCDCOMM_ECHOPGM(" ", receivedbyte);
164 170
         rx_datagram_state = (DGUS_HEADER2 == receivedbyte) ? DGUS_HEADER2_SEEN : DGUS_IDLE;
165 171
         break;
166 172
 
167 173
       case DGUS_HEADER2_SEEN: // Waiting for the length byte
168 174
         rx_datagram_len = LCD_SERIAL.read();
169
-        DEBUG_ECHOPGM(" (", rx_datagram_len, ") ");
175
+        //DEBUGLCDCOMM_ECHOPGM(" (", rx_datagram_len, ") ");
170 176
 
171 177
         // Telegram min len is 3 (command and one word of payload)
172 178
         rx_datagram_state = WITHIN(rx_datagram_len, 3, DGUS_RX_BUFFER_SIZE) ? DGUS_WAIT_TELEGRAM : DGUS_IDLE;
@@ -178,20 +184,20 @@ void DGUSDisplay::ProcessRx() {
178 184
         Initialized = true; // We've talked to it, so we defined it as initialized.
179 185
         uint8_t command = LCD_SERIAL.read();
180 186
 
181
-        DEBUG_ECHOPGM("# ", command);
187
+        //DEBUGLCDCOMM_ECHOPGM("# ", command);
182 188
 
183 189
         uint8_t readlen = rx_datagram_len - 1;  // command is part of len.
184 190
         unsigned char tmp[rx_datagram_len - 1];
185 191
         unsigned char *ptmp = tmp;
186 192
         while (readlen--) {
187 193
           receivedbyte = LCD_SERIAL.read();
188
-          DEBUG_ECHOPGM(" ", receivedbyte);
194
+          //DEBUGLCDCOMM_ECHOPGM(" ", receivedbyte);
189 195
           *ptmp++ = receivedbyte;
190 196
         }
191
-        DEBUG_ECHOPGM(" # ");
197
+        //DEBUGLCDCOMM_ECHOPGM(" # ");
192 198
         // mostly we'll get this: 5A A5 03 82 4F 4B -- ACK on 0x82, so discard it.
193 199
         if (command == DGUS_CMD_WRITEVAR && 'O' == tmp[0] && 'K' == tmp[1]) {
194
-          DEBUG_ECHOLNPGM(">");
200
+          //DEBUGLCDCOMM_ECHOPGM(">");
195 201
           rx_datagram_state = DGUS_IDLE;
196 202
           break;
197 203
         }
@@ -253,16 +259,16 @@ void DGUSDisplay::loop() {
253 259
 
254 260
 rx_datagram_state_t DGUSDisplay::rx_datagram_state = DGUS_IDLE;
255 261
 uint8_t DGUSDisplay::rx_datagram_len = 0;
256
-bool DGUSDisplay::Initialized = false;
257
-bool DGUSDisplay::no_reentrance = false;
262
+bool DGUSDisplay::Initialized = false,
263
+     DGUSDisplay::no_reentrance = false;
258 264
 
259 265
 // A SW memory barrier, to ensure GCC does not overoptimize loops
260 266
 #define sw_barrier() asm volatile("": : :"memory");
261 267
 
262 268
 bool populate_VPVar(const uint16_t VP, DGUS_VP_Variable * const ramcopy) {
263
-  // DEBUG_ECHOPGM("populate_VPVar ", VP);
269
+  //DEBUG_ECHOPGM("populate_VPVar ", VP);
264 270
   const DGUS_VP_Variable *pvp = DGUSLCD_FindVPVar(VP);
265
-  // DEBUG_ECHOLNPGM(" pvp ", (uint16_t )pvp);
271
+  //DEBUG_ECHOLNPGM(" pvp ", (uint16_t )pvp);
266 272
   if (!pvp) return false;
267 273
   memcpy_P(ramcopy, pvp, sizeof(DGUS_VP_Variable));
268 274
   return true;

+ 3
- 0
Marlin/src/lcd/extui/dgus/DGUSDisplay.h Zobrazit soubor

@@ -29,6 +29,9 @@
29 29
 
30 30
 #include <stdlib.h>    // size_t
31 31
 
32
+//#define DEBUG_DGUSLCD
33
+//#define DEBUG_DGUSLCD_COMM
34
+
32 35
 #if HAS_BED_PROBE
33 36
   #include "../../../module/probe.h"
34 37
 #endif

+ 10
- 7
Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp Zobrazit soubor

@@ -55,14 +55,14 @@ void (*DGUSScreenHandler::confirm_action_cb)() = nullptr;
55 55
 #if ENABLED(SDSUPPORT)
56 56
   int16_t DGUSScreenHandler::top_file = 0,
57 57
           DGUSScreenHandler::file_to_print = 0;
58
-  static ExtUI::FileList filelist;
58
+  ExtUI::FileList filelist;
59 59
 #endif
60 60
 
61 61
 #if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
62 62
   filament_data_t filament_data;
63 63
 #endif
64 64
 
65
-void DGUSScreenHandler::sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool l4inflash) {
65
+void DGUSScreenHandler::sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool l4inflash) {
66 66
   DGUS_VP_Variable ramcopy;
67 67
   if (populate_VPVar(VP_MSGSTR1, &ramcopy)) {
68 68
     ramcopy.memadr = (void*) line1;
@@ -76,13 +76,15 @@ void DGUSScreenHandler::sendinfoscreen(const char *line1, const char *line2, con
76 76
     ramcopy.memadr = (void*) line3;
77 77
     l3inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy);
78 78
   }
79
-  if (populate_VPVar(VP_MSGSTR4, &ramcopy)) {
80
-    ramcopy.memadr = (void*) line4;
81
-    l4inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy);
82
-  }
79
+  #ifdef VP_MSGSTR4
80
+    if (populate_VPVar(VP_MSGSTR4, &ramcopy)) {
81
+      ramcopy.memadr = (void*) line4;
82
+      l4inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy);
83
+    }
84
+  #endif
83 85
 }
84 86
 
85
-void DGUSScreenHandler::HandleUserConfirmationPopUp(uint16_t VP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1, bool l2, bool l3, bool l4) {
87
+void DGUSScreenHandler::HandleUserConfirmationPopUp(uint16_t VP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1, bool l2, bool l3, bool l4) {
86 88
   if (current_screen == DGUSLCD_SCREEN_CONFIRM) // Already showing a pop up, so we need to cancel that first.
87 89
     PopToOldScreen();
88 90
 
@@ -344,6 +346,7 @@ void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var)
344 346
     SetupConfirmAction(nullptr);
345 347
     GotoScreen(DGUSLCD_SCREEN_POPUP);
346 348
   }
349
+
347 350
 #endif // SDSUPPORT
348 351
 
349 352
 void DGUSScreenHandler::ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr) {

+ 1
- 1
Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp Zobrazit soubor

@@ -42,7 +42,7 @@
42 42
 
43 43
 #if ENABLED(SDSUPPORT)
44 44
 
45
-  static ExtUI::FileList filelist;
45
+  extern ExtUI::FileList filelist;
46 46
 
47 47
   void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) {
48 48
     uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file;

+ 3
- 3
Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h Zobrazit soubor

@@ -37,15 +37,15 @@ public:
37 37
 
38 38
   // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
39 39
   // The bools specifying whether the strings are in RAM or FLASH.
40
-  static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
41
-  static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
40
+  static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
41
+  static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
42 42
     sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash);
43 43
   }
44 44
   static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
45 45
     sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash);
46 46
   }
47 47
 
48
-  static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
48
+  static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
49 49
 
50 50
   // "M117" Message -- msg is a RAM ptr.
51 51
   static void setstatusmessage(const char *msg);

+ 1
- 1
Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp Zobrazit soubor

@@ -42,7 +42,7 @@
42 42
 
43 43
 #if ENABLED(SDSUPPORT)
44 44
 
45
-  static ExtUI::FileList filelist;
45
+  extern ExtUI::FileList filelist;
46 46
 
47 47
   void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) {
48 48
     uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file;

+ 3
- 3
Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h Zobrazit soubor

@@ -37,15 +37,15 @@ public:
37 37
 
38 38
   // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
39 39
   // The bools specifying whether the strings are in RAM or FLASH.
40
-  static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
41
-  static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
40
+  static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
41
+  static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
42 42
     sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash);
43 43
   }
44 44
   static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
45 45
     sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash);
46 46
   }
47 47
 
48
-  static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
48
+  static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
49 49
 
50 50
   // "M117" Message -- msg is a RAM ptr.
51 51
   static void setstatusmessage(const char *msg);

+ 2
- 2
Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp Zobrazit soubor

@@ -48,7 +48,7 @@
48 48
 #endif
49 49
 
50 50
 #if ENABLED(SDSUPPORT)
51
-  static ExtUI::FileList filelist;
51
+  extern ExtUI::FileList filelist;
52 52
 #endif
53 53
 
54 54
 bool DGUSAutoTurnOff = false;
@@ -65,7 +65,7 @@ void DGUSScreenHandler::sendinfoscreen_ch_mks(const uint16_t *line1, const uint1
65 65
   dgusdisplay.WriteVariable(VP_MSGSTR4, line4, 32, true);
66 66
 }
67 67
 
68
-void DGUSScreenHandler::sendinfoscreen_en_mks(const char *line1, const char *line2, const char *line3, const char *line4) {
68
+void DGUSScreenHandler::sendinfoscreen_en_mks(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4) {
69 69
   dgusdisplay.WriteVariable(VP_MSGSTR1, line1, 32, true);
70 70
   dgusdisplay.WriteVariable(VP_MSGSTR2, line2, 32, true);
71 71
   dgusdisplay.WriteVariable(VP_MSGSTR3, line3, 32, true);

+ 4
- 4
Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h Zobrazit soubor

@@ -37,19 +37,19 @@ public:
37 37
 
38 38
   // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
39 39
   // The bools specifying whether the strings are in RAM or FLASH.
40
-  static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
41
-  static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
40
+  static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
41
+  static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
42 42
     sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash);
43 43
   }
44 44
   static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
45 45
     sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash);
46 46
   }
47 47
 
48
-  static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
48
+  static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
49 49
 
50 50
   #if 0
51 51
   static void sendinfoscreen_ch_mks(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4);
52
-  static void sendinfoscreen_en_mks(const char *line1, const char *line2, const char *line3, const char *line4) ;
52
+  static void sendinfoscreen_en_mks(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4);
53 53
   static void sendinfoscreen_mks(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language);
54 54
   #endif
55 55
 

+ 1
- 1
Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp Zobrazit soubor

@@ -42,7 +42,7 @@
42 42
 
43 43
 #if ENABLED(SDSUPPORT)
44 44
 
45
-  static ExtUI::FileList filelist;
45
+  extern ExtUI::FileList filelist;
46 46
 
47 47
   void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) {
48 48
     uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file;

+ 3
- 3
Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h Zobrazit soubor

@@ -37,15 +37,15 @@ public:
37 37
 
38 38
   // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
39 39
   // The bools specifying whether the strings are in RAM or FLASH.
40
-  static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
41
-  static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
40
+  static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
41
+  static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
42 42
     sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash);
43 43
   }
44 44
   static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
45 45
     sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash);
46 46
   }
47 47
 
48
-  static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
48
+  static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
49 49
 
50 50
   // "M117" Message -- msg is a RAM ptr.
51 51
   static void setstatusmessage(const char *msg);

Loading…
Zrušit
Uložit