![](/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
Revision 6:1fda11b7b0b9, committed 2021-03-07
- Comitter:
- formulas
- Date:
- Sun Mar 07 15:44:19 2021 +0000
- Parent:
- 5:4b63e6845a8e
- Commit message:
- a
Changed in this revision
diff -r 4b63e6845a8e -r 1fda11b7b0b9 CAN_library.cpp --- a/CAN_library.cpp Wed Nov 28 12:01:20 2018 +0000 +++ b/CAN_library.cpp Sun Mar 07 15:44:19 2021 +0000 @@ -10,8 +10,8 @@ extern uint8_t distance_flag; extern uint8_t lvdtref; -extern uint16_t Rpm0, Speed0, Gear0, Water_Temp0, Oil_Temp0, TPS0, Brakes0, MAP0, Air_Temp0, Lambda0, Volts0; -extern uint16_t Rpm, Speed, Gear, Water_Temp, Oil_Temp, TPS, Brakes, MAP, Air_Temp, Lambda, Volts; +extern uint16_t Rpm0, Speed0, Gear0, Water_Temp0, Bat_Temp0, TPS0, Brakes0, MAP0, Air_Temp0, Lambda0, Volts0; +extern uint16_t Rpm, Speed, Gear, Water_Temp, Bat_Temp, TPS, Brakes, MAP, Air_Temp, Lambda, Volts; extern int FL_LVDT0, FR_LVDT0, RL_LVDT0, RR_LVDT0, FL_LVDT, FR_LVDT, RL_LVDT, RR_LVDT; extern int FL_LVDT_Ref,FR_LVDT_Ref,RL_LVDT_Ref,RR_LVDT_Ref; int LVDT_Max=1024; @@ -28,29 +28,29 @@ if (can.read(tmpMsg)) { //Detect message //pc.printf("%x\n",tmpMsg.id); switch(tmpMsg.id){ //Find which DTA message is received - case(0x2000): + case(0x0 | 0x2000): rx_flag|=(1<<0); msgDTA1=tmpMsg; //pc.printf("%x\n", tmpMsg.id); break; - case(0x2001): + case(0x1 | 0x2001): rx_flag|=(1<<1); msgDTA2=tmpMsg; //pc.printf("rx_flag=%x\n",rx_flag); break; - case(0x2002): + case(0x2 | 0x2002): rx_flag|=(1<<2); msgDTA3=tmpMsg; break; - case(0x2003): + case(0x3 | 0x2003): rx_flag|=(1<<3); msgDTA4=tmpMsg; break; - case(0x2004): + case(0x4 | 0x2004): rx_flag|=(1<<4); msgDTA5=tmpMsg; break; - case(0x2005): + case(0x5 | 0x2005): rx_flag|=(1<<5); msgDTA6=tmpMsg; break; @@ -199,8 +199,8 @@ void UpdateInfoDTA3(uint16_t newData[4]){ //Update values for DTA3 message if (newData[1]>0 && newData[1]<200){ - Oil_Temp0=Oil_Temp; - Oil_Temp=newData[1]; + Bat_Temp0=Bat_Temp; + Bat_Temp=newData[1]; }; if (newData[2]>0 && newData[2]<200){ Volts0=Volts;
diff -r 4b63e6845a8e -r 1fda11b7b0b9 draw_print_library.h --- a/draw_print_library.h Wed Nov 28 12:01:20 2018 +0000 +++ b/draw_print_library.h Sun Mar 07 15:44:19 2021 +0000 @@ -24,7 +24,7 @@ //Positions of Informations on screen const uint16_t GearXPos=272,GearYPos=95; //Gear in Main -const uint16_t OilTempXPos=15,OilTempYPos=200; //Oil Temperature in Main +const uint16_t BatTempXPos=15,BatTempYPos=200; //Oil Temperature in Main const uint16_t LogoSmallXPos=635,LogoSmallYPos=5; //Small Logo, all three screens const uint16_t WaterTempXPos=15,WaterTempYPos=350; //Water Temperature in Main const uint16_t TPSXPos=569,TPSYPos=200; //TPS in Main
diff -r 4b63e6845a8e -r 1fda11b7b0b9 main.cpp --- a/main.cpp Wed Nov 28 12:01:20 2018 +0000 +++ b/main.cpp Sun Mar 07 15:44:19 2021 +0000 @@ -6,7 +6,7 @@ LCD_DISCO_F469NI lcd; //Initialize LCD Display SD_DISCO_F469NI sd; //Initialize SD Card //EEPROM_DISCO_F469NI eep; //Initialize EEPROM Internal memory -Serial pc(USBTX, USBRX); //Initialize Serial. This is used only while debuging code. +Serial pc(USBTX, USBRX,115200); //Initialize Serial. This is used only while debuging code. CAN can(PB_5, PB_13,1000000); //Initialize CAN. I2C i2c(D14, D15); DigitalOut reset(D8); @@ -57,7 +57,7 @@ } void showLedRpm(int RPM){ - pc.printf("%d\n",RPM); + //pc.printf("%d\n",RPM); if(RPM<1000) { cmd[1]=0xFF; cmd[2]=0xFF; @@ -120,18 +120,20 @@ int main(){ +//pc.printf("proba\n"); LEDInitialize(); can.attach(&CANMsgReceive,CAN::RxIrq); // Attach interrupt function to CAN RX change_screen_input.rise(&ChangeCommand); //Attach interrupt function to rising edge of DigitalIn for changing screen. SetIntro(); // Display logo when starting display SetMain(); // First screen is main by default sd.Init(); - + //pc.printf("proba1\n"); while(1){ if(change_flag){ // Check if screen is changed ChangeScreen(); }; UpdateInfo(); // Update info for DTA values in every iteration + //pc.printf("proba2\n"); switch(screen_flag){ // Display only changes visible on current screen case(1): MainUpdate();
diff -r 4b63e6845a8e -r 1fda11b7b0b9 main1.cpp --- a/main1.cpp Wed Nov 28 12:01:20 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,210 +0,0 @@ -/*#include "mbed.h" -#include "functions.h" - -LCD_DISCO_F469NI lcd; -SD_DISCO_F469NI sd; -Serial pc(USBTX, USBRX); -CAN can(PB_5, PB_13); -DigitalIn changescreen_command(D0); - -int can_data; -int RPM; -extern GEAR *Gears; -extern IMAGE LogoBig,LogoSmall,Branko; - -void MainScreen(); -void FirstAuxScreen(); -void SecondAuxScreen(); - -int main(){ - DrawRGBImage(LogoBig,0,0); - wait(0.5); - lcd.SetTextColor(LCD_COLOR_WHITE); - lcd.FillRect(0,0,800,480); - MainScreen(); -}; - - -void MainScreen(){ - lcd.SetTextColor(LCD_COLOR_BLACK); - DrawSpeedMeter(); - DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos); - lcd.SetFont(&Font24); - lcd.DisplayStringAt(30,170,(uint8_t*)"Oil Temp",LEFT_MODE); - lcd.DisplayStringAt(30,320,(uint8_t*)"Water Temp",LEFT_MODE); - lcd.DisplayStringAt(584,170,(uint8_t*)"TPS",LEFT_MODE); - lcd.SetTextColor(LCD_COLOR_DARKRED); - lcd.FillRect(560,340,230,68); - lcd.SetBackColor(LCD_COLOR_DARKRED); - PrintString("BRAKE",50,575,350,LCD_COLOR_BLACK); - lcd.SetBackColor(LCD_COLOR_WHITE); - - int Vin,V0=0,OilTemp,OilTemp0=0,WaterTemp,WaterTemp0=0,TPS,TPS0=0,Brake,Brake0=0,Gear,Gear0; - - CANMessage msg; - - //inicijalne vrednosti prikazane na ekranu - PrintChar(Gears[0],GearXPos,GearYPos,LCD_COLOR_BLACK); - ChangeNumber(0,111,100,OilTempXPos,OilTempYPos); - ChangeNumber(0,111,100,WaterTempXPos,WaterTempYPos); - ChangeNumber(0,111,100,TPSXPos,TPSYPos); - BrakeSignal(0,1); - wait(1); - while(changescreen_command.read()==0){ - if(can.read(msg)){ - can_data=msg.data[0]; - lcd.SetTextColor(LCD_COLOR_BLACK); - if (msg.id==SPEED_ID){ - Vin=(int)can_data; - UpdateSpeedMeter(V0,Vin-V0); - V0=Vin; - }else if (msg.id==GEAR_ID){ - Gear=can_data; - if(Gear!=Gear0){ - Gear=can_data; - printf("%d\n",Gear); - PrintChar(Gears[Gear],GearXPos,GearYPos,LCD_COLOR_BLACK); - Gear0=Gear; - }; - }else if (msg.id==OIL_TEMP_ID){ - OilTemp=can_data; - ChangeNumber(OilTemp,OilTemp0,100,OilTempXPos,OilTempYPos); - OilTemp0=OilTemp; - }else if (msg.id==WATER_TEMP_ID){ - WaterTemp=can_data; - ChangeNumber(WaterTemp,WaterTemp0,100,WaterTempXPos,WaterTempYPos); - WaterTemp0=WaterTemp; - }else if (msg.id==TPS_ID){ - TPS=can_data; - ChangeNumber(TPS,TPS0,100,TPSXPos,TPSYPos); - TPS0=TPS; - }else if (msg.id==BRAKE_ID){ - Brake=can_data; - BrakeSignal(Brake,Brake0); - Brake0=Brake; - }; - }; - }; - lcd.SetTextColor(LCD_COLOR_WHITE); - lcd.FillRect(0,0,800,480); - FirstAuxScreen(); - lcd.SetTextColor(LCD_COLOR_BLACK); -}; - -void FirstAuxScreen(){ - PrintString("Oil P",50,20,25,LCD_COLOR_BLACK); - PrintString("MAP",50,20,100,LCD_COLOR_BLACK); - PrintString("Air Temp",50,20,175,LCD_COLOR_BLACK); - PrintString("Lambda",50,20,250,LCD_COLOR_BLACK); - PrintString("Volts",50,20,325,LCD_COLOR_BLACK); - PrintString("Crank",50,20,400,LCD_COLOR_BLACK); - PrintString("kPa",50,470,25,LCD_COLOR_BLACK); - PrintString("kPa",50,470,100,LCD_COLOR_BLACK); - PrintString("C",50,470,175,LCD_COLOR_BLACK); - PrintString("Ratio",50,470,250,LCD_COLOR_BLACK); - PrintString("V",50,470,325,LCD_COLOR_BLACK); - DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos); - - uint8_t OilP,OilP0=0,MAP,MAP0=0,AirTemp,AirTemp0=0,Lambda,Lambda0=0,Volts,Volts0=0,Crank,Crank0=1; - - CANMessage msg; - - ChangeNumber(0,111,50,OilPXPos,OilPYPos); - ChangeNumber(0,111,50,MAPXPos,MAPYPos); - ChangeNumber(0,111,50,AirTempXPos,AirTempYPos); - ChangeNumber(0,111,50,LambdaXPos,LambdaYPos); - ChangeNumber(0,111,50,VoltsXPos,VoltsYPos); - - while(changescreen_command.read()==0){ - if(can.read(msg)){ - can_data=msg.data[0]; - lcd.SetTextColor(LCD_COLOR_BLACK); - if (msg.id==OIL_P_ID){ - OilP=can_data; - ChangeNumber(OilP,OilP0,100,OilPXPos,OilPYPos); - OilP0=OilP; - }else if (msg.id==MAP_ID){ - MAP=can_data; - ChangeNumber(MAP,MAP0,100,MAPXPos,MAPYPos); - MAP0=MAP; - }else if (msg.id==AIR_TEMP_ID){ - AirTemp=can_data; - ChangeNumber(AirTemp,AirTemp0,100,AirTempXPos,AirTempYPos); - AirTemp0=AirTemp; - }else if (msg.id==LAMBDA_ID){ - Lambda=can_data; - ChangeNumber(Lambda,Lambda0,100,LambdaXPos,LambdaYPos); - Lambda0=Lambda; - }else if (msg.id==VOLTS_ID){ - Volts=can_data; - ChangeNumber(Volts,Volts0,100,VoltsXPos,VoltsYPos); - Volts0=Volts; - }else if (msg.id==CRANK_ID){ - Crank=can_data; - if(Crank!=Crank0){ - if(Crank==1){ - PrintString("ERROR",50,CrankXPos,CrankYPos,LCD_COLOR_RED); - }else if(Crank==0){ - PrintString("OK",50,CrankXPos,CrankYPos,LCD_COLOR_RED); - }; - }; - Crank0=Crank; - }; - }; - }; - lcd.SetTextColor(LCD_COLOR_WHITE); - lcd.FillRect(0,0,800,480); - SecondAuxScreen(); - -}; - -void SecondAuxScreen(){ - PrintString("LVDT Sensors",50,200,20,LCD_COLOR_BLACK); - DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos); - lcd.SetTextColor(LCD_COLOR_BLACK); - lcd.SetFont(&Font24); - lcd.DisplayStringAt(FLLVDTBarXPos+25,FLLVDTBarYPos,(uint8_t*)"FL",LEFT_MODE); - lcd.DisplayStringAt(FRLVDTBarXPos+25,FRLVDTBarYPos,(uint8_t*)"FR",LEFT_MODE); - lcd.DisplayStringAt(BLLVDTBarXPos+25,BLLVDTBarYPos,(uint8_t*)"BL",LEFT_MODE); - lcd.DisplayStringAt(BRLVDTBarXPos+25,BRLVDTBarYPos,(uint8_t*)"BR",LEFT_MODE); - - uint8_t FLLVDT,FLLVDT0=0,FRLVDT,FRLVDT0=0,BLLVDT,BLLVDT0=0,BRLVDT,BRLVDT0=0; - - CANMessage msg; - - ChangeNumber(0,111,100,FLLVDTXPos,FLLVDTYPos); - ChangeNumber(0,111,100,FRLVDTXPos,FRLVDTYPos); - ChangeNumber(0,111,100,BLLVDTXPos,BLLVDTYPos); - ChangeNumber(0,111,100,BRLVDTXPos,BRLVDTYPos); - - while(changescreen_command.read()==0){ - if(can.read(msg)){ - can_data=msg.data[0]; - if(msg.id==FL_LVDT_ID){ - FLLVDT=can_data; - ChangeNumber(FLLVDT,FLLVDT0,100,FLLVDTXPos,FLLVDTYPos); - UpdateLVDTScale(FLLVDT,FLLVDT0,FLLVDTBarXPos,FLLVDTBarYPos); - FLLVDT0=FLLVDT; - }else if(msg.id==FR_LVDT_ID){ - FRLVDT=can_data; - ChangeNumber(FRLVDT,FRLVDT0,100,FRLVDTXPos,FRLVDTYPos); - UpdateLVDTScale(FRLVDT,FRLVDT0,FRLVDTBarXPos,FRLVDTBarYPos); - FRLVDT0=FRLVDT; - }else if(msg.id==BL_LVDT_ID){ - BLLVDT=can_data; - ChangeNumber(BLLVDT,BLLVDT0,100,BLLVDTXPos,BLLVDTYPos); - UpdateLVDTScale(BLLVDT,BLLVDT0,BLLVDTBarXPos,BLLVDTBarYPos); - BLLVDT0=BLLVDT; - }else if(msg.id==BR_LVDT_ID){ - BRLVDT=can_data; - ChangeNumber(BRLVDT,BRLVDT0,100,BRLVDTXPos,BRLVDTYPos); - UpdateLVDTScale(BRLVDT,BRLVDT0,BRLVDTBarXPos,BRLVDTBarYPos); - BRLVDT0=BRLVDT; - }; - }; - }; - lcd.SetTextColor(LCD_COLOR_WHITE); - lcd.FillRect(0,0,800,480); - lcd.SetTextColor(LCD_COLOR_BLACK); - MainScreen(); -};*/ \ No newline at end of file
diff -r 4b63e6845a8e -r 1fda11b7b0b9 screen_library.cpp --- a/screen_library.cpp Wed Nov 28 12:01:20 2018 +0000 +++ b/screen_library.cpp Sun Mar 07 15:44:19 2021 +0000 @@ -8,8 +8,8 @@ extern GEAR *Gears; extern IMAGE LogoBig,LogoSmall,Branko,NewYearCongat; -extern uint16_t Rpm0, Speed0, Gear0, Water_Temp0, Oil_Temp0, TPS0, Brakes0, MAP0, Air_Temp0, Lambda0, Volts0, Crank0; -extern uint16_t Rpm, Speed, Gear, Water_Temp, Oil_Temp, TPS, Brakes, MAP, Air_Temp, Lambda, Volts, Crank; +extern uint16_t Rpm0, Speed0, Gear0, Water_Temp0, Bat_Temp0, TPS0, Brakes0, MAP0, Air_Temp0, Lambda0, Volts0, Crank0; +extern uint16_t Rpm, Speed, Gear, Water_Temp, Bat_Temp, TPS, Brakes, MAP, Air_Temp, Lambda, Volts, Crank; extern int FL_LVDT0, FR_LVDT0, RL_LVDT0, RR_LVDT0, FL_LVDT, FR_LVDT, RL_LVDT, RR_LVDT; extern int FL_LVDT_Ref,FR_LVDT_Ref,RL_LVDT_Ref,RR_LVDT_Ref; extern int LVDT_Max; @@ -54,7 +54,7 @@ DrawSpeedMeter(); DrawRGBImage(LogoSmall,LogoSmallXPos,LogoSmallYPos); lcd.SetFont(&Font24); - lcd.DisplayStringAt(30,170,(uint8_t*)"Oil Temp",LEFT_MODE); + lcd.DisplayStringAt(30,170,(uint8_t*)"Battery Temp",LEFT_MODE); lcd.DisplayStringAt(30,320,(uint8_t*)"Water Temp",LEFT_MODE); lcd.DisplayStringAt(584,170,(uint8_t*)"TPS",LEFT_MODE); lcd.SetTextColor(LCD_COLOR_DARKRED); @@ -65,7 +65,7 @@ //Display initial values PrintChar(Gears[Gear],GearXPos,GearYPos,LCD_COLOR_BLACK); - SetNumber(Oil_Temp,100,OilTempXPos,OilTempYPos,3,0,0); + SetNumber(Bat_Temp,100,BatTempXPos,BatTempYPos,3,0,0); SetNumber(Water_Temp,100,WaterTempXPos,WaterTempYPos,3,0,0); SetNumber(TPS,100,TPSXPos,TPSYPos,3,0,0); BrakeSignal(Brakes); @@ -143,8 +143,8 @@ if(Gear!=Gear0){ PrintChar(Gears[Gear],GearXPos,GearYPos,LCD_COLOR_BLACK); }; - if(Oil_Temp!=Oil_Temp0){ - ChangeNumber(Oil_Temp,Oil_Temp0,100,OilTempXPos,OilTempYPos,3,0,0); + if(Bat_Temp!=Bat_Temp0){ + ChangeNumber(Bat_Temp,Bat_Temp0,100,BatTempXPos,BatTempYPos,3,0,0); }; if(Water_Temp!=Water_Temp0){ ChangeNumber(Water_Temp,Water_Temp0,100,WaterTempXPos,WaterTempYPos,3,0,0);