Konacan kod
Dependencies: BSP_DISCO_F469NIa LCD_DISCO_F469NIa SD_DISCO_F469NI mbed
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 IMAGE LogoBig,LogoSmall,Branko,NewYearCongat; 00010 00011 extern uint16_t Rpm0, Speed0, Gear0, Water_Temp0, Oil_Temp0, TPS0, Brakes0, Oil_P0, MAP0, Air_Temp0, Lambda0, Volts0, Crank0; 00012 extern uint16_t Rpm, Speed, Gear, Water_Temp, Oil_Temp, TPS, Brakes, Oil_P, MAP, Air_Temp, Lambda, Volts, Crank; 00013 extern int FL_LVDT0, FR_LVDT0, RL_LVDT0, RR_LVDT0, FL_LVDT, FR_LVDT, RL_LVDT, RR_LVDT; 00014 extern int FL_LVDT_Ref,FR_LVDT_Ref,RL_LVDT_Ref,RR_LVDT_Ref; 00015 extern int LVDT_Max; 00016 00017 void ChangeCommand(){ //Interrupt function for registering change command 00018 change_flag=1; 00019 }; 00020 00021 void ChangeScreen(){ //Changes the screen if needed. 00022 switch(screen_flag){ 00023 case(3): 00024 screen_flag=1; //Change flag to new value. 00025 ft_main_flag=1; //Set flag which point that Main screne is entered. 00026 SetMain(); //Set Main Screne. 00027 break; 00028 case(1): 00029 screen_flag=2; 00030 SetFirstAux(); 00031 break; 00032 case(2): 00033 screen_flag=3; 00034 SetSecondAux(); 00035 break; 00036 }; 00037 change_flag=0; 00038 }; 00039 00040 00041 00042 void SetIntro(){ // Set Intro screen 00043 DrawRGBImage(LogoBig,0,0); 00044 wait(0.5); 00045 /*lcd.SetTextColor(LCD_COLOR_WHITE); 00046 lcd.FillRect(0,0,800,480); 00047 PrintString(" Srecnu Novu godinu ",50,70,50,LCD_COLOR_RED); 00048 PrintString(" i Bozicne praznike ",50,80,110,LCD_COLOR_RED); 00049 PrintString(" zeli Vam ",50,70,170,LCD_COLOR_RED); 00050 PrintString("Podtim za Elektroniku",50,50,230,LCD_COLOR_RED); 00051 wait(5); 00052 DrawRGBImage(NewYearCongat,0,0); 00053 wait(10);*/ 00054 }; 00055 00056 void SetMain(){ // Set Main screen 00057 //Erase previous screen 00058 lcd.SetTextColor(LCD_COLOR_WHITE); 00059 lcd.FillRect(0,0,800,480); 00060 lcd.SetTextColor(LCD_COLOR_BLACK); 00061 //Draw Main screen 00062 DrawSpeedMeter(); 00063 DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos); 00064 lcd.SetFont(&Font24); 00065 lcd.DisplayStringAt(30,170,(uint8_t*)"Oil Temp",LEFT_MODE); 00066 lcd.DisplayStringAt(30,320,(uint8_t*)"Water Temp",LEFT_MODE); 00067 lcd.DisplayStringAt(584,170,(uint8_t*)"TPS",LEFT_MODE); 00068 lcd.SetTextColor(LCD_COLOR_DARKRED); 00069 lcd.FillRect(560,340,230,68); 00070 lcd.SetBackColor(LCD_COLOR_DARKRED); 00071 PrintString("BRAKE",50,575,350,LCD_COLOR_BLACK); 00072 lcd.SetBackColor(LCD_COLOR_WHITE); 00073 00074 //Display initial values 00075 PrintChar(Gears[Gear],GearXPos,GearYPos,LCD_COLOR_BLACK); 00076 SetNumber(Oil_Temp,100,OilTempXPos,OilTempYPos,3,0,0); 00077 SetNumber(Water_Temp,100,WaterTempXPos,WaterTempYPos,3,0,0); 00078 SetNumber(TPS,100,TPSXPos,TPSYPos,3,0,0); 00079 BrakeSignal(Brakes); 00080 }; 00081 00082 00083 void SetFirstAux(){ // Set First Auxiliary screen 00084 // Erase previous screen 00085 lcd.SetTextColor(LCD_COLOR_WHITE); 00086 lcd.FillRect(0,0,800,480); 00087 lcd.SetTextColor(LCD_COLOR_BLACK); 00088 //Draw First Auxiliary screen 00089 PrintString("Oil P",50,20,25,LCD_COLOR_BLACK); 00090 PrintString("MAP",50,20,100,LCD_COLOR_BLACK); 00091 PrintString("Air Temp",50,20,175,LCD_COLOR_BLACK); 00092 PrintString("Lambda",50,20,250,LCD_COLOR_BLACK); 00093 PrintString("Volts",50,20,325,LCD_COLOR_BLACK); 00094 PrintString("Crank",50,20,400,LCD_COLOR_BLACK); 00095 PrintString("kPa",50,470,25,LCD_COLOR_BLACK); 00096 PrintString("kPa",50,470,100,LCD_COLOR_BLACK); 00097 PrintString("C",50,470,175,LCD_COLOR_BLACK); 00098 PrintString("Ratio",50,470,250,LCD_COLOR_BLACK); 00099 PrintString("V",50,470,325,LCD_COLOR_BLACK); 00100 DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos); 00101 //Display initial values 00102 SetNumber(Oil_P,50,OilPXPos,OilPYPos,3,0,0); 00103 SetNumber(MAP,50,MAPXPos,MAPYPos,3,0,0); 00104 SetNumber(Air_Temp,50,AirTempXPos,AirTempYPos,3,0,0); 00105 SetNumber(Lambda,50,LambdaXPos,LambdaYPos,3,0,0); 00106 SetNumber(Volts,50,VoltsXPos,VoltsYPos,3,0,0); 00107 ChangeCrank(Crank); 00108 }; 00109 00110 00111 void SetSecondAux(){ // Set Second Auxiliary screen 00112 // Erase previous screen 00113 lcd.SetTextColor(LCD_COLOR_WHITE); 00114 lcd.FillRect(0,0,800,480); 00115 lcd.SetTextColor(LCD_COLOR_BLACK); 00116 // Draw Second Auxiliary screen 00117 PrintString("LVDT Sensors",50,200,20,LCD_COLOR_BLACK); 00118 DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos); 00119 lcd.SetTextColor(LCD_COLOR_BLACK); 00120 lcd.SetFont(&Font24); 00121 lcd.DisplayStringAt(FLLVDTBarXPos+25,FLLVDTBarYPos,(uint8_t*)"FL",LEFT_MODE); 00122 lcd.DisplayStringAt(FRLVDTBarXPos+25,FRLVDTBarYPos,(uint8_t*)"FR",LEFT_MODE); 00123 lcd.DisplayStringAt(RLLVDTBarXPos+25,RLLVDTBarYPos,(uint8_t*)"BL",LEFT_MODE); 00124 lcd.DisplayStringAt(RRLVDTBarXPos+25,RRLVDTBarYPos,(uint8_t*)"BR",LEFT_MODE); 00125 // Display initial values 00126 SetNumber(FL_LVDT,100,FLLVDTXPos,FLLVDTYPos,3,0,1); 00127 SetNumber(FR_LVDT,100,FRLVDTXPos,FRLVDTYPos,3,0,1); 00128 SetNumber(RL_LVDT,100,RLLVDTXPos,RLLVDTYPos,3,0,1); 00129 SetNumber(RR_LVDT,100,RRLVDTXPos,RRLVDTYPos,3,0,1); 00130 UpdateLVDTScale(FL_LVDT,-100,FLLVDTBarXPos,FLLVDTBarYPos); 00131 UpdateLVDTScale(FR_LVDT,-100,FRLVDTBarXPos,FRLVDTBarYPos); 00132 UpdateLVDTScale(RL_LVDT,-100,RLLVDTBarXPos,RLLVDTBarYPos); 00133 UpdateLVDTScale(RR_LVDT,-100,RRLVDTBarXPos,RRLVDTBarYPos); 00134 00135 }; 00136 00137 00138 void MainUpdate(){ // Update information in Main screen 00139 lcd.SetTextColor(LCD_COLOR_BLACK); 00140 switch(ft_main_flag){ // Check is main update is first time entered. If yes set Speed0 to 0 to acordingly draw update. 00141 case(0):break; 00142 case(1): 00143 Speed0=0; 00144 ft_main_flag=0; //Set flag to 0. 00145 break; 00146 }; 00147 if(Speed!=Speed0){ //Check is value is changed. If it is then update it on screen. 00148 UpdateSpeedMeter(Speed0,Speed-Speed0); 00149 }; 00150 if(Gear!=Gear0){ 00151 PrintChar(Gears[Gear],GearXPos,GearYPos,LCD_COLOR_BLACK); 00152 }; 00153 if(Oil_Temp!=Oil_Temp0){ 00154 ChangeNumber(Oil_Temp,Oil_Temp0,100,OilTempXPos,OilTempYPos,3,0,0); 00155 }; 00156 if(Water_Temp!=Water_Temp0){ 00157 ChangeNumber(Water_Temp,Water_Temp0,100,WaterTempXPos,WaterTempYPos,3,0,0); 00158 }; 00159 if(TPS!=TPS0){ 00160 ChangeNumber(TPS,TPS0,100,TPSXPos,TPSYPos,3,0,0); 00161 }; 00162 if(Brakes!=Brakes0){ 00163 BrakeSignal(Brakes); 00164 }; 00165 }; 00166 00167 00168 void FirstAuxUpdate(){ // Update information in First Auxiliary screen 00169 if (Oil_P!=Oil_P0){ 00170 ChangeNumber(Oil_P,Oil_P0,50,OilPXPos,OilPYPos,3,0,0); 00171 }; 00172 if (MAP!=MAP0){ 00173 ChangeNumber(MAP,MAP0,50,MAPXPos,MAPYPos,3,0,0); 00174 }; 00175 if (Air_Temp!=Air_Temp0){ 00176 ChangeNumber(Air_Temp,Air_Temp0,50,AirTempXPos,AirTempYPos,3,0,0); 00177 }; 00178 if (Lambda!=Lambda0){ 00179 ChangeNumber(Lambda,Lambda0,50,LambdaXPos,LambdaYPos,3,0,0); 00180 }; 00181 if (Volts!=Volts0){ 00182 ChangeNumber(Volts,Volts0,50,VoltsXPos,VoltsYPos,3,0,0); 00183 }; 00184 if (Crank!=Crank0){ 00185 ChangeCrank(Crank); 00186 }; 00187 }; 00188 00189 void SecondAuxUpdate(){ // Update information in Second Auxiliary screen 00190 switch(ft_2aux_flag){ //Same as in Main. 00191 case(0):break; 00192 case(1): 00193 FL_LVDT0=0; 00194 FR_LVDT0=0; 00195 RL_LVDT0=0; 00196 RR_LVDT0=0; 00197 ft_2aux_flag=0; 00198 break; 00199 }; 00200 00201 if(FL_LVDT!=FL_LVDT0){ 00202 ChangeNumber(FL_LVDT,FL_LVDT0,100,FLLVDTXPos,FLLVDTYPos,3,0,1); 00203 UpdateLVDTScale(FL_LVDT,FL_LVDT0,FLLVDTBarXPos,FLLVDTBarYPos); 00204 }; 00205 if(FR_LVDT!=FR_LVDT0){ 00206 ChangeNumber(FR_LVDT,FR_LVDT0,100,FRLVDTXPos,FRLVDTYPos,3,0,1); 00207 UpdateLVDTScale(FR_LVDT,FR_LVDT0,FRLVDTBarXPos,FRLVDTBarYPos); 00208 }; 00209 if(RL_LVDT!=RL_LVDT0){ 00210 ChangeNumber(RL_LVDT,RL_LVDT0,100,RLLVDTXPos,RLLVDTYPos,3,0,1); 00211 UpdateLVDTScale(RL_LVDT,RL_LVDT0,RLLVDTBarXPos,RLLVDTBarYPos); 00212 }; 00213 if(RR_LVDT!=RR_LVDT0){ 00214 ChangeNumber(RR_LVDT,RR_LVDT0,100,RRLVDTXPos,RRLVDTYPos,3,0,1); 00215 UpdateLVDTScale(RR_LVDT,RR_LVDT0,RRLVDTBarXPos,RRLVDTBarYPos); 00216 }; 00217 };
Generated on Thu Jul 14 2022 09:25:33 by 1.7.2