![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
7 julaa
Dependencies: mbed LCD_DISCO_F469NIa SD_DISCO_F469NI BSP_DISCO_F469NIa EEPROM_DISCO_F469NI
screen_library.cpp@3:a06e417a5a2c, 2018-07-05 (annotated)
- Committer:
- nemanja1994
- Date:
- Thu Jul 05 20:18:32 2018 +0000
- Revision:
- 3:a06e417a5a2c
- Parent:
- 2:f54f01527ebb
- Child:
- 4:0e8413277df8
fhgj;
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 | 0:38c3afd99aeb | 9 | extern IMAGE LogoBig,LogoSmall,Branko,NewYearCongat; |
formulas | 0:38c3afd99aeb | 10 | |
formulas | 0:38c3afd99aeb | 11 | extern uint16_t Rpm0, Speed0, Gear0, Water_Temp0, Oil_Temp0, TPS0, Brakes0, Oil_P0, MAP0, Air_Temp0, Lambda0, Volts0, Crank0; |
formulas | 0:38c3afd99aeb | 12 | extern uint16_t Rpm, Speed, Gear, Water_Temp, Oil_Temp, TPS, Brakes, Oil_P, 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 | 2:f54f01527ebb | 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); |
nemanja1994 | 3:a06e417a5a2c | 46 | DrawRGBImage(Branko,250,50); |
nemanja1994 | 3:a06e417a5a2c | 47 | wait(3); |
formulas | 0:38c3afd99aeb | 48 | /*lcd.SetTextColor(LCD_COLOR_WHITE); |
formulas | 0:38c3afd99aeb | 49 | lcd.FillRect(0,0,800,480); |
formulas | 0:38c3afd99aeb | 50 | PrintString(" Srecnu Novu godinu ",50,70,50,LCD_COLOR_RED); |
formulas | 0:38c3afd99aeb | 51 | PrintString(" i Bozicne praznike ",50,80,110,LCD_COLOR_RED); |
formulas | 0:38c3afd99aeb | 52 | PrintString(" zeli Vam ",50,70,170,LCD_COLOR_RED); |
formulas | 0:38c3afd99aeb | 53 | PrintString("Podtim za Elektroniku",50,50,230,LCD_COLOR_RED); |
formulas | 0:38c3afd99aeb | 54 | wait(5); |
formulas | 0:38c3afd99aeb | 55 | DrawRGBImage(NewYearCongat,0,0); |
formulas | 0:38c3afd99aeb | 56 | wait(10);*/ |
formulas | 0:38c3afd99aeb | 57 | }; |
formulas | 0:38c3afd99aeb | 58 | |
formulas | 0:38c3afd99aeb | 59 | void SetMain(){ // Set Main screen |
formulas | 0:38c3afd99aeb | 60 | //Erase previous screen |
formulas | 0:38c3afd99aeb | 61 | lcd.SetTextColor(LCD_COLOR_WHITE); |
formulas | 0:38c3afd99aeb | 62 | lcd.FillRect(0,0,800,480); |
formulas | 0:38c3afd99aeb | 63 | lcd.SetTextColor(LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 64 | //Draw Main screen |
formulas | 0:38c3afd99aeb | 65 | DrawSpeedMeter(); |
formulas | 0:38c3afd99aeb | 66 | DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos); |
formulas | 0:38c3afd99aeb | 67 | lcd.SetFont(&Font24); |
formulas | 0:38c3afd99aeb | 68 | lcd.DisplayStringAt(30,170,(uint8_t*)"Oil Temp",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 69 | lcd.DisplayStringAt(30,320,(uint8_t*)"Water Temp",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 70 | lcd.DisplayStringAt(584,170,(uint8_t*)"TPS",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 71 | lcd.SetTextColor(LCD_COLOR_DARKRED); |
formulas | 0:38c3afd99aeb | 72 | lcd.FillRect(560,340,230,68); |
formulas | 0:38c3afd99aeb | 73 | lcd.SetBackColor(LCD_COLOR_DARKRED); |
formulas | 0:38c3afd99aeb | 74 | PrintString("BRAKE",50,575,350,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 75 | lcd.SetBackColor(LCD_COLOR_WHITE); |
formulas | 0:38c3afd99aeb | 76 | |
formulas | 0:38c3afd99aeb | 77 | //Display initial values |
formulas | 0:38c3afd99aeb | 78 | PrintChar(Gears[Gear],GearXPos,GearYPos,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 79 | SetNumber(Oil_Temp,100,OilTempXPos,OilTempYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 80 | SetNumber(Water_Temp,100,WaterTempXPos,WaterTempYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 81 | SetNumber(TPS,100,TPSXPos,TPSYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 82 | BrakeSignal(Brakes); |
formulas | 0:38c3afd99aeb | 83 | }; |
formulas | 0:38c3afd99aeb | 84 | |
formulas | 0:38c3afd99aeb | 85 | |
formulas | 0:38c3afd99aeb | 86 | void SetFirstAux(){ // Set First Auxiliary screen |
formulas | 0:38c3afd99aeb | 87 | // Erase previous screen |
formulas | 0:38c3afd99aeb | 88 | lcd.SetTextColor(LCD_COLOR_WHITE); |
formulas | 0:38c3afd99aeb | 89 | lcd.FillRect(0,0,800,480); |
formulas | 0:38c3afd99aeb | 90 | lcd.SetTextColor(LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 91 | //Draw First Auxiliary screen |
formulas | 2:f54f01527ebb | 92 | PrintString("Oil P",50,20,30,LCD_COLOR_BLACK); |
formulas | 2:f54f01527ebb | 93 | PrintString("MAP",50,20,90,LCD_COLOR_BLACK); |
formulas | 2:f54f01527ebb | 94 | PrintString("Air Temp",50,20,150,LCD_COLOR_BLACK); |
formulas | 2:f54f01527ebb | 95 | PrintString("Lambda",50,20,210,LCD_COLOR_BLACK); |
formulas | 2:f54f01527ebb | 96 | PrintString("Volts",50,20,270,LCD_COLOR_BLACK); |
formulas | 2:f54f01527ebb | 97 | PrintString("Crank",50,20,330,LCD_COLOR_BLACK); |
formulas | 2:f54f01527ebb | 98 | PrintString("Distance:",50,20,390,LCD_COLOR_BLACK); |
formulas | 2:f54f01527ebb | 99 | PrintString("kPa",50,470,30,LCD_COLOR_BLACK); |
formulas | 2:f54f01527ebb | 100 | PrintString("kPa",50,470,90,LCD_COLOR_BLACK); |
formulas | 2:f54f01527ebb | 101 | PrintString("C",50,470,150,LCD_COLOR_BLACK); |
nemanja1994 | 3:a06e417a5a2c | 102 | PrintString("Ratio",50,500,210,LCD_COLOR_BLACK); |
formulas | 2:f54f01527ebb | 103 | PrintString("V",50,470,270,LCD_COLOR_BLACK); |
formulas | 2:f54f01527ebb | 104 | PrintString("km",50,550,390,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 105 | DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos); |
formulas | 0:38c3afd99aeb | 106 | //Display initial values |
formulas | 0:38c3afd99aeb | 107 | SetNumber(Oil_P,50,OilPXPos,OilPYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 108 | SetNumber(MAP,50,MAPXPos,MAPYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 109 | SetNumber(Air_Temp,50,AirTempXPos,AirTempYPos,3,0,0); |
nemanja1994 | 3:a06e417a5a2c | 110 | SetNumber(Lambda,50,LambdaXPos,LambdaYPos,4,1,0); |
nemanja1994 | 3:a06e417a5a2c | 111 | SetNumber(Volts,50,VoltsXPos,VoltsYPos,3,2,0); |
formulas | 2:f54f01527ebb | 112 | ChangeCrank(Crank); |
formulas | 2:f54f01527ebb | 113 | SetNumber((int)(Meter_counter/10),50,Meter_counterXPos,Meter_counterYPos,5,3,0); |
formulas | 0:38c3afd99aeb | 114 | }; |
formulas | 0:38c3afd99aeb | 115 | |
formulas | 0:38c3afd99aeb | 116 | |
formulas | 0:38c3afd99aeb | 117 | void SetSecondAux(){ // Set Second Auxiliary screen |
formulas | 0:38c3afd99aeb | 118 | // Erase previous screen |
formulas | 0:38c3afd99aeb | 119 | lcd.SetTextColor(LCD_COLOR_WHITE); |
formulas | 0:38c3afd99aeb | 120 | lcd.FillRect(0,0,800,480); |
formulas | 0:38c3afd99aeb | 121 | lcd.SetTextColor(LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 122 | // Draw Second Auxiliary screen |
formulas | 0:38c3afd99aeb | 123 | PrintString("LVDT Sensors",50,200,20,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 124 | DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos); |
formulas | 0:38c3afd99aeb | 125 | lcd.SetTextColor(LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 126 | lcd.SetFont(&Font24); |
formulas | 0:38c3afd99aeb | 127 | lcd.DisplayStringAt(FLLVDTBarXPos+25,FLLVDTBarYPos,(uint8_t*)"FL",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 128 | lcd.DisplayStringAt(FRLVDTBarXPos+25,FRLVDTBarYPos,(uint8_t*)"FR",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 129 | lcd.DisplayStringAt(RLLVDTBarXPos+25,RLLVDTBarYPos,(uint8_t*)"BL",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 130 | lcd.DisplayStringAt(RRLVDTBarXPos+25,RRLVDTBarYPos,(uint8_t*)"BR",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 131 | // Display initial values |
formulas | 0:38c3afd99aeb | 132 | SetNumber(FL_LVDT,100,FLLVDTXPos,FLLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 133 | SetNumber(FR_LVDT,100,FRLVDTXPos,FRLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 134 | SetNumber(RL_LVDT,100,RLLVDTXPos,RLLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 135 | SetNumber(RR_LVDT,100,RRLVDTXPos,RRLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 136 | UpdateLVDTScale(FL_LVDT,-100,FLLVDTBarXPos,FLLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 137 | UpdateLVDTScale(FR_LVDT,-100,FRLVDTBarXPos,FRLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 138 | UpdateLVDTScale(RL_LVDT,-100,RLLVDTBarXPos,RLLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 139 | UpdateLVDTScale(RR_LVDT,-100,RRLVDTBarXPos,RRLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 140 | |
formulas | 0:38c3afd99aeb | 141 | }; |
formulas | 0:38c3afd99aeb | 142 | |
formulas | 0:38c3afd99aeb | 143 | |
formulas | 0:38c3afd99aeb | 144 | void MainUpdate(){ // Update information in Main screen |
formulas | 0:38c3afd99aeb | 145 | lcd.SetTextColor(LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 146 | 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 | 147 | case(0):break; |
formulas | 0:38c3afd99aeb | 148 | case(1): |
formulas | 0:38c3afd99aeb | 149 | Speed0=0; |
formulas | 0:38c3afd99aeb | 150 | ft_main_flag=0; //Set flag to 0. |
formulas | 0:38c3afd99aeb | 151 | break; |
formulas | 0:38c3afd99aeb | 152 | }; |
formulas | 0:38c3afd99aeb | 153 | if(Speed!=Speed0){ //Check is value is changed. If it is then update it on screen. |
formulas | 0:38c3afd99aeb | 154 | UpdateSpeedMeter(Speed0,Speed-Speed0); |
formulas | 0:38c3afd99aeb | 155 | }; |
formulas | 0:38c3afd99aeb | 156 | if(Gear!=Gear0){ |
formulas | 0:38c3afd99aeb | 157 | PrintChar(Gears[Gear],GearXPos,GearYPos,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 158 | }; |
formulas | 0:38c3afd99aeb | 159 | if(Oil_Temp!=Oil_Temp0){ |
formulas | 0:38c3afd99aeb | 160 | ChangeNumber(Oil_Temp,Oil_Temp0,100,OilTempXPos,OilTempYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 161 | }; |
formulas | 0:38c3afd99aeb | 162 | if(Water_Temp!=Water_Temp0){ |
formulas | 0:38c3afd99aeb | 163 | ChangeNumber(Water_Temp,Water_Temp0,100,WaterTempXPos,WaterTempYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 164 | }; |
formulas | 0:38c3afd99aeb | 165 | if(TPS!=TPS0){ |
formulas | 0:38c3afd99aeb | 166 | ChangeNumber(TPS,TPS0,100,TPSXPos,TPSYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 167 | }; |
formulas | 0:38c3afd99aeb | 168 | if(Brakes!=Brakes0){ |
formulas | 0:38c3afd99aeb | 169 | BrakeSignal(Brakes); |
formulas | 0:38c3afd99aeb | 170 | }; |
formulas | 0:38c3afd99aeb | 171 | }; |
formulas | 0:38c3afd99aeb | 172 | |
formulas | 0:38c3afd99aeb | 173 | |
formulas | 0:38c3afd99aeb | 174 | void FirstAuxUpdate(){ // Update information in First Auxiliary screen |
formulas | 0:38c3afd99aeb | 175 | if (Oil_P!=Oil_P0){ |
formulas | 0:38c3afd99aeb | 176 | ChangeNumber(Oil_P,Oil_P0,50,OilPXPos,OilPYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 177 | }; |
formulas | 0:38c3afd99aeb | 178 | if (MAP!=MAP0){ |
formulas | 0:38c3afd99aeb | 179 | ChangeNumber(MAP,MAP0,50,MAPXPos,MAPYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 180 | }; |
formulas | 0:38c3afd99aeb | 181 | if (Air_Temp!=Air_Temp0){ |
formulas | 0:38c3afd99aeb | 182 | ChangeNumber(Air_Temp,Air_Temp0,50,AirTempXPos,AirTempYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 183 | }; |
formulas | 0:38c3afd99aeb | 184 | if (Lambda!=Lambda0){ |
nemanja1994 | 3:a06e417a5a2c | 185 | ChangeNumber(Lambda,Lambda0,50,LambdaXPos,LambdaYPos,4,1,0); |
formulas | 0:38c3afd99aeb | 186 | }; |
formulas | 0:38c3afd99aeb | 187 | if (Volts!=Volts0){ |
nemanja1994 | 3:a06e417a5a2c | 188 | ChangeNumber(Volts,Volts0,50,VoltsXPos,VoltsYPos,3,2,0); |
formulas | 0:38c3afd99aeb | 189 | }; |
formulas | 0:38c3afd99aeb | 190 | if (Crank!=Crank0){ |
formulas | 0:38c3afd99aeb | 191 | ChangeCrank(Crank); |
formulas | 0:38c3afd99aeb | 192 | }; |
formulas | 2:f54f01527ebb | 193 | if (Meter_counter!=Meter_counter0){ |
formulas | 2:f54f01527ebb | 194 | ChangeNumber((int)(Meter_counter/10),(int)(Meter_counter0/10),50,Meter_counterXPos,Meter_counterYPos,5,3,0); |
formulas | 2:f54f01527ebb | 195 | }; |
formulas | 0:38c3afd99aeb | 196 | }; |
formulas | 0:38c3afd99aeb | 197 | |
formulas | 0:38c3afd99aeb | 198 | void SecondAuxUpdate(){ // Update information in Second Auxiliary screen |
formulas | 0:38c3afd99aeb | 199 | switch(ft_2aux_flag){ //Same as in Main. |
formulas | 0:38c3afd99aeb | 200 | case(0):break; |
formulas | 0:38c3afd99aeb | 201 | case(1): |
formulas | 0:38c3afd99aeb | 202 | FL_LVDT0=0; |
formulas | 0:38c3afd99aeb | 203 | FR_LVDT0=0; |
formulas | 0:38c3afd99aeb | 204 | RL_LVDT0=0; |
formulas | 0:38c3afd99aeb | 205 | RR_LVDT0=0; |
formulas | 0:38c3afd99aeb | 206 | ft_2aux_flag=0; |
formulas | 0:38c3afd99aeb | 207 | break; |
formulas | 0:38c3afd99aeb | 208 | }; |
formulas | 0:38c3afd99aeb | 209 | |
formulas | 0:38c3afd99aeb | 210 | if(FL_LVDT!=FL_LVDT0){ |
formulas | 0:38c3afd99aeb | 211 | ChangeNumber(FL_LVDT,FL_LVDT0,100,FLLVDTXPos,FLLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 212 | UpdateLVDTScale(FL_LVDT,FL_LVDT0,FLLVDTBarXPos,FLLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 213 | }; |
formulas | 0:38c3afd99aeb | 214 | if(FR_LVDT!=FR_LVDT0){ |
formulas | 0:38c3afd99aeb | 215 | ChangeNumber(FR_LVDT,FR_LVDT0,100,FRLVDTXPos,FRLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 216 | UpdateLVDTScale(FR_LVDT,FR_LVDT0,FRLVDTBarXPos,FRLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 217 | }; |
formulas | 0:38c3afd99aeb | 218 | if(RL_LVDT!=RL_LVDT0){ |
formulas | 0:38c3afd99aeb | 219 | ChangeNumber(RL_LVDT,RL_LVDT0,100,RLLVDTXPos,RLLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 220 | UpdateLVDTScale(RL_LVDT,RL_LVDT0,RLLVDTBarXPos,RLLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 221 | }; |
formulas | 0:38c3afd99aeb | 222 | if(RR_LVDT!=RR_LVDT0){ |
formulas | 0:38c3afd99aeb | 223 | ChangeNumber(RR_LVDT,RR_LVDT0,100,RRLVDTXPos,RRLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 224 | UpdateLVDTScale(RR_LVDT,RR_LVDT0,RRLVDTBarXPos,RRLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 225 | }; |
formulas | 0:38c3afd99aeb | 226 | }; |