[WIP] Major rewrite of display code
Currently, the displayed values are hardcoded
This commit is contained in:
		@ -8,31 +8,15 @@ EDIPTFT tft(true,false);
 | 
				
			|||||||
String bezeichnungen[]={"T_mot","T_oil","P_oil","% fa","U_batt","P_wat","T_air",
 | 
					String bezeichnungen[]={"T_mot","T_oil","P_oil","% fa","U_batt","P_wat","T_air",
 | 
				
			||||||
						"P_b_front","P_b_rear","Error Type","Speed_fl","Speed_fr","Speed"};
 | 
											"P_b_front","P_b_rear","Error Type","Speed_fl","Speed_fr","Speed"};
 | 
				
			||||||
//"Drehzahl","P_fuel","Index"
 | 
					//"Drehzahl","P_fuel","Index"
 | 
				
			||||||
int vergleichsindex;
 | 
					 | 
				
			||||||
int sizeaalt;
 | 
					 | 
				
			||||||
int sizeaneu;
 | 
					 | 
				
			||||||
int sizebalt;
 | 
					 | 
				
			||||||
int sizebneu;
 | 
					 | 
				
			||||||
int sizecalt;
 | 
					 | 
				
			||||||
int sizecneu;
 | 
					 | 
				
			||||||
int sizedalt;
 | 
					 | 
				
			||||||
int sizedneu;
 | 
					 | 
				
			||||||
int sizeealt;
 | 
					 | 
				
			||||||
int sizeeneu;
 | 
					 | 
				
			||||||
uint8_t clearcounter = 56;
 | 
					 | 
				
			||||||
uint8_t trcalt = Stw_data.trc; 
 | 
					 | 
				
			||||||
uint8_t modealt = Stw_data.mode;
 | 
					 | 
				
			||||||
uint8_t trccounter;// = Stw_data.trc;
 | 
					 | 
				
			||||||
uint8_t modecounter;// = Stw_data.mode;
 | 
					 | 
				
			||||||
bool trctimer;
 | 
					 | 
				
			||||||
bool modetimer;
 | 
					 | 
				
			||||||
int led_s[] = {led1,led2,led3,led4,led5,led6,led7,led8,led9,led10,led11,led12,led13,led14,led15,led16};
 | 
					int led_s[] = {led1,led2,led3,led4,led5,led6,led7,led8,led9,led10,led11,led12,led13,led14,led15,led16};
 | 
				
			||||||
unsigned long poiltimer;
 | 
					
 | 
				
			||||||
unsigned long tmottimer;
 | 
					DataBox gear_box(121, 0, 199, 94, 160, 0, EA_SWISS30B, 4, 4, 'C');
 | 
				
			||||||
unsigned long toiltimer;
 | 
					DataBox left_box(0, 0, 119, 94, 110, 12, EA_FONT7X12, 3, 8, 'R');
 | 
				
			||||||
bool poilbool = true;
 | 
					DataBox right_box(201, 0, 320, 94, 310, 12, EA_FONT7X12, 3, 8, 'R');
 | 
				
			||||||
bool tmotbool = true;
 | 
					TireTempBox fl_box(80, 130, 156, 176, 118, 124, EA_FONT7X12, 3, 5, 'C');
 | 
				
			||||||
