Skip to content

Commit 3d2b2ca

Browse files
committed
🎨 Misc. DGUS cleanup
1 parent f2d1770 commit 3d2b2ca

11 files changed

+48
-36
lines changed

Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp

+17-11
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646

4747
DGUSDisplay dgusdisplay;
4848

49+
#ifdef DEBUG_DGUSLCD_COMM
50+
#define DEBUGLCDCOMM_ECHOPGM DEBUG_ECHOPGM
51+
#else
52+
#define DEBUGLCDCOMM_ECHOPGM(...) NOOP
53+
#endif
54+
4955
// Preamble... 2 Bytes, usually 0x5A 0xA5, but configurable
5056
constexpr uint8_t DGUS_HEADER1 = 0x5A;
5157
constexpr uint8_t DGUS_HEADER2 = 0xA5;
@@ -154,19 +160,19 @@ void DGUSDisplay::ProcessRx() {
154160

155161
case DGUS_IDLE: // Waiting for the first header byte
156162
receivedbyte = LCD_SERIAL.read();
157-
//DEBUG_ECHOPGM("< ",x);
163+
//DEBUGLCDCOMM_ECHOPGM("< ", receivedbyte);
158164
if (DGUS_HEADER1 == receivedbyte) rx_datagram_state = DGUS_HEADER1_SEEN;
159165
break;
160166

161167
case DGUS_HEADER1_SEEN: // Waiting for the second header byte
162168
receivedbyte = LCD_SERIAL.read();
163-
//DEBUG_ECHOPGM(" ",x);
169+
//DEBUGLCDCOMM_ECHOPGM(" ", receivedbyte);
164170
rx_datagram_state = (DGUS_HEADER2 == receivedbyte) ? DGUS_HEADER2_SEEN : DGUS_IDLE;
165171
break;
166172

167173
case DGUS_HEADER2_SEEN: // Waiting for the length byte
168174
rx_datagram_len = LCD_SERIAL.read();
169-
DEBUG_ECHOPGM(" (", rx_datagram_len, ") ");
175+
//DEBUGLCDCOMM_ECHOPGM(" (", rx_datagram_len, ") ");
170176

171177
// Telegram min len is 3 (command and one word of payload)
172178
rx_datagram_state = WITHIN(rx_datagram_len, 3, DGUS_RX_BUFFER_SIZE) ? DGUS_WAIT_TELEGRAM : DGUS_IDLE;
@@ -178,20 +184,20 @@ void DGUSDisplay::ProcessRx() {
178184
Initialized = true; // We've talked to it, so we defined it as initialized.
179185
uint8_t command = LCD_SERIAL.read();
180186

181-
DEBUG_ECHOPGM("# ", command);
187+
//DEBUGLCDCOMM_ECHOPGM("# ", command);
182188

183189
uint8_t readlen = rx_datagram_len - 1; // command is part of len.
184190
unsigned char tmp[rx_datagram_len - 1];
185191
unsigned char *ptmp = tmp;
186192
while (readlen--) {
187193
receivedbyte = LCD_SERIAL.read();
188-
DEBUG_ECHOPGM(" ", receivedbyte);
194+
//DEBUGLCDCOMM_ECHOPGM(" ", receivedbyte);
189195
*ptmp++ = receivedbyte;
190196
}
191-
DEBUG_ECHOPGM(" # ");
197+
//DEBUGLCDCOMM_ECHOPGM(" # ");
192198
// mostly we'll get this: 5A A5 03 82 4F 4B -- ACK on 0x82, so discard it.
193199
if (command == DGUS_CMD_WRITEVAR && 'O' == tmp[0] && 'K' == tmp[1]) {
194-
DEBUG_ECHOLNPGM(">");
200+
//DEBUGLCDCOMM_ECHOPGM(">");
195201
rx_datagram_state = DGUS_IDLE;
196202
break;
197203
}
@@ -253,16 +259,16 @@ void DGUSDisplay::loop() {
253259

254260
rx_datagram_state_t DGUSDisplay::rx_datagram_state = DGUS_IDLE;
255261
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;
258264

259265
// A SW memory barrier, to ensure GCC does not overoptimize loops
260266
#define sw_barrier() asm volatile("": : :"memory");
261267

262268
bool populate_VPVar(const uint16_t VP, DGUS_VP_Variable * const ramcopy) {
263-
// DEBUG_ECHOPGM("populate_VPVar ", VP);
269+
//DEBUG_ECHOPGM("populate_VPVar ", VP);
264270
const DGUS_VP_Variable *pvp = DGUSLCD_FindVPVar(VP);
265-
// DEBUG_ECHOLNPGM(" pvp ", (uint16_t )pvp);
271+
//DEBUG_ECHOLNPGM(" pvp ", (uint16_t )pvp);
266272
if (!pvp) return false;
267273
memcpy_P(ramcopy, pvp, sizeof(DGUS_VP_Variable));
268274
return true;

Marlin/src/lcd/extui/dgus/DGUSDisplay.h

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929

3030
#include <stdlib.h> // size_t
3131

32+
//#define DEBUG_DGUSLCD
33+
//#define DEBUG_DGUSLCD_COMM
34+
3235
#if HAS_BED_PROBE
3336
#include "../../../module/probe.h"
3437
#endif

Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ void (*DGUSScreenHandler::confirm_action_cb)() = nullptr;
5555
#if ENABLED(SDSUPPORT)
5656
int16_t DGUSScreenHandler::top_file = 0,
5757
DGUSScreenHandler::file_to_print = 0;
58-
static ExtUI::FileList filelist;
58+
ExtUI::FileList filelist;
5959
#endif
6060

6161
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
6262
filament_data_t filament_data;
6363
#endif
6464

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) {
6666
DGUS_VP_Variable ramcopy;
6767
if (populate_VPVar(VP_MSGSTR1, &ramcopy)) {
6868
ramcopy.memadr = (void*) line1;
@@ -76,13 +76,15 @@ void DGUSScreenHandler::sendinfoscreen(const char *line1, const char *line2, con
7676
ramcopy.memadr = (void*) line3;
7777
l3inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy);
7878
}
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
8385
}
8486

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) {
8688
if (current_screen == DGUSLCD_SCREEN_CONFIRM) // Already showing a pop up, so we need to cancel that first.
8789
PopToOldScreen();
8890

@@ -344,6 +346,7 @@ void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var)
344346
SetupConfirmAction(nullptr);
345347
GotoScreen(DGUSLCD_SCREEN_POPUP);
346348
}
349+
347350
#endif // SDSUPPORT
348351

349352
void DGUSScreenHandler::ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr) {

Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
#if ENABLED(SDSUPPORT)
4444

45-
static ExtUI::FileList filelist;
45+
extern ExtUI::FileList filelist;
4646

4747
void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) {
4848
uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file;

Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ class DGUSScreenHandler {
3737

3838
// Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
3939
// 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) {
4242
sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash);
4343
}
4444
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) {
4545
sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash);
4646
}
4747

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);
4949

