From 895280cb5aa0c32e7525c73fb1864624a052748a Mon Sep 17 00:00:00 2001 From: jvblanck Date: Sun, 18 Jul 2021 18:27:47 +0200 Subject: [PATCH] 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. --- lib/FT18_STW_DISPLAY/FT18_STW_DISPLAY.cpp | 6 +++--- lib/FT18e_STW_DISPLAY/FT18e_STW_DISPLAY.cpp | 6 +++--- lib/arduino-ediptft-master/EDIPTFT.cpp | 20 ++++++++++---------- lib/arduino-ediptft-master/EDIPTFT.h | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/FT18_STW_DISPLAY/FT18_STW_DISPLAY.cpp b/lib/FT18_STW_DISPLAY/FT18_STW_DISPLAY.cpp index 84afc35..820e7d6 100644 --- a/lib/FT18_STW_DISPLAY/FT18_STW_DISPLAY.cpp +++ b/lib/FT18_STW_DISPLAY/FT18_STW_DISPLAY.cpp @@ -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); diff --git a/lib/FT18e_STW_DISPLAY/FT18e_STW_DISPLAY.cpp b/lib/FT18e_STW_DISPLAY/FT18e_STW_DISPLAY.cpp index c4d3110..94079a9 100644 --- a/lib/FT18e_STW_DISPLAY/FT18e_STW_DISPLAY.cpp +++ b/lib/FT18e_STW_DISPLAY/FT18e_STW_DISPLAY.cpp @@ -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); diff --git a/lib/arduino-ediptft-master/EDIPTFT.cpp b/lib/arduino-ediptft-master/EDIPTFT.cpp index 064bfa9..83a72ed 100644 --- a/lib/arduino-ediptft-master/EDIPTFT.cpp +++ b/lib/arduino-ediptft-master/EDIPTFT.cpp @@ -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; + } } } diff --git a/lib/arduino-ediptft-master/EDIPTFT.h b/lib/arduino-ediptft-master/EDIPTFT.h index fb400d4..c494752 100644 --- a/lib/arduino-ediptft-master/EDIPTFT.h +++ b/lib/arduino-ediptft-master/EDIPTFT.h @@ -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);