bool toilbool = true;
 | 
					TireTempBox fr_box(164, 130, 240, 176, 202, 124, EA_FONT7X12, 3, 5, 'C');
 | 
				
			||||||
 | 
					TireTempBox rl_box(80, 184, 156, 230, 118, 178, EA_FONT7X12, 3, 5, 'C');
 | 
				
			||||||
 | 
					TireTempBox rr_box(164, 184, 240, 230, 202, 178, EA_FONT7X12, 3, 5, 'C');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void init_display() {
 | 
					void init_display() {
 | 
				
			||||||
	pinMode(writeprotect, OUTPUT);
 | 
						pinMode(writeprotect, OUTPUT);
 | 
				
			||||||
@ -41,336 +25,197 @@ void init_display() {
 | 
				
			|||||||
	pinMode(disp_cs, OUTPUT);
 | 
						pinMode(disp_cs, OUTPUT);
 | 
				
			||||||
	pinMode(MOSI, OUTPUT);
 | 
						pinMode(MOSI, OUTPUT);
 | 
				
			||||||
	pinMode(MISO, OUTPUT);
 | 
						pinMode(MISO, OUTPUT);
 | 
				
			||||||
	//pinMode(CLK, INPUT);
 | 
					 | 
				
			||||||
	digitalWrite(disp_cs, HIGH);
 | 
						digitalWrite(disp_cs, HIGH);
 | 
				
			||||||
	digitalWrite(MOSI, HIGH);
 | 
						digitalWrite(MOSI, HIGH);
 | 
				
			||||||
	digitalWrite(MISO, HIGH);
 | 
						digitalWrite(MISO, HIGH);
 | 
				
			||||||
	digitalWrite(reset, LOW);
 | 
						digitalWrite(reset, LOW);
 | 
				
			||||||
		//edip.smallProtoSelect(7);
 | 
					 | 
				
			||||||
		//edip.setNewColor(EA_GREY, 0xe3, 0xe3,0xe3);	 // redefine r-g-b-values of EA_GREY 
 | 
					 | 
				
			||||||
		//edip.drawImage(0,50,FASTTUBE_LOGO_PNG);
 | 
					 | 
				
			||||||
	digitalWrite(reset,HIGH);
 | 
						digitalWrite(reset,HIGH);
 | 
				
			||||||
	tft.begin(115200);  // start display communication
 | 
						tft.begin(115200);  // start display communication
 | 
				
			||||||
	/*int h = 20;
 | 
					 | 
				
			||||||
	char charh[2];
 | 
					 | 
				
			||||||
	String strh = String(h);
 | 
					 | 
				
			||||||
	strh.toCharArray(charh,2);
 | 
					 | 
				
			||||||
	tft.DisplayLight(charh);*/
 | 
					 | 
				
			||||||
	tft.cursorOn(false);
 | 
						tft.cursorOn(false);
 | 
				
			||||||
	tft.terminalOn(false);
 | 
						tft.terminalOn(false);
 | 
				
			||||||
	tft.setDisplayColor(EA_WHITE,EA_BLACK);
 | 
						tft.setDisplayColor(EA_WHITE,EA_BLACK);
 | 
				
			||||||
	tft.setTextColor(EA_WHITE,EA_BLACK);
 | 
						tft.setTextColor(EA_WHITE,EA_TRANSPARENT);
 | 
				
			||||||
	//tft.setTextFont('4');
 | 
					 | 
				
			||||||
	tft.setTextSize(5,8);
 | 
						tft.setTextSize(5,8);
 | 
				
			||||||
	tft.clear();
 | 
						tft.clear();
 | 
				
			||||||
	//tft.displayLight('30');
 | 
						
 | 
				
			||||||
	tft.drawText(0, 14, 'C', "FaSTTUBe");  //draw some text
 | 
						gear_box.update_label("GEAR");
 | 
				
			||||||
	//tft.loadImage(0,0,1);
 | 
						left_box.update_label("SPEED");
 | 
				
			||||||
	//delay(2000);
 | 
						right_box.update_label("RPM");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
double get_value(int a){
 | 
					String get_value(Value val) {
 | 
				
			||||||
	double value;
 | 
						switch (val) {
 | 
				
			||||||
	if (a == 0){ 
 | 
						case VAL_GEAR:
 | 
				
			||||||
		value = Vehicle_data.gear;
 | 
							return String(Vehicle_data.gear);
 | 
				
			||||||
	//}else if (a == 11){
 | 
						case VAL_RPM:
 | 
				
			||||||
	//	value = Stw_data.i;
 | 
							return String(Vehicle_data.revol);
 | 
				
			||||||
	//}else if (a == 1){
 | 
					    case VAL_UBATT:
 | 
				
			||||||
	//	value = Vehicle_data.revol/2; 
 | 
							return String(0.0706949 * Vehicle_data.u_batt, 2);
 | 
				
			||||||
	}else if (a == 1){		
 | 
						case VAL_TMOT:
 | 
				
			||||||
		value = Vehicle_data.t_mot-40;
 | 
							return String(Vehicle_data.t_mot - 40);
 | 
				
			||||||
	}else if (a == 5){
 | 
						case VAL_TAIR:
 | 
				
			||||||
		value = 0.0706949*Vehicle_data.u_batt;
 | 
							return String(Vehicle_data.t_air - 40);
 | 
				
			||||||
	}else if (a == 7){
 | 
						case VAL_TOIL:
 | 
				
			||||||
		value = Vehicle_data.t_air-40;
 | 
							return String(Vehicle_data.t_oil - 40);
 | 
				
			||||||
	}else if(a == 10){
 | 
						case VAL_ERR_TYPE:
 | 
				
			||||||
		value = Stw_data.error_type;
 | 
							return String(Stw_data.error_type);
 | 
				
			||||||
	}else if (a == 2){		
 | 
						case VAL_PWAT:
 | 
				
			||||||
		value = Vehicle_data.t_oil-40;
 | 
							return String(0.0514*Vehicle_data.p_wat, 2);
 | 
				
			||||||
	}else if (a == 6){
 | 
						case VAL_POIL:
 | 
				
			||||||
		value = 0.0514*Vehicle_data.p_wat;
 | 
							return String(0.0514*Vehicle_data.p_oil, 2);
 | 
				
			||||||
	//}else if (a == 7){		
 | 
						case VAL_PBF:
 | 
				
			||||||
	//	value = 0.0514*Vehicle_data.p_fuel;
 | 
							return String(Vehicle_data.p_brake_front);
 | 
				
			||||||
	}else if (a == 3){		
 | 
						case VAL_PBR:
 | 
				
			||||||
		value = 0.0514*Vehicle_data.p_oil;
 | 
							return String(Vehicle_data.p_brake_rear);
 | 
				
			||||||
	}else if (a == 8){		
 | 
						case VAL_SPEED_FL:
 | 
				
			||||||
		value = Vehicle_data.p_brake_front;
 | 
							return String(Vehicle_data.speed_fl);
 | 
				
			||||||
	}else if (a == 9){		
 | 
						case VAL_SPEED_FR:
 | 
				
			||||||
		value = Vehicle_data.p_brake_rear;
 | 
							return String(Vehicle_data.speed_fr);
 | 
				
			||||||
	}else if(a == 4){
 | 
						case VAL_SPEED:
 | 
				
			||||||
		value = 200*Vehicle_data.p_brake_front/(Vehicle_data.p_brake_rear+(2*Vehicle_data.p_brake_front));
 | 
							return String(Vehicle_data.speed);
 | 
				
			||||||
	}else if (a == 11){		
 | 
						default:
 | 
				
			||||||
		value = Vehicle_data.speed_fl;
 | 
							return "???";
 | 
				
			||||||
	}else if (a == 12){		
 | 
					 | 
				
			||||||
		value = Vehicle_data.speed_fr;
 | 
					 | 
				
			||||||
	}else if(a == 13){
 | 
					 | 
				
			||||||
		value = Vehicle_data.speed;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return value;
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					String get_label(Value val) {
 | 
				
			||||||
 | 
						switch (val) {
 | 
				
			||||||
 | 
						case VAL_GEAR:
 | 
				
			||||||
 | 
							return "GEAR";
 | 
				
			||||||
 | 
						case VAL_RPM:
 | 
				
			||||||
 | 
							return "RPM";
 | 
				
			||||||
 | 
					    case VAL_UBATT:
 | 
				
			||||||
 | 
							return "BATT VOLTAGE";
 | 
				
			||||||
 | 
						case VAL_TMOT:
 | 
				
			||||||
 | 
							return "TEMP ENG";
 | 
				
			||||||
 | 
						case VAL_TAIR:
 | 
				
			||||||
 | 
							return "TEMP AIR";
 | 
				
			||||||
 | 
						case VAL_TOIL:
 | 
				
			||||||
 | 
							return "TEMP OIL";
 | 
				
			||||||
 | 
						case VAL_ERR_TYPE:
 | 
				
			||||||
 | 
							return "ERROR TYPE";
 | 
				
			||||||
 | 
						case VAL_PWAT:
 | 
				
			||||||
 | 
							return "PRESS WAT";
 | 
				
			||||||
 | 
						case VAL_POIL:
 | 
				
			||||||
 | 
							return "PRESS OIL";
 | 
				
			||||||
 | 
						case VAL_PBF:
 | 
				
			||||||
 | 
							return "PRESS BRAKE F";
 | 
				
			||||||
 | 
						case VAL_PBR:
 | 
				
			||||||
 | 
							return "PRESS BRAKE R";
 | 
				
			||||||
 | 
						case VAL_SPEED_FL:
 | 
				
			||||||
 | 
							return "SPEED FL";
 | 
				
			||||||
 | 
						case VAL_SPEED_FR:
 | 
				
			||||||
 | 
							return "SPEED FR";
 | 
				
			||||||
 | 
						case VAL_SPEED:
 | 
				
			||||||
 | 
							return "SPEED";
 | 
				
			||||||
 | 
						default:
 | 
				
			||||||
 | 
							return "???";
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool check_alarms() {
 | 
				
			||||||
 | 
						static uint32_t poil_last_valid, tmot_last_valid, toil_last_valid;
 | 
				
			||||||
 | 
						uint32_t now = millis();
 | 
				
			||||||
 | 
						if (Vehicle_data.p_oil >= POIL_ALARM_THRESH || Vehicle_data.speed == 0) {
 | 
				
			||||||
 | 
							poil_last_valid = now;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (Vehicle_data.t_mot <= TMOT_ALARM_THRESH || Vehicle_data.t_mot == TMOT_SAFE_VALUE) {
 | 
				
			||||||
 | 
							tmot_last_valid = now;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (Vehicle_data.t_oil <= TOIL_ALARM_THRESH) {
 | 
				
			||||||
 | 
							toil_last_valid = now;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						bool poil_alarm = now - poil_last_valid >= POIL_ALARM_TIME;
 | 
				
			||||||
 | 
						bool tmot_alarm = now - tmot_last_valid >= TMOT_ALARM_TIME;
 | 
				
			||||||
 | 
						bool toil_alarm = now - toil_last_valid >= TOIL_ALARM_TIME;
 | 
				
			||||||
 | 
						bool alarm_active = poil_alarm || tmot_alarm || toil_alarm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (alarm_active) {
 | 
				
			||||||
 | 
							String alarm_text = "";
 | 
				
			||||||
 | 
							if (poil_alarm) alarm_text += "PO";
 | 
				
			||||||
 | 
							if (tmot_alarm) alarm_text += "TM";
 | 
				
			||||||
 | 
							if (toil_alarm) alarm_text += "TO";
 | 
				
			||||||
 | 
							alarm(alarm_text);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return alarm_active;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool check_enc_displays() {
 | 
				
			||||||
 | 
						static uint8_t trc_old, mode_old;
 | 
				
			||||||
 | 
						static bool display_trc, display_mode;
 | 
				
			||||||
 | 
						static uint32_t display_trc_begin, display_mode_begin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return check_display(trc_old, Stw_data.trc, display_trc, display_trc_begin, "ARB") ||
 | 
				
			||||||
 | 
							check_display(mode_old, Stw_data.mode, display_mode, display_mode_begin, "MODE");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool check_display(uint8_t& val_old, uint8_t val_new, bool& active, uint32_t& begin, const String& title) {
 | 
				
			||||||
 | 
						if (val_old != val_new) {
 | 
				
			||||||
 | 
							active = true;
 | 
				
			||||||
 | 
							begin = millis();
 | 
				
			||||||
 | 
							val_old = val_new;
 | 
				
			||||||
 | 
							tft.clear();
 | 
				
			||||||
 | 
							tft.fillDisplayColor(EA_RED);
 | 
				
			||||||
 | 
							tft.setTextColor(EA_WHITE, EA_RED);
 | 
				
			||||||
 | 
							tft.setTextSize(7,8);
 | 
				
			||||||
 | 
							String text = title + ":" + val_new;
 | 
				
			||||||
 | 
							char text_arr[16];
 | 
				
			||||||
 | 
							text.toCharArray(text_arr, 16);
 | 
				
			||||||
 | 
							tft.drawText(15, 68, 'C', text_arr);
 | 
				
			||||||
 | 
						} else if (active && millis() - begin > ENC_DISPLAY_TIME) {
 | 
				
			||||||
 | 
							tft.setTextColor(EA_WHITE, EA_TRANSPARENT);
 | 
				
			||||||
 | 
							tft.clear();
 | 
				
			||||||
 | 
							active = false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return active;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void update_display(){
 | 
					void update_display(){
 | 
				
			||||||
	if(((millis()-poiltimer)>=20000) and poilbool){
 | 
						if (check_alarms()) {
 | 
				
			||||||
		poilbool = false;
 | 
							return;
 | 
				
			||||||
		alarm("P_oil");
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if(((millis()-tmottimer)>=20000) and tmotbool){
 | 
						if (tft.disconnected) {
 | 
				
			||||||
		tmotbool = false;
 | 
							return;
 | 
				
			||||||
		alarm("T_mot");
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if(((millis()-toiltimer)>=10000) and toilbool){
 | 
					 | 
				
			||||||
		toilbool = false;
 | 
					 | 
				
			||||||
		alarm("T_oil");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if((0.0514*Vehicle_data.p_oil)>=0,1 or Vehicle_data.speed == 0){
 | 
					 | 
				
			||||||
		poiltimer = millis();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(((Vehicle_data.t_mot - 40) <= 0x69) or ((Vehicle_data.t_mot - 40)==0xC8)){
 | 
					 | 
				
			||||||
		tmottimer = millis();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if((Vehicle_data.t_oil - 40) <= 0x96){
 | 
					 | 
				
			||||||
		toiltimer = millis();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(Stw_data.buttonState1 & Stw_data.buttonState4){
 | 
					 | 
				
			||||||
		alarm("");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(!tft.disconnected){
 | 
					 | 
				
			||||||
		tft.cursorOn(false);
 | 
					 | 
				
			||||||
		if(trcalt!=Stw_data.trc or trctimer == true or Stw_data.buttonStateEnc1 == HIGH){
 | 
					 | 
				
			||||||
			display_trc();
 | 
					 | 
				
			||||||
		}else if(modealt!=Stw_data.mode or modetimer == true or Stw_data.buttonStateEnc2 == HIGH){
 | 
					 | 
				
			||||||
			display_mode();
 | 
					 | 
				
			||||||
		}else{
 | 
					 | 
				
			||||||
			if(clearcounter>=56){
 | 
					 | 
				
			||||||
				tft.clear();
 | 
					 | 
				
			||||||
				clearcounter = 0;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			clearcounter+=1;
 | 
					 | 
				
			||||||
			if(Stw_data.buttonState4){
 | 
					 | 
				
			||||||
				if(Stw_data.displayindex>=sizeof(bezeichnungen)/sizeof(String)-3){
 | 
					 | 
				
			||||||
					Stw_data.displayindex = 0;
 | 
					 | 
				
			||||||
					delay(250);
 | 
					 | 
				
			||||||
				}else{
 | 
					 | 
				
			||||||
					Stw_data.displayindex+=1;
 | 
					 | 
				
			||||||
					delay(250);
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if(Stw_data.buttonState1){
 | 
					 | 
				
			||||||
				if(Stw_data.displayindex<=0){
 | 
					 | 
				
			||||||
					Stw_data.displayindex = sizeof(bezeichnungen)/sizeof(String)-3;
 | 
					 | 
				
			||||||
					delay(250);
 | 
					 | 
				
			||||||
				}else{
 | 
					 | 
				
			||||||
					Stw_data.displayindex-=1;
 | 
					 | 
				
			||||||
					delay(250);
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if(vergleichsindex!=Stw_data.displayindex){
 | 
					 | 
				
			||||||
				tft.clear();
 | 
					 | 
				
			||||||
				vergleichsindex=Stw_data.displayindex;
 | 
					 | 
				
			||||||
			}	
 | 
					 | 
				
			||||||
			int a = sizeof(bezeichnungen[Stw_data.displayindex]);
 | 
					 | 
				
			||||||
			int g = sizeof(bezeichnungen[Stw_data.displayindex+1]);
 | 
					 | 
				
			||||||
			int h = sizeof(bezeichnungen[Stw_data.displayindex+2]);
 | 
					 | 
				
			||||||
			char d[a];
 | 
					 | 
				
			||||||
			char e[g];
 | 
					 | 
				
			||||||
			char f[h];
 | 
					 | 
				
			||||||
			bezeichnungen[Stw_data.displayindex].toCharArray(d,a);
 | 
					 | 
				
			||||||
			bezeichnungen[Stw_data.displayindex+1].toCharArray(e,g);
 | 
					 | 
				
			||||||
			bezeichnungen[Stw_data.displayindex+2].toCharArray(f,h);
 | 
					 | 
				
			||||||
			char b[2];
 | 
					 | 
				
			||||||
			char c[5];
 | 
					 | 
				
			||||||
			char i[5];
 | 
					 | 
				
			||||||
			char j[5];
 | 
					 | 
				
			||||||
			char k[5];
 | 
					 | 
				
			||||||
			char m[5];
 | 
					 | 
				
			||||||
			String str=String(int(get_value(0)));
 | 
					 | 
				
			||||||
			if(str.equals(String(0))){
 | 
					 | 
				
			||||||
				str = "N";
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			String str1;
 | 
					 | 
				
			||||||
			String str2;
 | 
					 | 
				
			||||||
			String str3;
 | 
					 | 
				
			||||||
			if(Stw_data.displayindex+1==0 or Stw_data.displayindex+1==2 or Stw_data.displayindex+1==1 or Stw_data.displayindex+1==10 or Stw_data.displayindex+1==7 or Stw_data.displayindex+1==11 or Stw_data.displayindex+1==12 or Stw_data.displayindex+1==13){
 | 
					 | 
				
			||||||
				str1=String(int(get_value(Stw_data.displayindex+1)));	
 | 
					 | 
				
			||||||
			}else{
 | 
					 | 
				
			||||||
				str1=String(get_value(Stw_data.displayindex+1));
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if(Stw_data.displayindex+1 == 10){
 | 
					 | 
				
			||||||
				if(str1.equals(String(1))){
 | 
					 | 
				
			||||||
					str1 = "PC";
 | 
					 | 
				
			||||||
				}else if(str1.equals(String(2))){
 | 
					 | 
				
			||||||
					str1 = "BSE";
 | 
					 | 
				
			||||||
				}else if(str1.equals(String(3))){
 | 
					 | 
				
			||||||
					str1 = "APS";
 | 
					 | 
				
			||||||
				}else if(str1.equals(String(4))){
 | 
					 | 
				
			||||||
					str1 = "ETB";
 | 
					 | 
				
			||||||
				}else if(str1.equals(String(0))){
 | 
					 | 
				
			||||||
					str1 = "None";
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if(Stw_data.displayindex+2==0 or Stw_data.displayindex+2==2 or Stw_data.displayindex+2==1 or Stw_data.displayindex+2==10 or Stw_data.displayindex+2==7 or Stw_data.displayindex+2==11 or Stw_data.displayindex+2==12 or Stw_data.displayindex+2==13){
 | 
					 | 
				
			||||||
				str2=String(int(get_value(Stw_data.displayindex+2)));
 | 
					 | 
				
			||||||
			}else{
 | 
					 | 
				
			||||||
				str2=String(get_value(Stw_data.displayindex+2));
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if(Stw_data.displayindex+2 == 10){
 | 
					 | 
				
			||||||
				if(str2.equals(String(1))){
 | 
					 | 
				
			||||||
					str2 = "PC";
 | 
					 | 
				
			||||||
				}else if(str2.equals(String(2))){
 | 
					 | 
				
			||||||
					str2 = "BSE";
 | 
					 | 
				
			||||||
				}else if(str2.equals(String(3))){
 | 
					 | 
				
			||||||
					str2 = "APS";
 | 
					 | 
				
			||||||
				}else if(str2.equals(String(4))){
 | 
					 | 
				
			||||||
					str2 = "ETB";
 | 
					 | 
				
			||||||
				}else if(str2.equals(String(0))){
 | 
					 | 
				
			||||||
					str2 = "None";
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if(Stw_data.displayindex+3==0 or Stw_data.displayindex+3==2 or Stw_data.displayindex+3==1 or Stw_data.displayindex+3==10 or Stw_data.displayindex+3==7 or Stw_data.displayindex+3==11 or Stw_data.displayindex+3==12 or Stw_data.displayindex+3==13){
 | 
					 | 
				
			||||||
				str3=String(int(get_value(Stw_data.displayindex+3)));
 | 
					 | 
				
			||||||
			}else{
 | 
					 | 
				
			||||||
				str3=String(get_value(Stw_data.displayindex+3));
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if(Stw_data.displayindex+3 == 10){
 | 
					 | 
				
			||||||
				if(str3.equals(String(1))){
 | 
					 | 
				
			||||||
					str3 = "PC";
 | 
					 | 
				
			||||||
				}else if(str3.equals(String(2))){
 | 
					 | 
				
			||||||
					str3 = "BSE";
 | 
					 | 
				
			||||||
				}else if(str3.equals(String(3))){
 | 
					 | 
				
			||||||
					str3 = "APS";
 | 
					 | 
				
			||||||
				}else if(str3.equals(String(4))){
 | 
					 | 
				
			||||||
					str3 = "ETB";
 | 
					 | 
				
			||||||
				}else if(str3.equals(String(0))){
 | 
					 | 
				
			||||||
					str3 = "None";
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			String str5=String(Vehicle_data.revol/2);
 | 
					 | 
				
			||||||
			String str4=String(0.0514*Vehicle_data.p_fuel);
 | 
					 | 
				
			||||||
			str.toCharArray(b,2);
 | 
					 | 
				
			||||||
			str1.toCharArray(c,5);
 | 
					 | 
				
			||||||
			str2.toCharArray(i,5);
 | 
					 | 
				
			||||||
			str3.toCharArray(j,5);
 | 
					 | 
				
			||||||
			str4.toCharArray(k,5);
 | 
					 | 
				
			||||||
			str5.toCharArray(m,5);
 | 
					 | 
				
			||||||
			sizeaneu = strlen(c);
 | 
					 | 
				
			||||||
			sizebneu = strlen(i);
 | 
					 | 
				
			||||||
			sizecneu = strlen(j);
 | 
					 | 
				
			||||||
			sizedneu = strlen(k);
 | 
					 | 
				
			||||||
			sizeeneu = strlen(m);
 | 
					 | 
				
			||||||
			if(sizeaalt!=sizeaneu){
 | 
					 | 
				
			||||||
				tft.clear();
 | 
					 | 
				
			||||||
				sizeaalt=sizeaneu;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if(sizebalt!=sizebneu){
 | 
					 | 
				
			||||||
				tft.clear();
 | 
					 | 
				
			||||||
				sizebalt=sizebneu;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if(sizecalt!=sizecneu){
 | 
					 | 
				
			||||||
				tft.clear();
 | 
					 | 
				
			||||||
				sizecalt=sizecneu;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if(sizedalt!=sizedneu){
 | 
					 | 
				
			||||||
				tft.clear();
 | 
					 | 
				
			||||||
				sizedalt=sizedneu;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if(sizeealt!=sizeeneu){
 | 
					 | 
				
			||||||
				tft.clear();
 | 
					 | 
				
			||||||
				sizeealt=sizeeneu;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			tft.setTextSize(6,8);
 | 
					 | 
				
			||||||
			tft.drawText(132, 0, 'L', b);
 | 
					 | 
				
			||||||
			tft.setTextSize(2,7);
 | 
					 | 
				
			||||||
			tft.drawText(10, 20, 'L', k);
 | 
					 | 
				
			||||||
			tft.drawText(240, 20, 'L', m);
 | 
					 | 
				
			||||||
			tft.drawText(10,130, 'L', c);
 | 
					 | 
				
			||||||
			tft.drawText(120, 130, 'L', i);
 | 
					 | 
				
			||||||
			tft.drawText(240,130, 'L', j);
 | 
					 | 
				
			||||||
			tft.setTextSize(1,1);	
 | 
					 | 
				
			||||||
			tft.drawText(136,116, 'L', "Gang");
 | 
					 | 
				
			||||||
			tft.drawText(10,116, 'L', "P_fuel");
 | 
					 | 
				
			||||||
			tft.drawText(240,116, 'L', "Drehzahl");
 | 
					 | 
				
			||||||
			tft.drawText(10,226, 'L', d);
 | 
					 | 
				
			||||||
			tft.drawText(120,226, 'L', e);
 | 
					 | 
				
			||||||
			tft.drawText(240,226, 'L', f);
 | 
					 | 
				
			||||||
			/*if (cleaner){
 | 
					 | 
				
			||||||
				tft.setTextSize(5,8);
 | 
					 | 
				
			||||||
				tft.drawText(0, 14, 'C', "FaSTTUBe");  // draw some text
 | 
					 | 
				
			||||||
				tft.setTextSize(4,4);
 | 
					 | 
				
			||||||
				tft.drawText(24, 120, 'C', "insert coin");  // draw some text
 | 
					 | 
				
			||||||
				tft.drawText(0, 180, 'C', "to continue");
 | 
					 | 
				
			||||||
				cleaner = false;
 | 
					 | 
				
			||||||
			}else{
 | 
					 | 
				
			||||||
				tft.setTextSize(5,8);
 | 
					 | 
				
			||||||
				tft.drawText(0, 14, 'C', "FaSTTUBe");  // draw some text
 | 
					 | 
				
			||||||
				tft.setTextSize(4,4);
 | 
					 | 
				
			||||||
				tft.drawText(24, 120, 'C', "              ");  // draw some text
 | 
					 | 
				
			||||||
				tft.drawText(0, 180, 'C', "              ");
 | 
					 | 
				
			||||||
				cleaner = true;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			delay(80);*/
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void display_trc(){
 | 
						if (check_enc_displays()) {
 | 
				
			||||||
	if(trcalt!=Stw_data.trc or Stw_data.buttonStateEnc1 == HIGH){
 | 
							return;
 | 
				
			||||||
		tft.clear();
 | 
					 | 
				
			||||||
		tft.setTextSize(7,8);
 | 
					 | 
				
			||||||
		tft.setDisplayColor(EA_WHITE,EA_RED);
 | 
					 | 
				
			||||||
		tft.setTextColor(EA_WHITE,EA_RED);
 | 
					 | 
				
			||||||
		char trcanzeige[7];
 | 
					 | 
				
			||||||
		String str = String("ARB:");
 | 
					 | 
				
			||||||
		if(Stw_data.trc==11){
 | 
					 | 
				
			||||||
			str+="ED";
 | 
					 | 
				
			||||||
		}else{
 | 
					 | 
				
			||||||
			str+=String(Stw_data.trc);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		str.toCharArray(trcanzeige,7);
 | 
					 | 
				
			||||||
		tft.drawText(0,0,'L',"            ");
 | 
					 | 
				
			||||||
		tft.drawText(0,60,'L',"            ");
 | 
					 | 
				
			||||||
		tft.drawText(0,120,'L',"            ");
 | 
					 | 
				
			||||||
		tft.drawText(0,180,'L',"            ");
 | 
					 | 
				
			||||||
		tft.drawText(15,68,'L',trcanzeige);
 | 
					 | 
				
			||||||
		trccounter = 0;
 | 
					 | 
				
			||||||
		trcalt = Stw_data.trc;
 | 
					 | 
				
			||||||
		trctimer = true;
 | 
					 | 
				
			||||||
	}else if(trccounter >= 255){
 | 
					 | 
				
			||||||
		tft.setDisplayColor(EA_WHITE,EA_BLACK);
 | 
					 | 
				
			||||||
		tft.setTextColor(EA_WHITE,EA_BLACK);
 | 
					 | 
				
			||||||
		tft.clear();
 | 
					 | 
				
			||||||
		trctimer = false;
 | 
					 | 
				
			||||||
	}else{
 | 
					 | 
				
			||||||
		trccounter+=1;
 | 
					 | 
				
			||||||
		delay(5);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void display_mode(){
 | 
						static DisplayPage page = PAGE_DRIVER;
 | 
				
			||||||
	if(modealt!=Stw_data.mode or Stw_data.buttonStateEnc2 == HIGH){
 | 
						static uint32_t last_cleared;
 | 
				
			||||||
 | 
						static bool cleared = true;
 | 
				
			||||||
 | 
						uint32_t now = millis();
 | 
				
			||||||
 | 
						if(Stw_data.button1_rises > 0){
 | 
				
			||||||
 | 
							Stw_data.button1_rises--;
 | 
				
			||||||
 | 
							page = (DisplayPage) ((page + 1) % DISPLAY_PAGES);
 | 
				
			||||||
		tft.clear();
 | 
							tft.clear();
 | 
				
			||||||
		tft.setTextSize(6,8);
 | 
							last_cleared = now;
 | 
				
			||||||
		tft.setDisplayColor(EA_WHITE,EA_RED);
 | 
							cleared = true;
 | 
				
			||||||
		tft.setTextColor(EA_WHITE,EA_RED);
 | 
						}
 | 
				
			||||||
		char modeanzeige[7];
 | 
					
 | 
				
			||||||
		String str = String("MODE:");
 | 
						if (now - last_cleared >= DISP_CLEAR_INTERVAL) {
 | 
				
			||||||
		str+=String(Stw_data.mode);
 | 
					 | 
				
			||||||
		str.toCharArray(modeanzeige,7);
 | 
					 | 
				
			||||||
		tft.drawText(0,0,'L',"            ");
 | 
					 | 
				
			||||||
		tft.drawText(0,60,'L',"            ");
 | 
					 | 
				
			||||||
		tft.drawText(0,120,'L',"            ");
 | 
					 | 
				
			||||||
		tft.drawText(0,180,'L',"            ");
 | 
					 | 
				
			||||||
		tft.drawText(15,68,'L',modeanzeige);
 | 
					 | 
				
			||||||
		modecounter = 0;
 | 
					 | 
				
			||||||
		modealt = Stw_data.mode;
 | 
					 | 
				
			||||||
		modetimer = true;
 | 
					 | 
				
			||||||
	}else if(modecounter >= 255){
 | 
					 | 
				
			||||||
		tft.setDisplayColor(EA_WHITE,EA_BLACK);
 | 
					 | 
				
			||||||
		tft.setTextColor(EA_WHITE,EA_BLACK);
 | 
					 | 
				
			||||||
		tft.clear();
 | 
							tft.clear();
 | 
				
			||||||
		modetimer = false;
 | 
							last_cleared = now;
 | 
				
			||||||
	}else{
 | 
							cleared = true;
 | 
				
			||||||
		modecounter+=1;
 | 
						}
 | 
				
			||||||
		delay(5);
 | 
					
 | 
				
			||||||
 | 
						if (page == PAGE_DRIVER) {
 | 
				
			||||||
 | 
							if (cleared) {
 | 
				
			||||||
 | 
								redraw_page_driver();
 | 
				
			||||||
 | 
								cleared = false;
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								update_page_driver();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							if (cleared) {
 | 
				
			||||||
 | 
								redraw_page_testing();
 | 
				
			||||||
 | 
								cleared = false;
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								update_page_testing();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -400,7 +245,134 @@ void alarm(String textstr){
 | 
				
			|||||||
		delay(100);
 | 
							delay(100);
 | 
				
			||||||
		if(Stw_data.buttonState1 & Stw_data.buttonState4){
 | 
							if(Stw_data.buttonState1 & Stw_data.buttonState4){
 | 
				
			||||||
			x=0;
 | 
								x=0;
 | 
				
			||||||
			tft.setTextColor(EA_WHITE,EA_BLACK);
 | 
								tft.setTextColor(EA_WHITE,EA_TRANSPARENT);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void redraw_page_driver() {
 | 
				
			||||||
 | 
						// Boxes
 | 
				
			||||||
 | 
						tft.drawLine(0, 110, 320, 110);
 | 
				
			||||||
 | 
						tft.drawLine(120, 0, 120, 110);
 | 
				
			||||||
 | 
						tft.drawLine(200, 0, 200, 110);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Tire temperature cross
 | 
				
			||||||
 | 
						tft.drawLine(80, 180, 240, 180);
 | 
				
			||||||
 | 
						tft.drawLine(160, 130, 160, 230);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Boxes
 | 
				
			||||||
 | 
						gear_box.redraw();
 | 
				
			||||||
 | 
						left_box.redraw();
 | 
				
			||||||
 | 
						right_box.redraw();
 | 
				
			||||||
 | 
						fl_box.redraw();
 | 
				
			||||||
 | 
						fr_box.redraw();
 | 
				
			||||||
 | 
						rl_box.redraw();
 | 
				
			||||||
 | 
						rr_box.redraw();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void update_page_driver() {
 | 
				
			||||||
 | 
						// Top boxes
 | 
				
			||||||
 | 
						if (millis() < 2000 || millis() > 4000) {
 | 
				
			||||||
 | 
							gear_box.update_value("N");
 | 
				
			||||||
 | 
							left_box.update_label("LAPTIME");
 | 
				
			||||||
 | 
							left_box.update_value("93.13");
 | 
				
			||||||
 | 
							right_box.update_value("1234");
 | 
				
			||||||
 | 
							fl_box.update_value(2);
 | 
				
			||||||
 | 
							fr_box.update_value(40);
 | 
				
			||||||
 | 
							rl_box.update_value(55);
 | 
				
			||||||
 | 
							rr_box.update_value(65);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							gear_box.update_value("3");
 | 
				
			||||||
 | 
							left_box.update_label("SPEED");
 | 
				
			||||||
 | 
							left_box.update_value("313");
 | 
				
			||||||
 | 
							right_box.update_value("42");
 | 
				
			||||||
 | 
							fl_box.update_value(90);
 | 
				
			||||||
 | 
							fr_box.update_value(90);
 | 
				
			||||||
 | 
							rl_box.update_value(90);
 | 
				
			||||||
 | 
							rr_box.update_value(90);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Tire temperatures
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void redraw_page_testing() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void update_page_testing() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DataBox::DataBox(int x1, int y1, int x2, int y2, int text_x, int text_y, int font,
 | 
				
			||||||
 | 
					        int size_x, int size_y, uint8_t justification)
 | 
				
			||||||
 | 
						: x1{x1}, y1{y1}, x2{x2}, y2{y2}, text_x{text_x}, text_y{text_y},
 | 
				
			||||||
 | 
							font{font}, size_x{size_x}, size_y{size_y},
 | 
				
			||||||
 | 
							justification{justification}, value{""}, label{""} {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void DataBox::update_value(String val_new) {
 | 
				
			||||||
 | 
						if (!val_new.equals(value)) {
 | 
				
			||||||
 | 
							value = val_new;
 | 
				
			||||||
 | 
							redraw_value();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void DataBox::update_label(String label_new) {
 | 
				
			||||||
 | 
						if (!label_new.equals(label)) {
 | 
				
			||||||
 | 
							label = label_new;
 | 
				
			||||||
 | 
							redraw_label();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void DataBox::redraw() {
 | 
				
			||||||
 | 
						redraw_value();
 | 
				
			||||||
 | 
						redraw_label();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void DataBox::redraw_value() {
 | 
				
			||||||
 | 
						tft.setTextFont(font);
 | 
				
			||||||
 | 
						tft.setTextSize(size_x, size_y);
 | 
				
			||||||
 | 
						Serial.println("Redrawing value:");
 | 
				
			||||||
 | 
						tft.clearRect(x1, y1, x2, y2);
 | 
				
			||||||
 | 
						tft.drawText(text_x, text_y, justification, value.c_str());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void DataBox::redraw_label() {
 | 
				
			||||||
 | 
						tft.setTextFont(EA_FONT7X12);
 | 
				
			||||||
 | 
						tft.setTextSize(1, 1);
 | 
				
			||||||
 | 
						Serial.println("Redrawing label:");
 | 
				
			||||||
 | 
						tft.clearRect(x1, y2 + 1, x2, y2 + 13);
 | 
				
			||||||
 | 
						tft.drawText((x1 + x2) / 2, y2 + 1, 'C', label.c_str());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TireTempBox::TireTempBox(int x1, int y1, int x2, int y2, int text_x, int text_y,
 | 
				
			||||||
 | 
					        int font, int size_x, int size_y, uint8_t justification)
 | 
				
			||||||
 | 
						: DataBox{x1, y1, x2, y2, text_x, text_y, font, size_x, size_y, justification}, num_value{-1} {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TireTempBox::update_value(int val_new) {
 | 
				
			||||||
 | 
						if (val_new != num_value) {
 | 
				
			||||||
 | 
							num_value = val_new;
 | 
				
			||||||
 | 
							if (val_new < TT_THRESH1) {
 | 
				
			||||||
 | 
								color = TT_COL0;
 | 
				
			||||||
 | 
							} else if (val_new < TT_THRESH2) {
 | 
				
			||||||
 | 
								color = TT_COL1;
 | 
				
			||||||
 | 
							} else if (val_new < TT_THRESH3) {
 | 
				
			||||||
 | 
								color = TT_COL2;
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								color = TT_COL3;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							String val_str = String(val_new);
 | 
				
			||||||
 | 
							if (val_str.length() == 1) {
 | 
				
			||||||
 | 
								val_str = "  " + val_str;
 | 
				
			||||||
 | 
							} else if (val_str.length() == 2) {
 | 
				
			||||||
 | 
								val_str = " " + val_str;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							DataBox::update_value(val_str);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TireTempBox::redraw_value() {
 | 
				
			||||||
 | 
						tft.setTextFont(font);
 | 
				
			||||||
 | 
						tft.setTextSize(size_x, size_y);
 | 
				
			||||||
 | 
						tft.drawRectf(x1, y1, x2, y2, color);
 | 
				
			||||||
 | 
						tft.drawText(text_x, text_y, justification, value.c_str());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TireTempBox::redraw_label() {}
 | 
				
			||||||
@ -3,21 +3,93 @@
 | 
				
			|||||||
#include "FT_2018_STW_CAN.h"
 | 
					#include "FT_2018_STW_CAN.h"
 | 
				
			||||||
#include "FT18_STW_INIT.h"
 | 
					#include "FT18_STW_INIT.h"
 | 
				
			||||||
#ifndef FT18_STW_DISPLAY_h
 | 
					#ifndef FT18_STW_DISPLAY_h
 | 
				
			||||||
	#define FT18_STW_DISPLAY_h
 | 
					#define FT18_STW_DISPLAY_h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	#define MOSI			75
 | 
					#define MOSI			75
 | 
				
			||||||
	#define MISO			74
 | 
					#define MISO			74
 | 
				
			||||||
	#define CLK				76
 | 
					#define CLK				76
 | 
				
			||||||
	#define disp_cs			42
 | 
					#define disp_cs			42
 | 
				
			||||||
	#define reset 			43
 | 
					#define reset 			43
 | 
				
			||||||
	#define writeprotect 	52
 | 
					#define writeprotect 	52
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void init_display(void);
 | 
					#define POIL_ALARM_THRESH ((uint32_t) (0.1 / 0.0514))
 | 
				
			||||||
	void update_display(void);
 | 
					#define POIL_ALARM_TIME 20000 // ms
 | 
				
			||||||
	double get_value(int a);
 | 
					#define TMOT_ALARM_THRESH (40 + 105)
 | 
				
			||||||
	void display_trc(void);
 | 
					#define TMOT_SAFE_VALUE (40 + 200)
 | 
				
			||||||
	void display_mode(void);
 | 
					#define TMOT_ALARM_TIME 20000 // ms
 | 
				
			||||||
	void alarm(String text);
 | 
					#define TOIL_ALARM_THRESH (40 + 150)
 | 
				
			||||||
 | 
					#define TOIL_ALARM_TIME 10000 // ms
 | 
				
			||||||
 | 
					#define ENC_DISPLAY_TIME 1000 // ms
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum DisplayPage {PAGE_DRIVER, PAGE_TESTING};
 | 
				
			||||||
 | 
					#define DISPLAY_PAGES 2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum Value {
 | 
				
			||||||
 | 
					    VAL_GEAR, VAL_RPM, VAL_UBATT, VAL_TMOT, VAL_TAIR, VAL_TOIL, VAL_ERR_TYPE,
 | 
				
			||||||
 | 
					    VAL_PWAT, VAL_POIL, VAL_PBF, VAL_PBR, VAL_SPEED_FL, VAL_SPEED_FR, VAL_SPEED
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					#define VALUES 14
 | 
				
			||||||
 | 
					String get_value(Value val);
 | 
				
			||||||
 | 
					String get_label(Value val);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DISP_CLEAR_INTERVAL 5000 // ms
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void init_display(void);
 | 
				
			||||||
 | 
					void update_display(void);
 | 
				
			||||||
 | 
					void display_trc(void);
 | 
				
			||||||
 | 
					void display_mode(void);
 | 
				
			||||||
 | 
					void alarm(String text);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool check_alarms();
 | 
				
			||||||
 | 
					bool check_enc_displays();
 | 
				
			||||||
 | 
					bool check_display(uint8_t& val_old, uint8_t val_new, bool& active, uint32_t& begin, const String& title);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void redraw_page_driver();
 | 
				
			||||||
 | 
					void update_page_driver();
 | 
				
			||||||
 | 
					void redraw_page_testing();
 | 
				
			||||||
 | 
					void update_page_testing();
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					class DataBox {
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    DataBox(int x1, int y1, int x2, int y2, int text_x, int text_y, int font,
 | 
				
			||||||
 | 
					        int size_x, int size_y, uint8_t justification);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void update_value(String val_new);
 | 
				
			||||||
 | 
					    void update_label(String label_new);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void redraw();
 | 
				
			||||||
 | 
					    virtual void redraw_value();
 | 
				
			||||||
 | 
					    virtual void redraw_label();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					    int x1, y1, x2, y2, text_x, text_y, font, size_x, size_y;
 | 
				
			||||||
 | 
					    uint8_t justification;
 | 
				
			||||||
 | 
					    String value;
 | 
				
			||||||
 | 
					    String label;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define TT_COL0 EA_LIGHTBLUE
 | 
				
			||||||
 | 
					#define TT_COL1 EA_GREEN
 | 
				
			||||||
 | 
					#define TT_COL2 EA_ORANGE
 | 
				
			||||||
 | 
					#define TT_COL3 EA_RED
 | 
				
			||||||
 | 
					#define TT_THRESH1 50
 | 
				
			||||||
 | 
					#define TT_THRESH2 60
 | 
				
			||||||
 | 
					#define TT_THRESH3 70
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					class TireTempBox : public DataBox {
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    TireTempBox(int x1, int y1, int x2, int y2, int text_x, int text_y,
 | 
				
			||||||
 | 
					        int font, int size_x, int size_y, uint8_t justification);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void update_value(int val_new);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void redraw_value() override;
 | 
				
			||||||
 | 
					    void redraw_label() override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					    int color;
 | 
				
			||||||
 | 
					    int num_value;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		Reference in New Issue
	
	Block a user