Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed LCD_DISCO_F469NIa SD_DISCO_F469NI BSP_DISCO_F469NIa EEPROM_DISCO_F469NI
screen_library.cpp
00001 #include "screen_library.h" 00002 00003 extern LCD_DISCO_F469NI lcd; 00004 extern SD_DISCO_F469NI sd; 00005 extern DigitalIn change_screen_input; 00006 00007 extern uint8_t screen_flag,ft_main_flag,ft_2aux_flag,change_flag; 00008 extern GEAR *Gears; 00009 extern CHAR LogoSmallEA; 00010 extern IMAGE LogoBig,LogoSmall,Branko,NewYearCongat; 00011 00012 extern uint16_t Capacity0,HV_Voltage0, Rpm0, Speed0, Gear0, Water_Temp0, Bat_Temp0, TPS0, Brakes0, MAP0, Air_Temp0, Lambda0, Volts0, Crank0; 00013 extern uint16_t Capacity,HV_Voltage, Rpm, Speed, Gear, Water_Temp, Bat_Temp, TPS, Brakes, MAP, Air_Temp, Lambda, Volts, Crank; 00014 extern int FL_LVDT0, FR_LVDT0, RL_LVDT0, RR_LVDT0, FL_LVDT, FR_LVDT, RL_LVDT, RR_LVDT; 00015 extern int FL_LVDT_Ref,FR_LVDT_Ref,RL_LVDT_Ref,RR_LVDT_Ref; 00016 extern int LVDT_Max; 00017 extern uint8_t Acc_Temperature0[]; 00018 //extern float Meter_counter,Meter_counter0; 00019 00020 void ChangeCommand(){ //Interrupt function for registering change command 00021 change_flag=1; 00022 }; 00023 00024 void ChangeScreen(){ //Changes the screen if needed. 00025 switch(screen_flag){ 00026 case(3): 00027 screen_flag=1; //Change flag to new value. 00028 ft_main_flag=1; //Set flag which point that Main screne is entered. 00029 SetMain(); //Set Main Screne. 00030 break; 00031 case(1): 00032 screen_flag=2; 00033 SetFirstAux(); 00034 break; 00035 case(2): 00036 screen_flag=3; 00037 SetSecondAux(); 00038 break; 00039 }; 00040 change_flag=0; 00041 }; 00042 00043 00044 00045 void SetIntro(){ // Set Intro screen 00046 DrawRGBImage(LogoBig,0,0); 00047 wait(1); 00048 }; 00049 00050 void SetMain(){ // Set Main screen 00051 //Erase previous screen 00052 lcd.SetTextColor(LCD_COLOR_WHITE); 00053 lcd.FillRect(0,0,800,480); 00054 lcd.SetTextColor(LCD_COLOR_BLACK); 00055 //Draw Main screen 00056 DrawSpeedMeter(); 00057 PrintChar(LogoSmallEA,LogoSmallXPos,LogoSmallYPos,LCD_COLOR_BLACK); 00058 lcd.SetFont(&Font24); 00059 lcd.DisplayStringAt(30,170,(uint8_t*)"Battery Temp",LEFT_MODE); 00060 lcd.DisplayStringAt(30,320,(uint8_t*)"Water Temp",LEFT_MODE); 00061 lcd.DisplayStringAt(584,170,(uint8_t*)"TPS",LEFT_MODE); 00062 lcd.DisplayStringAt(584,320,(uint8_t*)"HVDC Voltage",LEFT_MODE); 00063 00064 //Display initial values 00065 lcd.SetTextColor(LCD_COLOR_BLACK); 00066 lcd.FillRect(CapXPos-5,CapYPos-5,210,310); 00067 lcd.FillRect(CapXPos+60,CapYPos-20,80,20); 00068 lcd.SetTextColor(LCD_COLOR_WHITE); 00069 lcd.FillRect(CapXPos,CapYPos,200,300); 00070 lcd.SetTextColor(LCD_COLOR_BLACK); 00071 UpdateCapBar(Capacity,0,CapXPos,CapYPos); 00072 SetNumber(Bat_Temp,100,BatTempXPos,BatTempYPos,3,0,0); 00073 SetNumber(Water_Temp,100,WaterTempXPos,WaterTempYPos,3,0,0); 00074 SetNumber(TPS,100,TPSXPos,TPSYPos,3,0,0); 00075 SetNumber(HV_Voltage,100,HVVXPos,HVVYPos,3,0,0); 00076 }; 00077 00078 00079 void SetFirstAux(){ // Set First Auxiliary screen 00080 // Erase previous screen 00081 lcd.SetTextColor(LCD_COLOR_WHITE); 00082 lcd.FillRect(0,0,800,480); 00083 lcd.SetTextColor(LCD_COLOR_BLACK); 00084 //PrintChar(LogoSmallEA,LogoSmallXPos,LogoSmallYPos,LCD_COLOR_BLACK); 00085 /* 00086 //Draw First Auxiliary screen 00087 PrintString("RPM",50,20,30,LCD_COLOR_BLACK); 00088 PrintString("MAP",50,20,90,LCD_COLOR_BLACK); 00089 PrintString("Air Temp",50,20,150,LCD_COLOR_BLACK); 00090 PrintString("Lambda",50,20,210,LCD_COLOR_BLACK); 00091 PrintString("Volts",50,20,270,LCD_COLOR_BLACK); 00092 PrintString("Distance:",50,20,330,LCD_COLOR_BLACK); 00093 //PrintString("",50,470,30,LCD_COLOR_BLACK); 00094 PrintString("kPa",50,560,90,LCD_COLOR_BLACK); 00095 PrintString("C",50,560,150,LCD_COLOR_BLACK); 00096 PrintString("Ratio",50,560,210,LCD_COLOR_BLACK); 00097 PrintString("V",50,560,270,LCD_COLOR_BLACK); 00098 PrintString("km",50,560,330,LCD_COLOR_BLACK); 00099 DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos); 00100 //Display initial values 00101 SetNumber(Rpm,50,RpmXPos,RpmYPos,5,0,0); 00102 SetNumber(MAP,50,MAPXPos,MAPYPos,3,0,0); 00103 SetNumber(Air_Temp,50,AirTempXPos,AirTempYPos,3,0,0); 00104 SetNumber(Lambda,50,LambdaXPos,LambdaYPos,4,1,0); 00105 SetNumber(Volts,50,VoltsXPos,VoltsYPos,3,2,0); 00106 //SetNumber((int)(Meter_counter/10),50,Meter_counterXPos,Meter_counterYPos,5,3,0); 00107 */ 00108 DrawBatTempMap(); 00109 for (uint8_t k = 1; k <= 70; k++){ 00110 Acc_Temperature0[k] = 10; 00111 }; 00112 }; 00113 00114 00115 void SetSecondAux(){ // Set Second Auxiliary screen 00116 // Erase previous screen 00117 lcd.SetTextColor(LCD_COLOR_WHITE); 00118 lcd.FillRect(0,0,800,480); 00119 lcd.SetTextColor(LCD_COLOR_BLACK); 00120 // Draw Second Auxiliary screen 00121 PrintString("LVDT Sensors",50,200,20,LCD_COLOR_BLACK); 00122 //DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos); 00123 lcd.SetTextColor(LCD_COLOR_BLACK); 00124 lcd.SetFont(&Font24); 00125 lcd.DisplayStringAt(FLLVDTBarXPos+25,FLLVDTBarYPos,(uint8_t*)"FL",LEFT_MODE); 00126 lcd.DisplayStringAt(FRLVDTBarXPos+25,FRLVDTBarYPos,(uint8_t*)"FR",LEFT_MODE); 00127 lcd.DisplayStringAt(RLLVDTBarXPos+25,RLLVDTBarYPos,(uint8_t*)"BL",LEFT_MODE); 00128 lcd.DisplayStringAt(RRLVDTBarXPos+25,RRLVDTBarYPos,(uint8_t*)"BR",LEFT_MODE); 00129 // Display initial values 00130 SetNumber(FL_LVDT,100,FLLVDTXPos,FLLVDTYPos,3,0,1); 00131 SetNumber(FR_LVDT,100,FRLVDTXPos,FRLVDTYPos,3,0,1); 00132 SetNumber(RL_LVDT,100,RLLVDTXPos,RLLVDTYPos,3,0,1); 00133 SetNumber(RR_LVDT,100,RRLVDTXPos,RRLVDTYPos,3,0,1); 00134 UpdateLVDTScale(FL_LVDT,-100,FLLVDTBarXPos,FLLVDTBarYPos); 00135 UpdateLVDTScale(FR_LVDT,-100,FRLVDTBarXPos,FRLVDTBarYPos); 00136 UpdateLVDTScale(RL_LVDT,-100,RLLVDTBarXPos,RLLVDTBarYPos); 00137 UpdateLVDTScale(RR_LVDT,-100,RRLVDTBarXPos,RRLVDTBarYPos); 00138 PrintChar(LogoSmallEA,LogoSmallXPos,LogoSmallYPos,LCD_COLOR_BLACK); 00139 }; 00140 00141 00142 void MainUpdate(){ // Update information in Main screen 00143 lcd.SetTextColor(LCD_COLOR_BLACK); 00144 switch(ft_main_flag){ // Check is main update is first time entered. If yes set Speed0 to 0 to acordingly draw update. 00145 case(0):break; 00146 case(1): 00147 Speed0=0; 00148 ft_main_flag=0; //Set flag to 0. 00149 break; 00150 }; 00151 if(Speed!=Speed0){ //Check is value is changed. If it is then update it on screen. 00152 UpdateSpeedMeter((int)(Speed0/10),(int)((Speed-Speed0)/10)); 00153 }; 00154 if(Capacity!=Capacity0){ 00155 UpdateCapBar(Capacity,Capacity0,CapXPos,CapYPos); 00156 }; 00157 if(Bat_Temp!=Bat_Temp0){ 00158 ChangeNumber(Bat_Temp,Bat_Temp0,100,BatTempXPos,BatTempYPos,3,0,0); 00159 }; 00160 if(Water_Temp!=Water_Temp0){ 00161 ChangeNumber(Water_Temp,Water_Temp0,100,WaterTempXPos,WaterTempYPos,3,0,0); 00162 }; 00163 if(TPS!=TPS0){ 00164 ChangeNumber(TPS,TPS0,100,TPSXPos,TPSYPos,3,0,0); 00165 }; 00166 if(HV_Voltage!=HV_Voltage0){ 00167 ChangeNumber(HV_Voltage,HV_Voltage0,100,HVVXPos,HVVYPos,3,0,0); 00168 }; 00169 }; 00170 00171 00172 void FirstAuxUpdate(){ // Update information in First Auxiliary screen 00173 /*if (Rpm!=Rpm0){ 00174 ChangeNumber(Rpm,Rpm0,50,RpmXPos,RpmYPos,5,0,0); 00175 }; 00176 if (MAP!=MAP0){ 00177 ChangeNumber(MAP,MAP0,50,MAPXPos,MAPYPos,3,0,0); 00178 }; 00179 if (Air_Temp!=Air_Temp0){ 00180 ChangeNumber(Air_Temp,Air_Temp0,50,AirTempXPos,AirTempYPos,3,0,0); 00181 }; 00182 if (Lambda!=Lambda0){ 00183 ChangeNumber(Lambda,Lambda0,50,LambdaXPos,LambdaYPos,4,1,0); 00184 }; 00185 if (Volts!=Volts0){ 00186 ChangeNumber(Volts,Volts0,50,VoltsXPos,VoltsYPos,3,2,0); 00187 }; 00188 //if (Meter_counter!=Meter_counter0){ 00189 // ChangeNumber((int)(Meter_counter/10),(int)(Meter_counter0/10),50,Meter_counterXPos,Meter_counterYPos,5,3,0); 00190 //}; 00191 */ 00192 UpdateBatTempMap(); 00193 }; 00194 00195 void SecondAuxUpdate(){ // Update information in Second Auxiliary screen 00196 switch(ft_2aux_flag){ //Same as in Main. 00197 case(0):break; 00198 case(1): 00199 FL_LVDT0=0; 00200 FR_LVDT0=0; 00201 RL_LVDT0=0; 00202 RR_LVDT0=0; 00203 ft_2aux_flag=0; 00204 break; 00205 }; 00206 00207 if(FL_LVDT!=FL_LVDT0){ 00208 ChangeNumber(FL_LVDT,FL_LVDT0,100,FLLVDTXPos,FLLVDTYPos,3,0,1); 00209 UpdateLVDTScale(FL_LVDT,FL_LVDT0,FLLVDTBarXPos,FLLVDTBarYPos); 00210 }; 00211 if(FR_LVDT!=FR_LVDT0){ 00212 ChangeNumber(FR_LVDT,FR_LVDT0,100,FRLVDTXPos,FRLVDTYPos,3,0,1); 00213 UpdateLVDTScale(FR_LVDT,FR_LVDT0,FRLVDTBarXPos,FRLVDTBarYPos); 00214 }; 00215 if(RL_LVDT!=RL_LVDT0){ 00216 ChangeNumber(RL_LVDT,RL_LVDT0,100,RLLVDTXPos,RLLVDTYPos,3,0,1); 00217 UpdateLVDTScale(RL_LVDT,RL_LVDT0,RLLVDTBarXPos,RLLVDTBarYPos); 00218 }; 00219 if(RR_LVDT!=RR_LVDT0){ 00220 ChangeNumber(RR_LVDT,RR_LVDT0,100,RRLVDTXPos,RRLVDTYPos,3,0,1); 00221 UpdateLVDTScale(RR_LVDT,RR_LVDT0,RRLVDTBarXPos,RRLVDTBarYPos); 00222 }; 00223 };
Generated on Tue Jul 12 2022 18:36:18 by
