15.02.2019. revision

Dependencies:   mbed LCD_DISCO_F469NIa SD_DISCO_F469NI BSP_DISCO_F469NIa EEPROM_DISCO_F469NI

Committer:
formulas
Date:
Wed Nov 28 12:01:20 2018 +0000
Revision:
5:4b63e6845a8e
Parent:
4:0e8413277df8
asdasd

Who changed what in which revision?

UserRevisionLine numberNew contents of line
formulas 0:38c3afd99aeb 1 #include "screen_library.h"
formulas 0:38c3afd99aeb 2
formulas 0:38c3afd99aeb 3 extern LCD_DISCO_F469NI lcd;
formulas 0:38c3afd99aeb 4 extern SD_DISCO_F469NI sd;
formulas 0:38c3afd99aeb 5 extern DigitalIn change_screen_input;
formulas 0:38c3afd99aeb 6
formulas 0:38c3afd99aeb 7 extern uint8_t screen_flag,ft_main_flag,ft_2aux_flag,change_flag;
formulas 0:38c3afd99aeb 8 extern GEAR *Gears;
formulas 0:38c3afd99aeb 9 extern IMAGE LogoBig,LogoSmall,Branko,NewYearCongat;
formulas 0:38c3afd99aeb 10
formulas 4:0e8413277df8 11 extern uint16_t Rpm0, Speed0, Gear0, Water_Temp0, Oil_Temp0, TPS0, Brakes0, MAP0, Air_Temp0, Lambda0, Volts0, Crank0;
formulas 4:0e8413277df8 12 extern uint16_t Rpm, Speed, Gear, Water_Temp, Oil_Temp, TPS, Brakes, MAP, Air_Temp, Lambda, Volts, Crank;
formulas 0:38c3afd99aeb 13 extern int FL_LVDT0, FR_LVDT0, RL_LVDT0, RR_LVDT0, FL_LVDT, FR_LVDT, RL_LVDT, RR_LVDT;
formulas 0:38c3afd99aeb 14 extern int FL_LVDT_Ref,FR_LVDT_Ref,RL_LVDT_Ref,RR_LVDT_Ref;
formulas 0:38c3afd99aeb 15 extern int LVDT_Max;
formulas 4:0e8413277df8 16 //extern float Meter_counter,Meter_counter0;
formulas 0:38c3afd99aeb 17
formulas 0:38c3afd99aeb 18 void ChangeCommand(){ //Interrupt function for registering change command
formulas 0:38c3afd99aeb 19 change_flag=1;
formulas 0:38c3afd99aeb 20 };
formulas 0:38c3afd99aeb 21
formulas 0:38c3afd99aeb 22 void ChangeScreen(){ //Changes the screen if needed.
formulas 0:38c3afd99aeb 23 switch(screen_flag){
formulas 0:38c3afd99aeb 24 case(3):
formulas 0:38c3afd99aeb 25 screen_flag=1; //Change flag to new value.
formulas 0:38c3afd99aeb 26 ft_main_flag=1; //Set flag which point that Main screne is entered.
formulas 0:38c3afd99aeb 27 SetMain(); //Set Main Screne.
formulas 0:38c3afd99aeb 28 break;
formulas 0:38c3afd99aeb 29 case(1):
formulas 0:38c3afd99aeb 30 screen_flag=2;
formulas 0:38c3afd99aeb 31 SetFirstAux();
formulas 0:38c3afd99aeb 32 break;
formulas 0:38c3afd99aeb 33 case(2):
formulas 0:38c3afd99aeb 34 screen_flag=3;
formulas 0:38c3afd99aeb 35 SetSecondAux();
formulas 0:38c3afd99aeb 36 break;
formulas 0:38c3afd99aeb 37 };
formulas 0:38c3afd99aeb 38 change_flag=0;
formulas 0:38c3afd99aeb 39 };
formulas 0:38c3afd99aeb 40
formulas 0:38c3afd99aeb 41
formulas 0:38c3afd99aeb 42
formulas 0:38c3afd99aeb 43 void SetIntro(){ // Set Intro screen
formulas 0:38c3afd99aeb 44 DrawRGBImage(LogoBig,0,0);
nemanja1994 3:a06e417a5a2c 45 wait(1);
formulas 0:38c3afd99aeb 46 };
formulas 0:38c3afd99aeb 47
formulas 0:38c3afd99aeb 48 void SetMain(){ // Set Main screen
formulas 0:38c3afd99aeb 49 //Erase previous screen
formulas 0:38c3afd99aeb 50 lcd.SetTextColor(LCD_COLOR_WHITE);
formulas 0:38c3afd99aeb 51 lcd.FillRect(0,0,800,480);
formulas 0:38c3afd99aeb 52 lcd.SetTextColor(LCD_COLOR_BLACK);
formulas 0:38c3afd99aeb 53 //Draw Main screen
formulas 0:38c3afd99aeb 54 DrawSpeedMeter();
formulas 0:38c3afd99aeb 55 DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos);
formulas 0:38c3afd99aeb 56 lcd.SetFont(&Font24);
formulas 0:38c3afd99aeb 57 lcd.DisplayStringAt(30,170,(uint8_t*)"Oil Temp",LEFT_MODE);
formulas 0:38c3afd99aeb 58 lcd.DisplayStringAt(30,320,(uint8_t*)"Water Temp",LEFT_MODE);
formulas 0:38c3afd99aeb 59 lcd.DisplayStringAt(584,170,(uint8_t*)"TPS",LEFT_MODE);
formulas 0:38c3afd99aeb 60 lcd.SetTextColor(LCD_COLOR_DARKRED);
formulas 0:38c3afd99aeb 61 lcd.FillRect(560,340,230,68);
formulas 0:38c3afd99aeb 62 lcd.SetBackColor(LCD_COLOR_DARKRED);
formulas 0:38c3afd99aeb 63 PrintString("BRAKE",50,575,350,LCD_COLOR_BLACK);
formulas 0:38c3afd99aeb 64 lcd.SetBackColor(LCD_COLOR_WHITE);
formulas 0:38c3afd99aeb 65
formulas 0:38c3afd99aeb 66 //Display initial values
formulas 0:38c3afd99aeb 67 PrintChar(Gears[Gear],GearXPos,GearYPos,LCD_COLOR_BLACK);
formulas 0:38c3afd99aeb 68 SetNumber(Oil_Temp,100,OilTempXPos,OilTempYPos,3,0,0);
formulas 0:38c3afd99aeb 69 SetNumber(Water_Temp,100,WaterTempXPos,WaterTempYPos,3,0,0);
formulas 0:38c3afd99aeb 70 SetNumber(TPS,100,TPSXPos,TPSYPos,3,0,0);
formulas 0:38c3afd99aeb 71 BrakeSignal(Brakes);
formulas 0:38c3afd99aeb 72 };
formulas 0:38c3afd99aeb 73
formulas 0:38c3afd99aeb 74
formulas 0:38c3afd99aeb 75 void SetFirstAux(){ // Set First Auxiliary screen
formulas 0:38c3afd99aeb 76 // Erase previous screen
formulas 0:38c3afd99aeb 77 lcd.SetTextColor(LCD_COLOR_WHITE);
formulas 0:38c3afd99aeb 78 lcd.FillRect(0,0,800,480);
formulas 0:38c3afd99aeb 79 lcd.SetTextColor(LCD_COLOR_BLACK);
formulas 0:38c3afd99aeb 80 //Draw First Auxiliary screen
formulas 4:0e8413277df8 81 PrintString("RPM",50,20,30,LCD_COLOR_BLACK);
formulas 2:f54f01527ebb 82 PrintString("MAP",50,20,90,LCD_COLOR_BLACK);
formulas 2:f54f01527ebb 83 PrintString("Air Temp",50,20,150,LCD_COLOR_BLACK);
formulas 2:f54f01527ebb 84 PrintString("Lambda",50,20,210,LCD_COLOR_BLACK);
formulas 2:f54f01527ebb 85 PrintString("Volts",50,20,270,LCD_COLOR_BLACK);
formulas 4:0e8413277df8 86 PrintString("Distance:",50,20,330,LCD_COLOR_BLACK);
formulas 4:0e8413277df8 87 //PrintString("",50,470,30,LCD_COLOR_BLACK);
formulas 4:0e8413277df8 88 PrintString("kPa",50,560,90,LCD_COLOR_BLACK);
formulas 4:0e8413277df8 89 PrintString("C",50,560,150,LCD_COLOR_BLACK);
formulas 4:0e8413277df8 90 PrintString("Ratio",50,560,210,LCD_COLOR_BLACK);
formulas 4:0e8413277df8 91 PrintString("V",50,560,270,LCD_COLOR_BLACK);
formulas 4:0e8413277df8 92 PrintString("km",50,560,330,LCD_COLOR_BLACK);
formulas 0:38c3afd99aeb 93 DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos);
formulas 0:38c3afd99aeb 94 //Display initial values
formulas 4:0e8413277df8 95 SetNumber(Rpm,50,RpmXPos,RpmYPos,5,0,0);
formulas 0:38c3afd99aeb 96 SetNumber(MAP,50,MAPXPos,MAPYPos,3,0,0);
formulas 0:38c3afd99aeb 97 SetNumber(Air_Temp,50,AirTempXPos,AirTempYPos,3,0,0);
nemanja1994 3:a06e417a5a2c 98 SetNumber(Lambda,50,LambdaXPos,LambdaYPos,4,1,0);
nemanja1994 3:a06e417a5a2c 99 SetNumber(Volts,50,VoltsXPos,VoltsYPos,3,2,0);
formulas 4:0e8413277df8 100 //SetNumber((int)(Meter_counter/10),50,Meter_counterXPos,Meter_counterYPos,5,3,0);
formulas 0:38c3afd99aeb 101 };
formulas 0:38c3afd99aeb 102
formulas 0:38c3afd99aeb 103
formulas 0:38c3afd99aeb 104 void SetSecondAux(){ // Set Second Auxiliary screen
formulas 0:38c3afd99aeb 105 // Erase previous screen
formulas 0:38c3afd99aeb 106 lcd.SetTextColor(LCD_COLOR_WHITE);
formulas 0:38c3afd99aeb 107 lcd.FillRect(0,0,800,480);
formulas 0:38c3afd99aeb 108 lcd.SetTextColor(LCD_COLOR_BLACK);
formulas 0:38c3afd99aeb 109 // Draw Second Auxiliary screen
formulas 0:38c3afd99aeb 110 PrintString("LVDT Sensors",50,200,20,LCD_COLOR_BLACK);
formulas 0:38c3afd99aeb 111 DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos);
formulas 0:38c3afd99aeb 112 lcd.SetTextColor(LCD_COLOR_BLACK);
formulas 0:38c3afd99aeb 113 lcd.SetFont(&Font24);
formulas 0:38c3afd99aeb 114 lcd.DisplayStringAt(FLLVDTBarXPos+25,FLLVDTBarYPos,(uint8_t*)"FL",LEFT_MODE);
formulas 0:38c3afd99aeb 115 lcd.DisplayStringAt(FRLVDTBarXPos+25,FRLVDTBarYPos,(uint8_t*)"FR",LEFT_MODE);
formulas 0:38c3afd99aeb 116 lcd.DisplayStringAt(RLLVDTBarXPos+25,RLLVDTBarYPos,(uint8_t*)"BL",LEFT_MODE);
formulas 0:38c3afd99aeb 117 lcd.DisplayStringAt(RRLVDTBarXPos+25,RRLVDTBarYPos,(uint8_t*)"BR",LEFT_MODE);
formulas 0:38c3afd99aeb 118 // Display initial values
formulas 0:38c3afd99aeb 119 SetNumber(FL_LVDT,100,FLLVDTXPos,FLLVDTYPos,3,0,1);
formulas 0:38c3afd99aeb 120 SetNumber(FR_LVDT,100,FRLVDTXPos,FRLVDTYPos,3,0,1);
formulas 0:38c3afd99aeb 121 SetNumber(RL_LVDT,100,RLLVDTXPos,RLLVDTYPos,3,0,1);
formulas 0:38c3afd99aeb 122 SetNumber(RR_LVDT,100,RRLVDTXPos,RRLVDTYPos,3,0,1);
formulas 0:38c3afd99aeb 123 UpdateLVDTScale(FL_LVDT,-100,FLLVDTBarXPos,FLLVDTBarYPos);
formulas 0:38c3afd99aeb 124 UpdateLVDTScale(FR_LVDT,-100,FRLVDTBarXPos,FRLVDTBarYPos);
formulas 0:38c3afd99aeb 125 UpdateLVDTScale(RL_LVDT,-100,RLLVDTBarXPos,RLLVDTBarYPos);
formulas 0:38c3afd99aeb 126 UpdateLVDTScale(RR_LVDT,-100,RRLVDTBarXPos,RRLVDTBarYPos);
formulas 0:38c3afd99aeb 127
formulas 0:38c3afd99aeb 128 };
formulas 0:38c3afd99aeb 129
formulas 0:38c3afd99aeb 130
formulas 0:38c3afd99aeb 131 void MainUpdate(){ // Update information in Main screen
formulas 0:38c3afd99aeb 132 lcd.SetTextColor(LCD_COLOR_BLACK);
formulas 0:38c3afd99aeb 133 switch(ft_main_flag){ // Check is main update is first time entered. If yes set Speed0 to 0 to acordingly draw update.
formulas 0:38c3afd99aeb 134 case(0):break;
formulas 0:38c3afd99aeb 135 case(1):
formulas 0:38c3afd99aeb 136 Speed0=0;
formulas 0:38c3afd99aeb 137 ft_main_flag=0; //Set flag to 0.
formulas 0:38c3afd99aeb 138 break;
formulas 0:38c3afd99aeb 139 };
formulas 0:38c3afd99aeb 140 if(Speed!=Speed0){ //Check is value is changed. If it is then update it on screen.
formulas 5:4b63e6845a8e 141 UpdateSpeedMeter((int)(Speed0/10),(int)((Speed-Speed0)/10));
formulas 0:38c3afd99aeb 142 };
formulas 0:38c3afd99aeb 143 if(Gear!=Gear0){
formulas 0:38c3afd99aeb 144 PrintChar(Gears[Gear],GearXPos,GearYPos,LCD_COLOR_BLACK);
formulas 0:38c3afd99aeb 145 };
formulas 0:38c3afd99aeb 146 if(Oil_Temp!=Oil_Temp0){
formulas 0:38c3afd99aeb 147 ChangeNumber(Oil_Temp,Oil_Temp0,100,OilTempXPos,OilTempYPos,3,0,0);
formulas 0:38c3afd99aeb 148 };
formulas 0:38c3afd99aeb 149 if(Water_Temp!=Water_Temp0){
formulas 0:38c3afd99aeb 150 ChangeNumber(Water_Temp,Water_Temp0,100,WaterTempXPos,WaterTempYPos,3,0,0);
formulas 0:38c3afd99aeb 151 };
formulas 0:38c3afd99aeb 152 if(TPS!=TPS0){
formulas 0:38c3afd99aeb 153 ChangeNumber(TPS,TPS0,100,TPSXPos,TPSYPos,3,0,0);
formulas 0:38c3afd99aeb 154 };
formulas 0:38c3afd99aeb 155 if(Brakes!=Brakes0){
formulas 0:38c3afd99aeb 156 BrakeSignal(Brakes);
formulas 0:38c3afd99aeb 157 };
formulas 0:38c3afd99aeb 158 };
formulas 0:38c3afd99aeb 159
formulas 0:38c3afd99aeb 160
formulas 0:38c3afd99aeb 161 void FirstAuxUpdate(){ // Update information in First Auxiliary screen
formulas 4:0e8413277df8 162 if (Rpm!=Rpm0){
formulas 4:0e8413277df8 163 ChangeNumber(Rpm,Rpm0,50,RpmXPos,RpmYPos,5,0,0);
formulas 0:38c3afd99aeb 164 };
formulas 0:38c3afd99aeb 165 if (MAP!=MAP0){
formulas 0:38c3afd99aeb 166 ChangeNumber(MAP,MAP0,50,MAPXPos,MAPYPos,3,0,0);
formulas 0:38c3afd99aeb 167 };
formulas 0:38c3afd99aeb 168 if (Air_Temp!=Air_Temp0){
formulas 0:38c3afd99aeb 169 ChangeNumber(Air_Temp,Air_Temp0,50,AirTempXPos,AirTempYPos,3,0,0);
formulas 0:38c3afd99aeb 170 };
formulas 0:38c3afd99aeb 171 if (Lambda!=Lambda0){
nemanja1994 3:a06e417a5a2c 172 ChangeNumber(Lambda,Lambda0,50,LambdaXPos,LambdaYPos,4,1,0);
formulas 0:38c3afd99aeb 173 };
formulas 0:38c3afd99aeb 174 if (Volts!=Volts0){
nemanja1994 3:a06e417a5a2c 175 ChangeNumber(Volts,Volts0,50,VoltsXPos,VoltsYPos,3,2,0);
formulas 0:38c3afd99aeb 176 };
formulas 4:0e8413277df8 177 //if (Meter_counter!=Meter_counter0){
formulas 4:0e8413277df8 178 // ChangeNumber((int)(Meter_counter/10),(int)(Meter_counter0/10),50,Meter_counterXPos,Meter_counterYPos,5,3,0);
formulas 4:0e8413277df8 179 //};
formulas 0:38c3afd99aeb 180 };
formulas 0:38c3afd99aeb 181
formulas 0:38c3afd99aeb 182 void SecondAuxUpdate(){ // Update information in Second Auxiliary screen
formulas 0:38c3afd99aeb 183 switch(ft_2aux_flag){ //Same as in Main.
formulas 0:38c3afd99aeb 184 case(0):break;
formulas 0:38c3afd99aeb 185 case(1):
formulas 0:38c3afd99aeb 186 FL_LVDT0=0;
formulas 0:38c3afd99aeb 187 FR_LVDT0=0;
formulas 0:38c3afd99aeb 188 RL_LVDT0=0;
formulas 0:38c3afd99aeb 189 RR_LVDT0=0;
formulas 0:38c3afd99aeb 190 ft_2aux_flag=0;
formulas 0:38c3afd99aeb 191 break;
formulas 0:38c3afd99aeb 192 };
formulas 0:38c3afd99aeb 193
formulas 0:38c3afd99aeb 194 if(FL_LVDT!=FL_LVDT0){
formulas 0:38c3afd99aeb 195 ChangeNumber(FL_LVDT,FL_LVDT0,100,FLLVDTXPos,FLLVDTYPos,3,0,1);
formulas 0:38c3afd99aeb 196 UpdateLVDTScale(FL_LVDT,FL_LVDT0,FLLVDTBarXPos,FLLVDTBarYPos);
formulas 0:38c3afd99aeb 197 };
formulas 0:38c3afd99aeb 198 if(FR_LVDT!=FR_LVDT0){
formulas 0:38c3afd99aeb 199 ChangeNumber(FR_LVDT,FR_LVDT0,100,FRLVDTXPos,FRLVDTYPos,3,0,1);
formulas 0:38c3afd99aeb 200 UpdateLVDTScale(FR_LVDT,FR_LVDT0,FRLVDTBarXPos,FRLVDTBarYPos);
formulas 0:38c3afd99aeb 201 };
formulas 0:38c3afd99aeb 202 if(RL_LVDT!=RL_LVDT0){
formulas 0:38c3afd99aeb 203 ChangeNumber(RL_LVDT,RL_LVDT0,100,RLLVDTXPos,RLLVDTYPos,3,0,1);
formulas 0:38c3afd99aeb 204 UpdateLVDTScale(RL_LVDT,RL_LVDT0,RLLVDTBarXPos,RLLVDTBarYPos);
formulas 0:38c3afd99aeb 205 };
formulas 0:38c3afd99aeb 206 if(RR_LVDT!=RR_LVDT0){
formulas 0:38c3afd99aeb 207 ChangeNumber(RR_LVDT,RR_LVDT0,100,RRLVDTXPos,RRLVDTYPos,3,0,1);
formulas 0:38c3afd99aeb 208 UpdateLVDTScale(RR_LVDT,RR_LVDT0,RRLVDTBarXPos,RRLVDTBarYPos);
formulas 0:38c3afd99aeb 209 };
formulas 0:38c3afd99aeb 210 };