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:
		@ -134,7 +134,7 @@ void update_display(){
 | 
				
			|||||||
	if(Stw_data.buttonState1 & Stw_data.buttonState4){
 | 
						if(Stw_data.buttonState1 & Stw_data.buttonState4){
 | 
				
			||||||
		alarm("");
 | 
							alarm("");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if(!tft._displaybool){
 | 
						if(!tft.disconnected){
 | 
				
			||||||
		tft.cursorOn(false);
 | 
							tft.cursorOn(false);
 | 
				
			||||||
		if(trcalt!=Stw_data.trc or trctimer == true or Stw_data.buttonStateEnc1 == HIGH){
 | 
							if(trcalt!=Stw_data.trc or trctimer == true or Stw_data.buttonStateEnc1 == HIGH){
 | 
				
			||||||
			display_trc();
 | 
								display_trc();
 | 
				
			||||||
@ -380,7 +380,7 @@ void alarm(String textstr){
 | 
				
			|||||||
	textstr.toCharArray(text,7);
 | 
						textstr.toCharArray(text,7);
 | 
				
			||||||
	tft.setTextSize(8,8);
 | 
						tft.setTextSize(8,8);
 | 
				
			||||||
	while(x==1){
 | 
						while(x==1){
 | 
				
			||||||
		if(!tft._displaybool){
 | 
							if(!tft.disconnected){
 | 
				
			||||||
			tft.setTextColor(EA_BLACK,EA_RED);
 | 
								tft.setTextColor(EA_BLACK,EA_RED);
 | 
				
			||||||
			tft.fillDisplayColor(EA_RED);
 | 
								tft.fillDisplayColor(EA_RED);
 | 
				
			||||||
			tft.drawText(5,68,'L',text);
 | 
								tft.drawText(5,68,'L',text);
 | 
				
			||||||
@ -389,7 +389,7 @@ void alarm(String textstr){
 | 
				
			|||||||
			digitalWrite(led_s[j], HIGH);
 | 
								digitalWrite(led_s[j], HIGH);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		delay(100);
 | 
							delay(100);
 | 
				
			||||||
		if(!tft._displaybool){
 | 
							if(!tft.disconnected){
 | 
				
			||||||
			tft.setTextColor(EA_BLACK,EA_WHITE);
 | 
								tft.setTextColor(EA_BLACK,EA_WHITE);
 | 
				
			||||||
			tft.fillDisplayColor(EA_WHITE);
 | 
								tft.fillDisplayColor(EA_WHITE);
 | 
				
			||||||
			tft.drawText(5,68,'L',text);
 | 
								tft.drawText(5,68,'L',text);
 | 
				
			||||||
 | 
				
			|||||||
@ -77,7 +77,7 @@ double get_value(int a)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void update_display()
 | 
					void update_display()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (!tft._displaybool)
 | 
						if (!tft.disconnected)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		tft.cursorOn(false);
 | 
							tft.cursorOn(false);
 | 
				
			||||||
		if (modealt != Stw_data.mode || modetimer == true)
 | 
							if (modealt != Stw_data.mode || modetimer == true)
 | 
				
			||||||
@ -140,7 +140,7 @@ void alarm(String textstr)
 | 
				
			|||||||
	tft.setTextSize(8, 8);
 | 
						tft.setTextSize(8, 8);
 | 
				
			||||||
	while (x == 1)
 | 
						while (x == 1)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		if (!tft._displaybool)
 | 
							if (!tft.disconnected)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			tft.setTextColor(EA_BLACK, EA_RED);
 | 
								tft.setTextColor(EA_BLACK, EA_RED);
 | 
				
			||||||
			tft.fillDisplayColor(EA_RED);
 | 
								tft.fillDisplayColor(EA_RED);
 | 
				
			||||||
@ -151,7 +151,7 @@ void alarm(String textstr)
 | 
				
			|||||||
			digitalWrite(led_s[j], HIGH);
 | 
								digitalWrite(led_s[j], HIGH);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		delay(100);
 | 
							delay(100);
 | 
				
			||||||
		if (!tft._displaybool)
 | 
							if (!tft.disconnected)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			tft.setTextColor(EA_BLACK, EA_WHITE);
 | 
								tft.setTextColor(EA_BLACK, EA_WHITE);
 | 
				
			||||||
			tft.fillDisplayColor(EA_WHITE);
 | 
								tft.fillDisplayColor(EA_WHITE);
 | 
				
			||||||
 | 
				
			|||||||
@ -26,10 +26,8 @@
 | 
				
			|||||||
#define DEBUG false
 | 
					#define DEBUG false
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EDIPTFT::EDIPTFT(boolean smallprotocol, boolean displaybool) {
 | 
					EDIPTFT::EDIPTFT(boolean smallprotocol, boolean disconnected)
 | 
				
			||||||
  _smallprotocol = smallprotocol;
 | 
					  : _smallprotocol{smallprotocol}, disconnected{disconnected} {}
 | 
				
			||||||
  _displaybool = displaybool;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void EDIPTFT::begin(long baud) {
 | 
					void EDIPTFT::begin(long baud) {
 | 
				
			||||||
@ -108,6 +106,10 @@ void EDIPTFT::sendData(char* data, char len) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void EDIPTFT::sendSmall(char* data, char len) {
 | 
					void EDIPTFT::sendSmall(char* data, char len) {
 | 
				
			||||||
 | 
					  if (disconnected) {
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  unsigned char i, bcc;
 | 
					  unsigned char i, bcc;
 | 
				
			||||||
  char ok = 0;
 | 
					  char ok = 0;
 | 
				
			||||||
  const uint32_t t_start = millis();
 | 
					  const uint32_t t_start = millis();
 | 
				
			||||||
@ -137,12 +139,10 @@ void EDIPTFT::sendSmall(char* data, char len) {
 | 
				
			|||||||
      delay(200);
 | 
					      delay(200);
 | 
				
			||||||
      ok = 0;
 | 
					      ok = 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
	if(t_start + 1000 < millis())
 | 
					    if (t_start + 1000 < millis()) {
 | 
				
			||||||
	{
 | 
					      ok = 1;
 | 
				
			||||||
		//Serial.println("Error: waited to long!");
 | 
					      disconnected = true;
 | 
				
			||||||
		ok =1;
 | 
					    }
 | 
				
			||||||
		_displaybool = true;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -72,8 +72,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class EDIPTFT {
 | 
					class EDIPTFT {
 | 
				
			||||||
  public:
 | 
					  public:
 | 
				
			||||||
    EDIPTFT(boolean smallprotocol=true, boolean displaybool=false);
 | 
					    EDIPTFT(boolean smallprotocol=true, boolean disconnected=false);
 | 
				
			||||||
	boolean _displaybool;
 | 
						boolean disconnected;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void begin(long baud=115200);
 | 
					    void begin(long baud=115200);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user