Don't send data if display is disconnected

Otherwise, we're waiting 1s on pretty much any call to the display. If
the display gets disconnected at the start of the `update_display()`
function, that can mean quite the delay.

It's possible that this delay triggers a watchdog timer that blinks the
LEDs, but there doesn't appear to be any watchdog timer configured.
This commit is contained in:
jvblanck
2021-07-18 18:27:47 +02:00
parent fb68e8c4d6
commit 895280cb5a
4 changed files with 18 additions and 18 deletions

View File

@ -26,10 +26,8 @@
#define DEBUG false
EDIPTFT::EDIPTFT(boolean smallprotocol, boolean displaybool) {
_smallprotocol = smallprotocol;
_displaybool = displaybool;
}
EDIPTFT::EDIPTFT(boolean smallprotocol, boolean disconnected)
: _smallprotocol{smallprotocol}, disconnected{disconnected} {}
void EDIPTFT::begin(long baud) {
@ -108,6 +106,10 @@ void EDIPTFT::sendData(char* data, char len) {
void EDIPTFT::sendSmall(char* data, char len) {
if (disconnected) {
return;
}
unsigned char i, bcc;
char ok = 0;
const uint32_t t_start = millis();
@ -137,12 +139,10 @@ void EDIPTFT::sendSmall(char* data, char len) {
delay(200);
ok = 0;
}
if(t_start + 1000 < millis())
{
//Serial.println("Error: waited to long!");
ok =1;
_displaybool = true;
}
if (t_start + 1000 < millis()) {
ok = 1;
disconnected = true;
}
}
}

View File

@ -72,8 +72,8 @@
class EDIPTFT {
public:
EDIPTFT(boolean smallprotocol=true, boolean displaybool=false);
boolean _displaybool;
EDIPTFT(boolean smallprotocol=true, boolean disconnected=false);
boolean disconnected;
void begin(long baud=115200);