15.02.2019. revision
Dependencies: mbed LCD_DISCO_F469NIa SD_DISCO_F469NI BSP_DISCO_F469NIa EEPROM_DISCO_F469NI
screen_library.cpp@0:38c3afd99aeb, 2018-05-16 (annotated)
- Committer:
- formulas
- Date:
- Wed May 16 14:48:37 2018 +0000
- Revision:
- 0:38c3afd99aeb
- Child:
- 2:f54f01527ebb
a
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 | 0:38c3afd99aeb | 16 | |
formulas | 0:38c3afd99aeb | 17 | void ChangeCommand(){ //Interrupt function for registering change command |
formulas | 0:38c3afd99aeb | 18 | change_flag=1; |
formulas | 0:38c3afd99aeb | 19 | }; |
formulas | 0:38c3afd99aeb | 20 | |
formulas | 0:38c3afd99aeb | 21 | void ChangeScreen(){ //Changes the screen if needed. |
formulas | 0:38c3afd99aeb | 22 | switch(screen_flag){ |
formulas | 0:38c3afd99aeb | 23 | case(3): |
formulas | 0:38c3afd99aeb | 24 | screen_flag=1; //Change flag to new value. |
formulas | 0:38c3afd99aeb | 25 | ft_main_flag=1; //Set flag which point that Main screne is entered. |
formulas | 0:38c3afd99aeb | 26 | SetMain(); //Set Main Screne. |
formulas | 0:38c3afd99aeb | 27 | break; |
formulas | 0:38c3afd99aeb | 28 | case(1): |
formulas | 0:38c3afd99aeb | 29 | screen_flag=2; |
formulas | 0:38c3afd99aeb | 30 | SetFirstAux(); |
formulas | 0:38c3afd99aeb | 31 | break; |
formulas | 0:38c3afd99aeb | 32 | case(2): |
formulas | 0:38c3afd99aeb | 33 | screen_flag=3; |
formulas | 0:38c3afd99aeb | 34 | SetSecondAux(); |
formulas | 0:38c3afd99aeb | 35 | break; |
formulas | 0:38c3afd99aeb | 36 | }; |
formulas | 0:38c3afd99aeb | 37 | change_flag=0; |
formulas | 0:38c3afd99aeb | 38 | }; |
formulas | 0:38c3afd99aeb | 39 | |
formulas | 0:38c3afd99aeb | 40 | |
formulas | 0:38c3afd99aeb | 41 | |
formulas | 0:38c3afd99aeb | 42 | void SetIntro(){ // Set Intro screen |
formulas | 0:38c3afd99aeb | 43 | DrawRGBImage(LogoBig,0,0); |
formulas | 0:38c3afd99aeb | 44 | wait(0.5); |
formulas | 0:38c3afd99aeb | 45 | /*lcd.SetTextColor(LCD_COLOR_WHITE); |
formulas | 0:38c3afd99aeb | 46 | lcd.FillRect(0,0,800,480); |
formulas | 0:38c3afd99aeb | 47 | PrintString(" Srecnu Novu godinu ",50,70,50,LCD_COLOR_RED); |
formulas | 0:38c3afd99aeb | 48 | PrintString(" i Bozicne praznike ",50,80,110,LCD_COLOR_RED); |
formulas | 0:38c3afd99aeb | 49 | PrintString(" zeli Vam ",50,70,170,LCD_COLOR_RED); |
formulas | 0:38c3afd99aeb | 50 | PrintString("Podtim za Elektroniku",50,50,230,LCD_COLOR_RED); |
formulas | 0:38c3afd99aeb | 51 | wait(5); |
formulas | 0:38c3afd99aeb | 52 | DrawRGBImage(NewYearCongat,0,0); |
formulas | 0:38c3afd99aeb | 53 | wait(10);*/ |
formulas | 0:38c3afd99aeb | 54 | }; |
formulas | 0:38c3afd99aeb | 55 | |
formulas | 0:38c3afd99aeb | 56 | void SetMain(){ // Set Main screen |
formulas | 0:38c3afd99aeb | 57 | //Erase previous screen |
formulas | 0:38c3afd99aeb | 58 | lcd.SetTextColor(LCD_COLOR_WHITE); |
formulas | 0:38c3afd99aeb | 59 | lcd.FillRect(0,0,800,480); |
formulas | 0:38c3afd99aeb | 60 | lcd.SetTextColor(LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 61 | //Draw Main screen |
formulas | 0:38c3afd99aeb | 62 | DrawSpeedMeter(); |
formulas | 0:38c3afd99aeb | 63 | DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos); |
formulas | 0:38c3afd99aeb | 64 | lcd.SetFont(&Font24); |
formulas | 0:38c3afd99aeb | 65 | lcd.DisplayStringAt(30,170,(uint8_t*)"Oil Temp",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 66 | lcd.DisplayStringAt(30,320,(uint8_t*)"Water Temp",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 67 | lcd.DisplayStringAt(584,170,(uint8_t*)"TPS",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 68 | lcd.SetTextColor(LCD_COLOR_DARKRED); |
formulas | 0:38c3afd99aeb | 69 | lcd.FillRect(560,340,230,68); |
formulas | 0:38c3afd99aeb | 70 | lcd.SetBackColor(LCD_COLOR_DARKRED); |
formulas | 0:38c3afd99aeb | 71 | PrintString("BRAKE",50,575,350,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 72 | lcd.SetBackColor(LCD_COLOR_WHITE); |
formulas | 0:38c3afd99aeb | 73 | |
formulas | 0:38c3afd99aeb | 74 | //Display initial values |
formulas | 0:38c3afd99aeb | 75 | PrintChar(Gears[Gear],GearXPos,GearYPos,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 76 | SetNumber(Oil_Temp,100,OilTempXPos,OilTempYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 77 | SetNumber(Water_Temp,100,WaterTempXPos,WaterTempYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 78 | SetNumber(TPS,100,TPSXPos,TPSYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 79 | BrakeSignal(Brakes); |
formulas | 0:38c3afd99aeb | 80 | }; |
formulas | 0:38c3afd99aeb | 81 | |
formulas | 0:38c3afd99aeb | 82 | |
formulas | 0:38c3afd99aeb | 83 | void SetFirstAux(){ // Set First Auxiliary screen |
formulas | 0:38c3afd99aeb | 84 | // Erase previous screen |
formulas | 0:38c3afd99aeb | 85 | lcd.SetTextColor(LCD_COLOR_WHITE); |
formulas | 0:38c3afd99aeb | 86 | lcd.FillRect(0,0,800,480); |
formulas | 0:38c3afd99aeb | 87 | lcd.SetTextColor(LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 88 | //Draw First Auxiliary screen |
formulas | 0:38c3afd99aeb | 89 | PrintString("Oil P",50,20,25,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 90 | PrintString("MAP",50,20,100,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 91 | PrintString("Air Temp",50,20,175,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 92 | PrintString("Lambda",50,20,250,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 93 | PrintString("Volts",50,20,325,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 94 | PrintString("Crank",50,20,400,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 95 | PrintString("kPa",50,470,25,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 96 | PrintString("kPa",50,470,100,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 97 | PrintString("C",50,470,175,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 98 | PrintString("Ratio",50,470,250,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 99 | PrintString("V",50,470,325,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 100 | DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos); |
formulas | 0:38c3afd99aeb | 101 | //Display initial values |
formulas | 0:38c3afd99aeb | 102 | SetNumber(Oil_P,50,OilPXPos,OilPYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 103 | SetNumber(MAP,50,MAPXPos,MAPYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 104 | SetNumber(Air_Temp,50,AirTempXPos,AirTempYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 105 | SetNumber(Lambda,50,LambdaXPos,LambdaYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 106 | SetNumber(Volts,50,VoltsXPos,VoltsYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 107 | ChangeCrank(Crank); |
formulas | 0:38c3afd99aeb | 108 | }; |
formulas | 0:38c3afd99aeb | 109 | |
formulas | 0:38c3afd99aeb | 110 | |
formulas | 0:38c3afd99aeb | 111 | void SetSecondAux(){ // Set Second Auxiliary screen |
formulas | 0:38c3afd99aeb | 112 | // Erase previous screen |
formulas | 0:38c3afd99aeb | 113 | lcd.SetTextColor(LCD_COLOR_WHITE); |
formulas | 0:38c3afd99aeb | 114 | lcd.FillRect(0,0,800,480); |
formulas | 0:38c3afd99aeb | 115 | lcd.SetTextColor(LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 116 | // Draw Second Auxiliary screen |
formulas | 0:38c3afd99aeb | 117 | PrintString("LVDT Sensors",50,200,20,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 118 | DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos); |
formulas | 0:38c3afd99aeb | 119 | lcd.SetTextColor(LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 120 | lcd.SetFont(&Font24); |
formulas | 0:38c3afd99aeb | 121 | lcd.DisplayStringAt(FLLVDTBarXPos+25,FLLVDTBarYPos,(uint8_t*)"FL",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 122 | lcd.DisplayStringAt(FRLVDTBarXPos+25,FRLVDTBarYPos,(uint8_t*)"FR",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 123 | lcd.DisplayStringAt(RLLVDTBarXPos+25,RLLVDTBarYPos,(uint8_t*)"BL",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 124 | lcd.DisplayStringAt(RRLVDTBarXPos+25,RRLVDTBarYPos,(uint8_t*)"BR",LEFT_MODE); |
formulas | 0:38c3afd99aeb | 125 | // Display initial values |
formulas | 0:38c3afd99aeb | 126 | SetNumber(FL_LVDT,100,FLLVDTXPos,FLLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 127 | SetNumber(FR_LVDT,100,FRLVDTXPos,FRLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 128 | SetNumber(RL_LVDT,100,RLLVDTXPos,RLLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 129 | SetNumber(RR_LVDT,100,RRLVDTXPos,RRLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 130 | UpdateLVDTScale(FL_LVDT,-100,FLLVDTBarXPos,FLLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 131 | UpdateLVDTScale(FR_LVDT,-100,FRLVDTBarXPos,FRLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 132 | UpdateLVDTScale(RL_LVDT,-100,RLLVDTBarXPos,RLLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 133 | UpdateLVDTScale(RR_LVDT,-100,RRLVDTBarXPos,RRLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 134 | |
formulas | 0:38c3afd99aeb | 135 | }; |
formulas | 0:38c3afd99aeb | 136 | |
formulas | 0:38c3afd99aeb | 137 | |
formulas | 0:38c3afd99aeb | 138 | void MainUpdate(){ // Update information in Main screen |
formulas | 0:38c3afd99aeb | 139 | lcd.SetTextColor(LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 140 | 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 | 141 | case(0):break; |
formulas | 0:38c3afd99aeb | 142 | case(1): |
formulas | 0:38c3afd99aeb | 143 | Speed0=0; |
formulas | 0:38c3afd99aeb | 144 | ft_main_flag=0; //Set flag to 0. |
formulas | 0:38c3afd99aeb | 145 | break; |
formulas | 0:38c3afd99aeb | 146 | }; |
formulas | 0:38c3afd99aeb | 147 | if(Speed!=Speed0){ //Check is value is changed. If it is then update it on screen. |
formulas | 0:38c3afd99aeb | 148 | UpdateSpeedMeter(Speed0,Speed-Speed0); |
formulas | 0:38c3afd99aeb | 149 | }; |
formulas | 0:38c3afd99aeb | 150 | if(Gear!=Gear0){ |
formulas | 0:38c3afd99aeb | 151 | PrintChar(Gears[Gear],GearXPos,GearYPos,LCD_COLOR_BLACK); |
formulas | 0:38c3afd99aeb | 152 | }; |
formulas | 0:38c3afd99aeb | 153 | if(Oil_Temp!=Oil_Temp0){ |
formulas | 0:38c3afd99aeb | 154 | ChangeNumber(Oil_Temp,Oil_Temp0,100,OilTempXPos,OilTempYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 155 | }; |
formulas | 0:38c3afd99aeb | 156 | if(Water_Temp!=Water_Temp0){ |
formulas | 0:38c3afd99aeb | 157 | ChangeNumber(Water_Temp,Water_Temp0,100,WaterTempXPos,WaterTempYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 158 | }; |
formulas | 0:38c3afd99aeb | 159 | if(TPS!=TPS0){ |
formulas | 0:38c3afd99aeb | 160 | ChangeNumber(TPS,TPS0,100,TPSXPos,TPSYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 161 | }; |
formulas | 0:38c3afd99aeb | 162 | if(Brakes!=Brakes0){ |
formulas | 0:38c3afd99aeb | 163 | BrakeSignal(Brakes); |
formulas | 0:38c3afd99aeb | 164 | }; |
formulas | 0:38c3afd99aeb | 165 | }; |
formulas | 0:38c3afd99aeb | 166 | |
formulas | 0:38c3afd99aeb | 167 | |
formulas | 0:38c3afd99aeb | 168 | void FirstAuxUpdate(){ // Update information in First Auxiliary screen |
formulas | 0:38c3afd99aeb | 169 | if (Oil_P!=Oil_P0){ |
formulas | 0:38c3afd99aeb | 170 | ChangeNumber(Oil_P,Oil_P0,50,OilPXPos,OilPYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 171 | }; |
formulas | 0:38c3afd99aeb | 172 | if (MAP!=MAP0){ |
formulas | 0:38c3afd99aeb | 173 | ChangeNumber(MAP,MAP0,50,MAPXPos,MAPYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 174 | }; |
formulas | 0:38c3afd99aeb | 175 | if (Air_Temp!=Air_Temp0){ |
formulas | 0:38c3afd99aeb | 176 | ChangeNumber(Air_Temp,Air_Temp0,50,AirTempXPos,AirTempYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 177 | }; |
formulas | 0:38c3afd99aeb | 178 | if (Lambda!=Lambda0){ |
formulas | 0:38c3afd99aeb | 179 | ChangeNumber(Lambda,Lambda0,50,LambdaXPos,LambdaYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 180 | }; |
formulas | 0:38c3afd99aeb | 181 | if (Volts!=Volts0){ |
formulas | 0:38c3afd99aeb | 182 | ChangeNumber(Volts,Volts0,50,VoltsXPos,VoltsYPos,3,0,0); |
formulas | 0:38c3afd99aeb | 183 | }; |
formulas | 0:38c3afd99aeb | 184 | if (Crank!=Crank0){ |
formulas | 0:38c3afd99aeb | 185 | ChangeCrank(Crank); |
formulas | 0:38c3afd99aeb | 186 | }; |
formulas | 0:38c3afd99aeb | 187 | }; |
formulas | 0:38c3afd99aeb | 188 | |
formulas | 0:38c3afd99aeb | 189 | void SecondAuxUpdate(){ // Update information in Second Auxiliary screen |
formulas | 0:38c3afd99aeb | 190 | switch(ft_2aux_flag){ //Same as in Main. |
formulas | 0:38c3afd99aeb | 191 | case(0):break; |
formulas | 0:38c3afd99aeb | 192 | case(1): |
formulas | 0:38c3afd99aeb | 193 | FL_LVDT0=0; |
formulas | 0:38c3afd99aeb | 194 | FR_LVDT0=0; |
formulas | 0:38c3afd99aeb | 195 | RL_LVDT0=0; |
formulas | 0:38c3afd99aeb | 196 | RR_LVDT0=0; |
formulas | 0:38c3afd99aeb | 197 | ft_2aux_flag=0; |
formulas | 0:38c3afd99aeb | 198 | break; |
formulas | 0:38c3afd99aeb | 199 | }; |
formulas | 0:38c3afd99aeb | 200 | |
formulas | 0:38c3afd99aeb | 201 | if(FL_LVDT!=FL_LVDT0){ |
formulas | 0:38c3afd99aeb | 202 | ChangeNumber(FL_LVDT,FL_LVDT0,100,FLLVDTXPos,FLLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 203 | UpdateLVDTScale(FL_LVDT,FL_LVDT0,FLLVDTBarXPos,FLLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 204 | }; |
formulas | 0:38c3afd99aeb | 205 | if(FR_LVDT!=FR_LVDT0){ |
formulas | 0:38c3afd99aeb | 206 | ChangeNumber(FR_LVDT,FR_LVDT0,100,FRLVDTXPos,FRLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 207 | UpdateLVDTScale(FR_LVDT,FR_LVDT0,FRLVDTBarXPos,FRLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 208 | }; |
formulas | 0:38c3afd99aeb | 209 | if(RL_LVDT!=RL_LVDT0){ |
formulas | 0:38c3afd99aeb | 210 | ChangeNumber(RL_LVDT,RL_LVDT0,100,RLLVDTXPos,RLLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 211 | UpdateLVDTScale(RL_LVDT,RL_LVDT0,RLLVDTBarXPos,RLLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 212 | }; |
formulas | 0:38c3afd99aeb | 213 | if(RR_LVDT!=RR_LVDT0){ |
formulas | 0:38c3afd99aeb | 214 | ChangeNumber(RR_LVDT,RR_LVDT0,100,RRLVDTXPos,RRLVDTYPos,3,0,1); |
formulas | 0:38c3afd99aeb | 215 | UpdateLVDTScale(RR_LVDT,RR_LVDT0,RRLVDTBarXPos,RRLVDTBarYPos); |
formulas | 0:38c3afd99aeb | 216 | }; |
formulas | 0:38c3afd99aeb | 217 | }; |