5050
// "M117" Message -- msg is a RAM ptr.
5151
static void setstatusmessage(const char *msg);

Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
#if ENABLED(SDSUPPORT)
4444

45-
static ExtUI::FileList filelist;
45+
extern ExtUI::FileList filelist;
4646

4747
void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) {
4848
uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file;

Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ class DGUSScreenHandler {
3737

3838
// Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
3939
// 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) {
4242
sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash);
4343
}
4444
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) {
4545
sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash);
4646
}
4747

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);
4949

5050
// "M117" Message -- msg is a RAM ptr.
5151
static void setstatusmessage(const char *msg);

Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#endif
4949

5050
#if ENABLED(SDSUPPORT)
51-
static ExtUI::FileList filelist;
51+
extern ExtUI::FileList filelist;
5252
#endif
5353

5454
bool DGUSAutoTurnOff = false;
@@ -65,7 +65,7 @@ void DGUSScreenHandler::sendinfoscreen_ch_mks(const uint16_t *line1, const uint1
6565
dgusdisplay.WriteVariable(VP_MSGSTR4, line4, 32, true);
6666
}
6767

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) {
6969
dgusdisplay.WriteVariable(VP_MSGSTR1, line1, 32, true);
7070
dgusdisplay.WriteVariable(VP_MSGSTR2, line2, 32, true);
7171
dgusdisplay.WriteVariable(VP_MSGSTR3, line3, 32, true);

Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ class DGUSScreenHandler {
3737

3838
// Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
3939
// 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) {
4242
sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash);
4343
}
4444
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) {
4545
sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash);
4646
}
4747

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);
4949

5050
#if 0
5151
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);
5353
static void sendinfoscreen_mks(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language);
5454
#endif
5555

Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
#if ENABLED(SDSUPPORT)
4444

45-
static ExtUI::FileList filelist;
45+
extern ExtUI::FileList filelist;
4646

4747
void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) {
4848
uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file;

Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ class DGUSScreenHandler {
3737

3838
// Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
3939
// 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) {
4242
sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash);
4343
}
4444
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) {
4545
sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash);
4646
}
4747

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);
4949

5050
// "M117" Message -- msg is a RAM ptr.
5151
static void setstatusmessage(const char *msg);

0 commit comments

Comments
 (0)