Konacan kod

Dependencies:   BSP_DISCO_F469NIa EEPROM_DISCO_F469NI LCD_DISCO_F469NIa SD_DISCO_F469NI mbed

Fork of IntegrationCAN by Nenad Djalovic

Committer:
formulas
Date:
Thu Jun 28 16:33:23 2018 +0000
Revision:
2:f54f01527ebb
Parent:
0:38c3afd99aeb
a

Who changed what in which revision?

UserRevisionLine numberNew 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);
formulas 0:38c3afd99aeb 45 wait(0.5);
formulas 0:38c3afd99aeb 46 /*lcd.SetTextColor(LCD_COLOR_WHITE);
formulas 0:38c3afd99aeb 47 lcd.FillRect(0,0,800,480);
formulas 0:38c3afd99aeb 48 PrintString(" Srecnu Novu godinu ",50,70,50,LCD_COLOR_RED);
formulas 0:38c3afd99aeb 49 PrintString(" i Bozicne praznike ",50,80,110,LCD_COLOR_RED);
formulas 0:38c3afd99aeb 50 PrintString(" zeli Vam ",50,70,170,LCD_COLOR_RED);
formulas 0:38c3afd99aeb 51 PrintString("Podtim za Elektroniku",50,50,230,LCD_COLOR_RED);
formulas 0:38c3afd99aeb 52 wait(5);
formulas 0:38c3afd99aeb 53 DrawRGBImage(NewYearCongat,0,0);
formulas 0:38c3afd99aeb 54 wait(10);*/
formulas 0:38c3afd99aeb 55 };
formulas 0:38c3afd99aeb 56
formulas 0:38c3afd99aeb 57 void SetMain(){ // Set Main screen
formulas 0:38c3afd99aeb 58 //Erase previous screen
formulas 0:38c3afd99aeb 59 lcd.SetTextColor(LCD_COLOR_WHITE);
formulas 0:38c3afd99aeb 60 lcd.FillRect(0,0,800,480);
formulas 0:38c3afd99aeb 61 lcd.SetTextColor(LCD_COLOR_BLACK);
formulas 0:38c3afd99aeb 62 //Draw Main screen
formulas 0:38c3afd99aeb 63 DrawSpeedMeter();
formulas 0:38c3afd99aeb 64 DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos);
formulas 0:38c3afd99aeb 65 lcd.SetFont(&Font24);
formulas 0:38c3afd99aeb 66 lcd.DisplayStringAt(30,170,(uint8_t*)"Oil Temp",LEFT_MODE);
formulas 0:38c3afd99aeb 67 lcd.DisplayStringAt(30,320,(uint8_t*)"Water Temp",LEFT_MODE);
formulas 0:38c3afd99aeb 68 lcd.DisplayStringAt(584,170,(uint8_t*)"TPS",LEFT_MODE);
formulas 0:38c3afd99aeb 69 lcd.SetTextColor(LCD_COLOR_DARKRED);
formulas 0:38c3afd99aeb 70 lcd.FillRect(560,340,230,68);
formulas 0:38c3afd99aeb 71 lcd.SetBackColor(LCD_COLOR_DARKRED);
formulas 0:38c3afd99aeb 72 PrintString("BRAKE",50,575,350,LCD_COLOR_BLACK);
formulas 0:38c3afd99aeb 73 lcd.SetBackColor(LCD_COLOR_WHITE);
formulas 0:38c3afd99aeb 74
formulas 0:38c3afd99aeb 75 //Display initial values
formulas 0:38c3afd99aeb 76 PrintChar(Gears[Gear],GearXPos,GearYPos,LCD_COLOR_BLACK);
formulas 0:38c3afd99aeb 77 SetNumber(Oil_Temp,100,OilTempXPos,OilTempYPos,3,0,0);
formulas 0:38c3afd99aeb 78 SetNumber(Water_Temp,100,WaterTempXPos,WaterTempYPos,3,0,0);
formulas 0:38c3afd99aeb 79 SetNumber(TPS,100,TPSXPos,TPSYPos,3,0,0);
formulas 0:38c3afd99aeb 80 BrakeSignal(Brakes);
formulas 0:38c3afd99aeb 81 };
formulas 0:38c3afd99aeb 82
formulas 0:38c3afd99aeb 83
formulas 0:38c3afd99aeb 84 void SetFirstAux(){ // Set First Auxiliary screen
formulas 0:38c3afd99aeb 85 // Erase previous screen
formulas 0:38c3afd99aeb 86 lcd.SetTextColor(LCD_COLOR_WHITE);
formulas 0:38c3afd99aeb 87 lcd.FillRect(0,0,800,480);
formulas 0:38c3afd99aeb 88 lcd.SetTextColor(LCD_COLOR_BLACK);
formulas 0:38c3afd99aeb 89 //Draw First Auxiliary screen
formulas 2:f54f01527ebb 90 PrintString("Oil P",50,20,30,LCD_COLOR_BLACK);
formulas 2:f54f01527ebb 91 PrintString("MAP",50,20,90,LCD_COLOR_BLACK);
formulas 2:f54f01527ebb 92 PrintString("Air Temp",50,20,150,LCD_COLOR_BLACK);
formulas 2:f54f01527ebb 93 PrintString("Lambda",50,20,210,LCD_COLOR_BLACK);
formulas 2:f54f01527ebb 94 PrintString("Volts",50,20,270,LCD_COLOR_BLACK);
formulas 2:f54f01527ebb 95 PrintString("Crank",50,20,330,LCD_COLOR_BLACK);
formulas 2:f54f01527ebb 96 PrintString("Distance:",50,20,390,LCD_COLOR_BLACK);
formulas 2:f54f01527ebb 97 PrintString("kPa",50,470,30,LCD_COLOR_BLACK);
formulas 2:f54f01527ebb 98 PrintString("kPa",50,470,90,LCD_COLOR_BLACK);
formulas 2:f54f01527ebb 99 PrintString("C",50,470,150,LCD_COLOR_BLACK);
formulas 2:f54f01527ebb 100 PrintString("Ratio",50,470,210,LCD_COLOR_BLACK);
formulas 2:f54f01527ebb 101 PrintString("V",50,470,270,LCD_COLOR_BLACK);
formulas 2:f54f01527ebb 102 PrintString("km",50,550,390,LCD_COLOR_BLACK);
formulas 0:38c3afd99aeb 103 DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos);
formulas 0:38c3afd99aeb 104 //Display initial values
formulas 0:38c3afd99aeb 105 SetNumber(Oil_P,50,OilPXPos,OilPYPos,3,0,0);
formulas 0:38c3afd99aeb 106 SetNumber(MAP,50,MAPXPos,MAPYPos,3,0,0);
formulas 0:38c3afd99aeb 107 SetNumber(Air_Temp,50,AirTempXPos,AirTempYPos,3,0,0);
formulas 0:38c3afd99aeb 108 SetNumber(Lambda,50,LambdaXPos,LambdaYPos,3,0,0);
formulas 0:38c3afd99aeb 109 SetNumber(Volts,50,VoltsXPos,VoltsYPos,3,0,0);
formulas 2:f54f01527ebb 110 ChangeCrank(Crank);
formulas 2:f54f01527ebb 111 SetNumber((int)(Meter_counter/10),50,Meter_counterXPos,Meter_counterYPos,5,3,0);
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 0:38c3afd99aeb 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 0:38c3afd99aeb 138
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 0:38c3afd99aeb 152 UpdateSpeedMeter(Speed0,Speed-Speed0);
formulas 0:38c3afd99aeb 153 };
formulas 0:38c3afd99aeb 154 if(Gear!=Gear0){
formulas 0:38c3afd99aeb 155 PrintChar(Gears[Gear],GearXPos,GearYPos,LCD_COLOR_BLACK);
formulas 0:38c3afd99aeb 156 };
formulas 0:38c3afd99aeb 157 if(Oil_Temp!=Oil_Temp0){
formulas 0:38c3afd99aeb 158 ChangeNumber(Oil_Temp,Oil_Temp0,100,OilTempXPos,OilTempYPos,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 0:38c3afd99aeb 166 if(Brakes!=Brakes0){
formulas 0:38c3afd99aeb 167 BrakeSignal(Brakes);
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 0:38c3afd99aeb 173 if (Oil_P!=Oil_P0){
formulas 0:38c3afd99aeb 174 ChangeNumber(Oil_P,Oil_P0,50,OilPXPos,OilPYPos,3,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){
formulas 0:38c3afd99aeb 183 ChangeNumber(Lambda,Lambda0,50,LambdaXPos,LambdaYPos,3,0,0);
formulas 0:38c3afd99aeb 184 };
formulas 0:38c3afd99aeb 185 if (Volts!=Volts0){
formulas 0:38c3afd99aeb 186 ChangeNumber(Volts,Volts0,50,VoltsXPos,VoltsYPos,3,0,0);
formulas 0:38c3afd99aeb 187 };
formulas 0:38c3afd99aeb 188 if (Crank!=Crank0){
formulas 0:38c3afd99aeb 189 ChangeCrank(Crank);
formulas 0:38c3afd99aeb 190 };
formulas 2:f54f01527ebb 191 if (Meter_counter!=Meter_counter0){
formulas 2:f54f01527ebb 192 ChangeNumber((int)(Meter_counter/10),(int)(Meter_counter0/10),50,Meter_counterXPos,Meter_counterYPos,5,3,0);
formulas 2:f54f01527ebb 193 };
formulas 0:38c3afd99aeb 194 };
formulas 0:38c3afd99aeb 195
formulas 0:38c3afd99aeb 196 void SecondAuxUpdate(){ // Update information in Second Auxiliary screen
formulas 0:38c3afd99aeb 197 switch(ft_2aux_flag){ //Same as in Main.
formulas 0:38c3afd99aeb 198 case(0):break;
formulas 0:38c3afd99aeb 199 case(1):
formulas 0:38c3afd99aeb 200 FL_LVDT0=0;
formulas 0:38c3afd99aeb 201 FR_LVDT0=0;
formulas 0:38c3afd99aeb 202 RL_LVDT0=0;
formulas 0:38c3afd99aeb 203 RR_LVDT0=0;
formulas 0:38c3afd99aeb 204 ft_2aux_flag=0;
formulas 0:38c3afd99aeb 205 break;
formulas 0:38c3afd99aeb 206 };
formulas 0:38c3afd99aeb 207
formulas 0:38c3afd99aeb 208 if(FL_LVDT!=FL_LVDT0){
formulas 0:38c3afd99aeb 209 ChangeNumber(FL_LVDT,FL_LVDT0,100,FLLVDTXPos,FLLVDTYPos,3,0,1);
formulas 0:38c3afd99aeb 210 UpdateLVDTScale(FL_LVDT,FL_LVDT0,FLLVDTBarXPos,FLLVDTBarYPos);
formulas 0:38c3afd99aeb 211 };
formulas 0:38c3afd99aeb 212 if(FR_LVDT!=FR_LVDT0){
formulas 0:38c3afd99aeb 213 ChangeNumber(FR_LVDT,FR_LVDT0,100,FRLVDTXPos,FRLVDTYPos,3,0,1);
formulas 0:38c3afd99aeb 214 UpdateLVDTScale(FR_LVDT,FR_LVDT0,FRLVDTBarXPos,FRLVDTBarYPos);
formulas 0:38c3afd99aeb 215 };
formulas 0:38c3afd99aeb 216 if(RL_LVDT!=RL_LVDT0){
formulas 0:38c3afd99aeb 217 ChangeNumber(RL_LVDT,RL_LVDT0,100,RLLVDTXPos,RLLVDTYPos,3,0,1);
formulas 0:38c3afd99aeb 218 UpdateLVDTScale(RL_LVDT,RL_LVDT0,RLLVDTBarXPos,RLLVDTBarYPos);
formulas 0:38c3afd99aeb 219 };
formulas 0:38c3afd99aeb 220 if(RR_LVDT!=RR_LVDT0){
formulas 0:38c3afd99aeb 221 ChangeNumber(RR_LVDT,RR_LVDT0,100,RRLVDTXPos,RRLVDTYPos,3,0,1);
formulas 0:38c3afd99aeb 222 UpdateLVDTScale(RR_LVDT,RR_LVDT0,RRLVDTBarXPos,RRLVDTBarYPos);
formulas 0:38c3afd99aeb 223 };
formulas 0:38c3afd99aeb 224 };