🎨 Fewer serial macros

This commit is contained in:
Scott Lahteine
2021-09-09 04:57:05 -05:00
committed by Scott Lahteine
parent 6d96c221bd
commit b661795ae5
159 changed files with 1002 additions and 1014 deletions

View File

@ -159,7 +159,7 @@ void DGUSDisplay::WriteStringPGM(uint16_t addr, const void* data_ptr, uint8_t si
}
void DGUSDisplay::SwitchScreen(DGUS_Screen screen) {
DEBUG_ECHOLNPAIR("SwitchScreen ", (uint8_t)screen);
DEBUG_ECHOLNPGM("SwitchScreen ", (uint8_t)screen);
const uint8_t command[] = { 0x5A, 0x01, 0x00, (uint8_t)screen };
Write(0x84, command, sizeof(command));
}
@ -167,13 +167,13 @@ void DGUSDisplay::SwitchScreen(DGUS_Screen screen) {
void DGUSDisplay::PlaySound(uint8_t start, uint8_t len, uint8_t volume) {
if (volume == 0) volume = DGUSDisplay::volume;
if (volume == 0) return;
DEBUG_ECHOLNPAIR("PlaySound ", start, ":", len, "\nVolume ", volume);
DEBUG_ECHOLNPGM("PlaySound ", start, ":", len, "\nVolume ", volume);
const uint8_t command[] = { start, len, volume, 0x00 };
Write(0xA0, command, sizeof(command));
}
void DGUSDisplay::EnableControl(DGUS_Screen screen, DGUS_ControlType type, DGUS_Control control) {
DEBUG_ECHOLNPAIR("EnableControl ", (uint8_t)control, "\nScreen ", (uint8_t)screen, "\nType ", (uint8_t)type);
DEBUG_ECHOLNPGM("EnableControl ", (uint8_t)control, "\nScreen ", (uint8_t)screen, "\nType ", (uint8_t)type);
const uint8_t command[] = { 0x5A, 0xA5, 0x00, (uint8_t)screen, (uint8_t)control, type, 0x00, 0x01 };
Write(0xB0, command, sizeof(command));
@ -183,7 +183,7 @@ void DGUSDisplay::EnableControl(DGUS_Screen screen, DGUS_ControlType type, DGUS_
}
void DGUSDisplay::DisableControl(DGUS_Screen screen, DGUS_ControlType type, DGUS_Control control) {
DEBUG_ECHOLNPAIR("DisableControl ", (uint8_t)control, "\nScreen ", (uint8_t)screen, "\nType ", (uint8_t)type);
DEBUG_ECHOLNPGM("DisableControl ", (uint8_t)control, "\nScreen ", (uint8_t)screen, "\nType ", (uint8_t)type);
const uint8_t command[] = { 0x5A, 0xA5, 0x00, (uint8_t)screen, (uint8_t)control, type, 0x00, 0x00 };
Write(0xB0, command, sizeof(command));
@ -203,14 +203,14 @@ uint8_t DGUSDisplay::GetVolume() {
void DGUSDisplay::SetBrightness(uint8_t new_brightness) {
brightness = constrain(new_brightness, 0, 100);
new_brightness = map_precise(brightness, 0, 100, 5, 100);
DEBUG_ECHOLNPAIR("SetBrightness ", new_brightness);
DEBUG_ECHOLNPGM("SetBrightness ", new_brightness);
const uint8_t command[] = { new_brightness, new_brightness };
Write(0x82, command, sizeof(command));
}
void DGUSDisplay::SetVolume(uint8_t new_volume) {
volume = map_precise(constrain(new_volume, 0, 100), 0, 100, 0, 255);
DEBUG_ECHOLNPAIR("SetVolume ", volume);
DEBUG_ECHOLNPGM("SetVolume ", volume);
const uint8_t command[] = { volume, 0x00 };
Write(0xA1, command, sizeof(command));
}
@ -234,19 +234,19 @@ void DGUSDisplay::ProcessRx() {
case DGUS_IDLE: // Waiting for the first header byte
receivedbyte = LCD_SERIAL.read();
DEBUG_ECHOPAIR("< ", receivedbyte);
DEBUG_ECHOPGM("< ", receivedbyte);
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(" ", receivedbyte);
DEBUG_ECHOPGM(" ", receivedbyte);
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;
@ -258,7 +258,7 @@ 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];
@ -266,7 +266,7 @@ void DGUSDisplay::ProcessRx() {
while (readlen--) {
receivedbyte = LCD_SERIAL.read();
DEBUG_ECHOPAIR(" ", receivedbyte);
DEBUG_ECHOPGM(" ", receivedbyte);
*ptmp++ = receivedbyte;
}
DEBUG_ECHOPGM(" # ");
@ -287,7 +287,7 @@ void DGUSDisplay::ProcessRx() {
if (command == DGUS_READVAR) {
const uint16_t addr = tmp[0] << 8 | tmp[1];
const uint8_t dlen = tmp[2] << 1; // Convert to Bytes. (Display works with words)
DEBUG_ECHOPAIR("addr=", addr, " dlen=", dlen, "> ");
DEBUG_ECHOPGM("addr=", addr, " dlen=", dlen, "> ");
if (addr == DGUS_VERSION && dlen == 2) {
DEBUG_ECHOLNPGM("VERSIONS");
@ -400,7 +400,7 @@ bool DGUS_PopulateVP(const DGUS_Addr addr, DGUS_VP * const buffer) {
return true;
}
} while (++ret);
DEBUG_ECHOLNPAIR("VP not found: ", (uint16_t)addr);
DEBUG_ECHOLNPGM("VP not found: ", (uint16_t)addr);
return false;
}