🎨 Fewer serial macros

This commit is contained in:
Scott Lahteine
2021-09-09 04:57:05 -05:00
parent 79c72ed821
commit 754b31918a
159 changed files with 1002 additions and 1014 deletions

View File

@@ -154,19 +154,19 @@ void DGUSDisplay::ProcessRx() {
case DGUS_IDLE: // Waiting for the first header byte
receivedbyte = LCD_SERIAL.read();
//DEBUG_ECHOPAIR("< ",x);
//DEBUG_ECHOPGM("< ",x);
if (DGUS_HEADER1 == receivedbyte) rx_datagram_state = DGUS_HEADER1_SEEN;
break;
case DGUS_HEADER1_SEEN: // Waiting for the second header byte
receivedbyte = LCD_SERIAL.read();
//DEBUG_ECHOPAIR(" ",x);
//DEBUG_ECHOPGM(" ",x);
rx_datagram_state = (DGUS_HEADER2 == receivedbyte) ? DGUS_HEADER2_SEEN : DGUS_IDLE;
break;
case DGUS_HEADER2_SEEN: // Waiting for the length byte
rx_datagram_len = LCD_SERIAL.read();
DEBUG_ECHOPAIR(" (", rx_datagram_len, ") ");
DEBUG_ECHOPGM(" (", rx_datagram_len, ") ");
// Telegram min len is 3 (command and one word of payload)
rx_datagram_state = WITHIN(rx_datagram_len, 3, DGUS_RX_BUFFER_SIZE) ? DGUS_WAIT_TELEGRAM : DGUS_IDLE;
@@ -178,14 +178,14 @@ void DGUSDisplay::ProcessRx() {
Initialized = true; // We've talked to it, so we defined it as initialized.
uint8_t command = LCD_SERIAL.read();
DEBUG_ECHOPAIR("# ", command);
DEBUG_ECHOPGM("# ", command);
uint8_t readlen = rx_datagram_len - 1; // command is part of len.
unsigned char tmp[rx_datagram_len - 1];
unsigned char *ptmp = tmp;
while (readlen--) {
receivedbyte = LCD_SERIAL.read();
DEBUG_ECHOPAIR(" ", receivedbyte);
DEBUG_ECHOPGM(" ", receivedbyte);
*ptmp++ = receivedbyte;
}
DEBUG_ECHOPGM(" # ");
@@ -206,7 +206,7 @@ void DGUSDisplay::ProcessRx() {
if (command == DGUS_CMD_READVAR) {
const uint16_t vp = tmp[0] << 8 | tmp[1];
//const uint8_t dlen = tmp[2] << 1; // Convert to Bytes. (Display works with words)
//DEBUG_ECHOPAIR(" vp=", vp, " dlen=", dlen);
//DEBUG_ECHOPGM(" vp=", vp, " dlen=", dlen);
DGUS_VP_Variable ramcopy;
if (populate_VPVar(vp, &ramcopy)) {
if (ramcopy.set_by_display_handler)
@@ -215,7 +215,7 @@ void DGUSDisplay::ProcessRx() {
DEBUG_ECHOLNPGM(" VPVar found, no handler.");
}
else
DEBUG_ECHOLNPAIR(" VPVar not found:", vp);
DEBUG_ECHOLNPGM(" VPVar not found:", vp);
rx_datagram_state = DGUS_IDLE;
break;
@@ -260,9 +260,9 @@ bool DGUSDisplay::no_reentrance = false;
#define sw_barrier() asm volatile("": : :"memory");
bool populate_VPVar(const uint16_t VP, DGUS_VP_Variable * const ramcopy) {
// DEBUG_ECHOPAIR("populate_VPVar ", VP);
// DEBUG_ECHOPGM("populate_VPVar ", VP);
const DGUS_VP_Variable *pvp = DGUSLCD_FindVPVar(VP);
// DEBUG_ECHOLNPAIR(" pvp ", (uint16_t )pvp);
// DEBUG_ECHOLNPGM(" pvp ", (uint16_t )pvp);
if (!pvp) return false;
memcpy_P(ramcopy, pvp, sizeof(DGUS_VP_Variable));
return true;