![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
aa
Dependencies: mbed LCD_DISCO_F469NIa SD_DISCO_F469NI BSP_DISCO_F469NIa EEPROM_DISCO_F469NI
screen_library.cpp@6:d6e001d7cf16, 2020-02-12 (annotated)
- Committer:
- formulas
- Date:
- Wed Feb 12 18:49:12 2020 +0000
- Revision:
- 6:d6e001d7cf16
- Parent:
- 5:4b63e6845a8e
aaa
Who changed what in which revision?
User | Revision | Line number | New 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 | 6:d6e001d7cf16 | 9 | extern CHAR LogoSmallEA; |
formulas | 0:38c3afd99aeb | 10 | extern IMAGE LogoBig,LogoSmall,Branko,NewYearCongat; |
formulas | 0:38c3afd99aeb | 11 | |
formulas | 6:d6e001d7cf16 | 12 | extern uint16_t Capacity0,HV_Voltage0, Rpm0, Speed0, Gear0, Water_Temp0, Bat_Temp0, TPS0, Brakes0, MAP0, Air_Temp0, Lambda0, Volts0, Crank0; |
formulas | 6:d6e001d7cf16 | 13 | extern uint16_t Capacity,HV_Voltage, Rpm, Speed, Gear, Water_Temp, Bat_Temp, TPS, Brakes, MAP, Air_Temp, Lambda, Volts, Crank; |
formulas | 0:38c3afd99aeb | 14 | extern int FL_LVDT0, FR_LVDT0, RL_LVDT0, RR_LVDT0, FL_LVDT, FR_LVDT, RL_LVDT, RR_LVDT; |
formulas | 0:38c3afd99aeb | 15 | extern int FL_LVDT_Ref,FR_LVDT_Ref,RL_LVDT_Ref,RR_LVDT_Ref; |
formulas | 0:38c3afd99aeb | 16 | extern int LVDT_Max; |
formulas | 6:d6e001d7cf16 | 17 | extern uint8_t Acc_Temperature0[]; |
formulas | 4:0e8413277df8 | 18 | //extern float Meter_counter,Meter_counter0; |
formulas | 0:38c3afd99aeb | 19 | |
formulas | 0:38c3afd99aeb | 20 | void ChangeCommand(){ //Interrupt function for registering change command |
formulas | 0:38c3afd99aeb | 21 | change_flag=1; |
formulas | 0:38c3afd99aeb | 22 | }; |
formulas | 0:38c3afd99aeb | 23 | |
formulas | 0:38c3afd99aeb | 24 | void ChangeScreen(){ //Changes the screen if needed. |
formulas | 0:38c3afd99aeb | 25 | switch(screen_flag){ |
formulas | 0:38c3afd99aeb | 26 | case(3): |
formulas | 0:38c3afd99aeb | 27 | screen_flag=1; //Change flag to new value. |
formulas | 0:38c3afd99aeb | 28 | ft_main_flag=1; //Set flag which point that Main screne is entered. |
formulas | 0:38c3afd99aeb | 29 | SetMain(); //Set Main Screne. |
formulas | 0:38c3afd99aeb | 30 | break; |
formulas | 0:38c3afd99aeb | 31 | case(1): |
formulas | 0:38c3afd99aeb | 32 | screen_flag=2; |
formulas | 0:38c3afd99aeb | 33 | SetFirstAux(); |
formulas | 0:38c3afd99aeb | 34 | break; |
formulas | 0:38c3afd99aeb | 35 | case(2): |
formulas | 0:38c3afd99aeb | 36 | screen_flag=3; |
formulas | 0:38c3afd99aeb | 37 | SetSecondAux(); |
formulas | 0:38c3afd99aeb | 38 | break; |
formulas | 0:38c3afd99aeb | 39 | }; |
formulas | 0:38c3afd99aeb | 40 | change_flag=0; |
formulas | 0:38c3afd99aeb | 41 | }; |
formulas | 0:38c3afd99aeb | 42 | |
formulas | 0:38c3afd99aeb | 43 | |
formulas | 0:38c3afd99aeb | 44 | |
formulas | 0:38c3afd99aeb | 45 | void SetIntro(){ // Set Intro screen |
formulas | 0:38c3afd99aeb | 46 | DrawRGBImage(LogoBig,0,0); |
nemanja1994 | 3:a06e417a5a2c | 47 | wait(1); |
formulas | 0:38c3afd99aeb | 48 | }; |
formulas | 0:38c3afd99aeb | 49 | |
formulas | 0:38c3afd99aeb | 50 | void SetMain(){ // Set Main screen |
formulas | 0:38c3afd99aeb | 51 | //Erase previous screen |
formulas | 0:38c3afd99aeb | 52 | lcd.SetTextColor(LCD_COLOR_WHITE); |
formulas | 0:38c3afd99aeb | 53 | lcd.FillRect(0,0,800,480); |
formulas | 0:38c3afd99aeb | 54 | lcd.SetTextColor(LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 55 | //Draw Main screen |
formulas | 0:38c3afd99aeb | 56 | DrawSpeedMeter(); |
formulas | 6:d6e001d7cf16 | 57 | PrintChar(LogoSmallEA,LogoSmallXPos,LogoSmallYPos,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 58 | lcd.SetFont(&Font24); |
formulas | 6:d6e001d7cf16 | 59 | lcd.DisplayStringAt(30,170,(uint8_t*)"Battery Temp",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 60 | lcd.DisplayStringAt(30,320,(uint8_t*)"Water Temp",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 61 | lcd.DisplayStringAt(584,170,(uint8_t*)"TPS",LEFT_MODE); |
formulas | 6:d6e001d7cf16 | 62 | lcd.DisplayStringAt(584,320,(uint8_t*)"HVDC Voltage",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 63 | |
formulas | 0:38c3afd99aeb | 64 | //Display initial values |
formulas | 6:d6e001d7cf16 | 65 | lcd.SetTextColor(LCD_COLOR_BLACK); |
formulas | 6:d6e001d7cf16 | 66 | lcd.FillRect(CapXPos-5,CapYPos-5,210,310); |
formulas | 6:d6e001d7cf16 | 67 | lcd.FillRect(CapXPos+60,CapYPos-20,80,20); |
formulas | 6:d6e001d7cf16 | 68 | lcd.SetTextColor(LCD_COLOR_WHITE); |
formulas | 6:d6e001d7cf16 | 69 | lcd.FillRect(CapXPos,CapYPos,200,300); |
formulas | 6:d6e001d7cf16 | 70 | lcd.SetTextColor(LCD_COLOR_BLACK); |
formulas | 6:d6e001d7cf16 | 71 | UpdateCapBar(Capacity,0,CapXPos,CapYPos); |
formulas | 6:d6e001d7cf16 | 72 | SetNumber(Bat_Temp,100,BatTempXPos,BatTempYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 73 | SetNumber(Water_Temp,100,WaterTempXPos,WaterTempYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 74 | SetNumber(TPS,100,TPSXPos,TPSYPos,3,0,0); |
formulas | 6:d6e001d7cf16 | 75 | SetNumber(HV_Voltage,100,HVVXPos,HVVYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 76 | }; |
formulas | 0:38c3afd99aeb | 77 | |
formulas | 0:38c3afd99aeb | 78 | |
formulas | 0:38c3afd99aeb | 79 | void SetFirstAux(){ // Set First Auxiliary screen |
formulas | 0:38c3afd99aeb | 80 | // Erase previous screen |
formulas | 0:38c3afd99aeb | 81 | lcd.SetTextColor(LCD_COLOR_WHITE); |
formulas | 0:38c3afd99aeb | 82 | lcd.FillRect(0,0,800,480); |
formulas | 0:38c3afd99aeb | 83 | lcd.SetTextColor(LCD_COLOR_BLACK); |
formulas | 6:d6e001d7cf16 | 84 | //PrintChar(LogoSmallEA,LogoSmallXPos,LogoSmallYPos,LCD_COLOR_BLACK); |
formulas | 6:d6e001d7cf16 | 85 | /* |
formulas | 0:38c3afd99aeb | 86 | //Draw First Auxiliary screen |
formulas | 4:0e8413277df8 | 87 | PrintString("RPM",50,20,30,LCD_COLOR_BLACK); |
formulas | 2:f54f01527ebb | 88 | PrintString("MAP",50,20,90,LCD_COLOR_BLACK); |
formulas | 2:f54f01527ebb | 89 | PrintString("Air Temp",50,20,150,LCD_COLOR_BLACK); |
formulas | 2:f54f01527ebb | 90 | PrintString("Lambda",50,20,210,LCD_COLOR_BLACK); |
formulas | 2:f54f01527ebb | 91 | PrintString("Volts",50,20,270,LCD_COLOR_BLACK); |
formulas | 4:0e8413277df8 | 92 | PrintString("Distance:",50,20,330,LCD_COLOR_BLACK); |
formulas | 4:0e8413277df8 | 93 | //PrintString("",50,470,30,LCD_COLOR_BLACK); |
formulas | 4:0e8413277df8 | 94 | PrintString("kPa",50,560,90,LCD_COLOR_BLACK); |
formulas | 4:0e8413277df8 | 95 | PrintString("C",50,560,150,LCD_COLOR_BLACK); |
formulas | 4:0e8413277df8 | 96 | PrintString("Ratio",50,560,210,LCD_COLOR_BLACK); |
formulas | 4:0e8413277df8 | 97 | PrintString("V",50,560,270,LCD_COLOR_BLACK); |
formulas | 4:0e8413277df8 | 98 | PrintString("km",50,560,330,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 99 | DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos); |
formulas | 0:38c3afd99aeb | 100 | //Display initial values |
formulas | 4:0e8413277df8 | 101 | SetNumber(Rpm,50,RpmXPos,RpmYPos,5,0,0); |
formulas | 0:38c3afd99aeb | 102 | SetNumber(MAP,50,MAPXPos,MAPYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 103 | SetNumber(Air_Temp,50,AirTempXPos,AirTempYPos,3,0,0); |
nemanja1994 | 3:a06e417a5a2c | 104 | SetNumber(Lambda,50,LambdaXPos,LambdaYPos,4,1,0); |
nemanja1994 | 3:a06e417a5a2c | 105 | SetNumber(Volts,50,VoltsXPos,VoltsYPos,3,2,0); |
formulas | 4:0e8413277df8 | 106 | //SetNumber((int)(Meter_counter/10),50,Meter_counterXPos,Meter_counterYPos,5,3,0); |
formulas | 6:d6e001d7cf16 | 107 | */ |
formulas | 6:d6e001d7cf16 | 108 | DrawBatTempMap(); |
formulas | 6:d6e001d7cf16 | 109 | for (uint8_t k = 1; k <= 70; k++){ |
formulas | 6:d6e001d7cf16 | 110 | Acc_Temperature0[k] = 10; |
formulas | 6:d6e001d7cf16 | 111 | }; |
formulas | 0:38c3afd99aeb | 112 | }; |
formulas | 0:38c3afd99aeb | 113 | |
formulas | 0:38c3afd99aeb | 114 | |
formulas | 0:38c3afd99aeb | 115 | void SetSecondAux(){ // Set Second Auxiliary screen |
formulas | 0:38c3afd99aeb | 116 | // Erase previous screen |
formulas | 0:38c3afd99aeb | 117 | lcd.SetTextColor(LCD_COLOR_WHITE); |
formulas | 0:38c3afd99aeb | 118 | lcd.FillRect(0,0,800,480); |
formulas | 0:38c3afd99aeb | 119 | lcd.SetTextColor(LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 120 | // Draw Second Auxiliary screen |
formulas | 0:38c3afd99aeb | 121 | PrintString("LVDT Sensors",50,200,20,LCD_COLOR_BLACK); |
formulas | 6:d6e001d7cf16 | 122 | //DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos); |
formulas | 0:38c3afd99aeb | 123 | lcd.SetTextColor(LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 124 | lcd.SetFont(&Font24); |
formulas | 0:38c3afd99aeb | 125 | lcd.DisplayStringAt(FLLVDTBarXPos+25,FLLVDTBarYPos,(uint8_t*)"FL",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 126 | lcd.DisplayStringAt(FRLVDTBarXPos+25,FRLVDTBarYPos,(uint8_t*)"FR",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 127 | lcd.DisplayStringAt(RLLVDTBarXPos+25,RLLVDTBarYPos,(uint8_t*)"BL",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 128 | lcd.DisplayStringAt(RRLVDTBarXPos+25,RRLVDTBarYPos,(uint8_t*)"BR",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 129 | // Display initial values |
formulas | 0:38c3afd99aeb | 130 | SetNumber(FL_LVDT,100,FLLVDTXPos,FLLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 131 | SetNumber(FR_LVDT,100,FRLVDTXPos,FRLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 132 | SetNumber(RL_LVDT,100,RLLVDTXPos,RLLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 133 | SetNumber(RR_LVDT,100,RRLVDTXPos,RRLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 134 | UpdateLVDTScale(FL_LVDT,-100,FLLVDTBarXPos,FLLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 135 | UpdateLVDTScale(FR_LVDT,-100,FRLVDTBarXPos,FRLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 136 | UpdateLVDTScale(RL_LVDT,-100,RLLVDTBarXPos,RLLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 137 | UpdateLVDTScale(RR_LVDT,-100,RRLVDTBarXPos,RRLVDTBarYPos); |
formulas | 6:d6e001d7cf16 | 138 | PrintChar(LogoSmallEA,LogoSmallXPos,LogoSmallYPos,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 139 | }; |
formulas | 0:38c3afd99aeb | 140 | |
formulas | 0:38c3afd99aeb | 141 | |
formulas | 0:38c3afd99aeb | 142 | void MainUpdate(){ // Update information in Main screen |
formulas | 0:38c3afd99aeb | 143 | lcd.SetTextColor(LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 144 | 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 | 145 | case(0):break; |
formulas | 0:38c3afd99aeb | 146 | case(1): |
formulas | 0:38c3afd99aeb | 147 | Speed0=0; |
formulas | 0:38c3afd99aeb | 148 | ft_main_flag=0; //Set flag to 0. |
formulas | 0:38c3afd99aeb | 149 | break; |
formulas | 0:38c3afd99aeb | 150 | }; |
formulas | 0:38c3afd99aeb | 151 | if(Speed!=Speed0){ //Check is value is changed. If it is then update it on screen. |
formulas | 5:4b63e6845a8e | 152 | UpdateSpeedMeter((int)(Speed0/10),(int)((Speed-Speed0)/10)); |
formulas | 0:38c3afd99aeb | 153 | }; |
formulas | 6:d6e001d7cf16 | 154 | if(Capacity!=Capacity0){ |
formulas | 6:d6e001d7cf16 | 155 | UpdateCapBar(Capacity,Capacity0,CapXPos,CapYPos); |
formulas | 0:38c3afd99aeb | 156 | }; |
formulas | 6:d6e001d7cf16 | 157 | if(Bat_Temp!=Bat_Temp0){ |
formulas | 6:d6e001d7cf16 | 158 | ChangeNumber(Bat_Temp,Bat_Temp0,100,BatTempXPos,BatTempYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 159 | }; |
formulas | 0:38c3afd99aeb | 160 | if(Water_Temp!=Water_Temp0){ |
formulas | 0:38c3afd99aeb | 161 | ChangeNumber(Water_Temp,Water_Temp0,100,WaterTempXPos,WaterTempYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 162 | }; |
formulas | 0:38c3afd99aeb | 163 | if(TPS!=TPS0){ |
formulas | 0:38c3afd99aeb | 164 | ChangeNumber(TPS,TPS0,100,TPSXPos,TPSYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 165 | }; |
formulas | 6:d6e001d7cf16 | 166 | if(HV_Voltage!=HV_Voltage0){ |
formulas | 6:d6e001d7cf16 | 167 | ChangeNumber(HV_Voltage,HV_Voltage0,100,HVVXPos,HVVYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 168 | }; |
formulas | 0:38c3afd99aeb | 169 | }; |
formulas | 0:38c3afd99aeb | 170 | |
formulas | 0:38c3afd99aeb | 171 | |
formulas | 0:38c3afd99aeb | 172 | void FirstAuxUpdate(){ // Update information in First Auxiliary screen |
formulas | 6:d6e001d7cf16 | 173 | /*if (Rpm!=Rpm0){ |
formulas | 4:0e8413277df8 | 174 | ChangeNumber(Rpm,Rpm0,50,RpmXPos,RpmYPos,5,0,0); |
formulas | 0:38c3afd99aeb | 175 | }; |
formulas | 0:38c3afd99aeb | 176 | if (MAP!=MAP0){ |
formulas | 0:38c3afd99aeb | 177 | ChangeNumber(MAP,MAP0,50,MAPXPos,MAPYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 178 | }; |
formulas | 0:38c3afd99aeb | 179 | if (Air_Temp!=Air_Temp0){ |
formulas | 0:38c3afd99aeb | 180 | ChangeNumber(Air_Temp,Air_Temp0,50,AirTempXPos,AirTempYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 181 | }; |
formulas | 0:38c3afd99aeb | 182 | if (Lambda!=Lambda0){ |
nemanja1994 | 3:a06e417a5a2c | 183 | ChangeNumber(Lambda,Lambda0,50,LambdaXPos,LambdaYPos,4,1,0); |
formulas | 0:38c3afd99aeb | 184 | }; |
formulas | 0:38c3afd99aeb | 185 | if (Volts!=Volts0){ |
nemanja1994 | 3:a06e417a5a2c | 186 | ChangeNumber(Volts,Volts0,50,VoltsXPos,VoltsYPos,3,2,0); |
formulas | 0:38c3afd99aeb | 187 | }; |
formulas | 4:0e8413277df8 | 188 | //if (Meter_counter!=Meter_counter0){ |
formulas | 4:0e8413277df8 | 189 | // ChangeNumber((int)(Meter_counter/10),(int)(Meter_counter0/10),50,Meter_counterXPos,Meter_counterYPos,5,3,0); |
formulas | 4:0e8413277df8 | 190 | //}; |
formulas | 6:d6e001d7cf16 | 191 | */ |
formulas | 6:d6e001d7cf16 | 192 | UpdateBatTempMap(); |
formulas | 0:38c3afd99aeb | 193 | }; |
formulas | 0:38c3afd99aeb | 194 | |
formulas | 0:38c3afd99aeb | 195 | void SecondAuxUpdate(){ // Update information in Second Auxiliary screen |
formulas | 0:38c3afd99aeb | 196 | switch(ft_2aux_flag){ //Same as in Main. |
formulas | 0:38c3afd99aeb | 197 | case(0):break; |
formulas | 0:38c3afd99aeb | 198 | case(1): |
formulas | 0:38c3afd99aeb | 199 | FL_LVDT0=0; |
formulas | 0:38c3afd99aeb | 200 | FR_LVDT0=0; |
formulas | 0:38c3afd99aeb | 201 | RL_LVDT0=0; |
formulas | 0:38c3afd99aeb | 202 | RR_LVDT0=0; |
formulas | 0:38c3afd99aeb | 203 | ft_2aux_flag=0; |
formulas | 0:38c3afd99aeb | 204 | break; |
formulas | 0:38c3afd99aeb | 205 | }; |
formulas | 0:38c3afd99aeb | 206 | |
formulas | 0:38c3afd99aeb | 207 | if(FL_LVDT!=FL_LVDT0){ |
formulas | 0:38c3afd99aeb | 208 | ChangeNumber(FL_LVDT,FL_LVDT0,100,FLLVDTXPos,FLLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 209 | UpdateLVDTScale(FL_LVDT,FL_LVDT0,FLLVDTBarXPos,FLLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 210 | }; |
formulas | 0:38c3afd99aeb | 211 | if(FR_LVDT!=FR_LVDT0){ |
formulas | 0:38c3afd99aeb | 212 | ChangeNumber(FR_LVDT,FR_LVDT0,100,FRLVDTXPos,FRLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 213 | UpdateLVDTScale(FR_LVDT,FR_LVDT0,FRLVDTBarXPos,FRLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 214 | }; |
formulas | 0:38c3afd99aeb | 215 | if(RL_LVDT!=RL_LVDT0){ |
formulas | 0:38c3afd99aeb | 216 | ChangeNumber(RL_LVDT,RL_LVDT0,100,RLLVDTXPos,RLLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 217 | UpdateLVDTScale(RL_LVDT,RL_LVDT0,RLLVDTBarXPos,RLLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 218 | }; |
formulas | 0:38c3afd99aeb | 219 | if(RR_LVDT!=RR_LVDT0){ |
formulas | 0:38c3afd99aeb | 220 | ChangeNumber(RR_LVDT,RR_LVDT0,100,RRLVDTXPos,RRLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 221 | UpdateLVDTScale(RR_LVDT,RR_LVDT0,RRLVDTBarXPos,RRLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 222 | }; |
formulas | 0:38c3afd99aeb | 223 | }; |