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:
parent
fb68e8c4d6
commit
895280cb5a
|
@ -134,7 +134,7 @@ void update_display(){
|
|||
if(Stw_data.buttonState1 & Stw_data.buttonState4){
|
||||
alarm("");
|
||||
}
|
||||
if(!tft._displaybool){
|
||||
if(!tft.disconnected){
|
||||
tft.cursorOn(false);
|
||||
if(trcalt!=Stw_data.trc or trctimer == true or Stw_data.buttonStateEnc1 == HIGH){
|
||||
display_trc();
|
||||
|
@ -380,7 +380,7 @@ void alarm(String textstr){
|
|||
textstr.toCharArray(text,7);
|
||||
tft.setTextSize(8,8);
|
||||
while(x==1){
|
||||
if(!tft._displaybool){
|
||||
if(!tft.disconnected){
|
||||
tft.setTextColor(EA_BLACK,EA_RED);
|
||||
tft.fillDisplayColor(EA_RED);
|
||||
tft.drawText(5,68,'L',text);
|
||||
|
@ -389,7 +389,7 @@ void alarm(String textstr){
|
|||
digitalWrite(led_s[j], HIGH);
|
||||
}
|
||||
delay(100);
|
||||
if(!tft._displaybool){
|
||||
if(!tft.disconnected){
|
||||
tft.setTextColor(EA_BLACK,EA_WHITE);
|
||||
tft.fillDisplayColor(EA_WHITE);
|
||||
tft.drawText(5,68,'L',text);
|
||||
|
|
|
@ -77,7 +77,7 @@ double get_value(int a)
|
|||
|
||||
void update_display()
|
||||
{
|
||||
if (!tft._displaybool)
|
||||
if (!tft.disconnected)
|
||||
{
|
||||
tft.cursorOn(false);
|
||||
if (modealt != Stw_data.mode || modetimer == true)
|
||||
|
@ -140,7 +140,7 @@ void alarm(String textstr)
|
|||
tft.setTextSize(8, 8);
|
||||
while (x == 1)
|
||||
{
|
||||
if (!tft._displaybool)
|
||||
if (!tft.disconnected)
|
||||
{
|
||||
tft.setTextColor(EA_BLACK, EA_RED);
|
||||
tft.fillDisplayColor(EA_RED);
|
||||
|
@ -151,7 +151,7 @@ void alarm(String textstr)
|
|||
digitalWrite(led_s[j], HIGH);
|
||||
}
|
||||
delay(100);
|
||||
if (!tft._displaybool)
|
||||
if (!tft.disconnected)
|
||||
{
|
||||
tft.setTextColor(EA_BLACK, EA_WHITE);
|
||||
tft.fillDisplayColor(EA_WHITE);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue