The Code Repository for the REV0 Steering Wheel.

Dependencies:   CANBuffer KS0108_fork mbed-rtos mbed CAN Addresses

Fork of REVO_Updated_Steering by Penn Electric

Committer:
tmccurbin
Date:
Sun Feb 08 08:53:44 2015 +0000
Revision:
41:7c5ea411fad2
Parent:
40:92f08fdc32df
Child:
42:701df58e923a
Power bar implemented

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kiran_mbed 0:313541d8f8be 1 #include "Steering.h"
kiran_mbed 0:313541d8f8be 2
tmccurbin 36:8544a8900884 3 // To-Do:
tmccurbin 38:d04a430d7fe3 4 // Look at SYS management CAN translations: shutdown switches, DCDC status, & IMD (this is a resistance, in ohms)
tmccurbin 38:d04a430d7fe3 5 // Figure out screen/variable updating options (hardware filter), NVIC_SetPriority(CAN_IRQn,####)LPC17xx.h
tmccurbin 36:8544a8900884 6 // Firgure out fault protocall
tmccurbin 36:8544a8900884 7
tmccurbin 36:8544a8900884 8 void Init();
tmccurbin 36:8544a8900884 9 void ProcessButtons(void const *args);
tmccurbin 36:8544a8900884 10 void RequestStatusChange();
tmccurbin 36:8544a8900884 11 void ResetSteeringWheel();
tmccurbin 36:8544a8900884 12 void ResetCar();
tmccurbin 36:8544a8900884 13 void ProcessCANMsg(CANMessage& msg);
tmccurbin 36:8544a8900884 14 void UpdateDisplay();
tmccurbin 36:8544a8900884 15 void ProcessButtons(void const *args);
tmccurbin 36:8544a8900884 16 void ConnectedStatusCANMsg();
tmccurbin 36:8544a8900884 17
tmccurbin 36:8544a8900884 18 float CANFloat;
tmccurbin 36:8544a8900884 19 float CANFloat2;
tmccurbin 36:8544a8900884 20
tmccurbin 36:8544a8900884 21 Ticker StatusMsg;
kiran_mbed 0:313541d8f8be 22
tmccurbin 36:8544a8900884 23 int main()
tmccurbin 36:8544a8900884 24 {
tmccurbin 36:8544a8900884 25 Init();
tmccurbin 36:8544a8900884 26
tmccurbin 39:e6aa6dcf3f75 27 CANMessage Rxmsg;
tmccurbin 36:8544a8900884 28
tmccurbin 36:8544a8900884 29 Thread Thread2(ProcessButtons);
tmccurbin 36:8544a8900884 30 Thread Thread1(DisplayCurrScreen);
tmccurbin 36:8544a8900884 31
tmccurbin 36:8544a8900884 32 while(1) {
tmccurbin 36:8544a8900884 33 if (SteeringCANPort.rxRead(Rxmsg)) {
tmccurbin 36:8544a8900884 34 ProcessCANMsg(Rxmsg);
tmccurbin 32:535acb159709 35 }
tmccurbin 32:535acb159709 36 }
tmccurbin 32:535acb159709 37 }
tmccurbin 32:535acb159709 38
kiran_mbed 0:313541d8f8be 39
kiran_mbed 0:313541d8f8be 40 void Init()
kiran_mbed 0:313541d8f8be 41 {
tmccurbin 36:8544a8900884 42 StatusMsg.attach(&ConnectedStatusCANMsg,0.1);
palimar 23:6681a38918c6 43 pc.baud(921600);
tmccurbin 36:8544a8900884 44 BLButtonRed;
tmccurbin 36:8544a8900884 45 BRButtonGreen;
tmccurbin 36:8544a8900884 46 TLButtonGreen;
tmccurbin 36:8544a8900884 47 TRButtonGreen;
tmccurbin 36:8544a8900884 48 //initialize screen Startup Process
tmccurbin 36:8544a8900884 49 wait(2);
kiran_mbed 0:313541d8f8be 50 }
kiran_mbed 0:313541d8f8be 51
tmccurbin 36:8544a8900884 52
tmccurbin 36:8544a8900884 53 void ProcessButtons(void const *args)
tmccurbin 36:8544a8900884 54 {
tmccurbin 36:8544a8900884 55 while(1) {
tmccurbin 36:8544a8900884 56 Thread::wait(50);
tmccurbin 36:8544a8900884 57 if(biSWBR.read()) {
tmccurbin 36:8544a8900884 58 Thread::wait(750);
tmccurbin 36:8544a8900884 59 if (biSWBR.read()) {
tmccurbin 36:8544a8900884 60 ResetCar();
tmccurbin 36:8544a8900884 61 }
tmccurbin 36:8544a8900884 62 NVIC_SystemReset();
tmccurbin 36:8544a8900884 63 ResetSteeringWheel();
tmccurbin 36:8544a8900884 64 }
tmccurbin 36:8544a8900884 65
tmccurbin 36:8544a8900884 66 if(biSWBL.read()) {
tmccurbin 36:8544a8900884 67 Thread::wait(1000);
tmccurbin 36:8544a8900884 68 if (biSWBL.read()) {
tmccurbin 36:8544a8900884 69 RequestStatusChange();
palimar 23:6681a38918c6 70 }
palimar 21:56890c41ecf1 71 }
tmccurbin 36:8544a8900884 72
tmccurbin 36:8544a8900884 73 if(biSWTR.read() && CurrScreen != 5) {
tmccurbin 36:8544a8900884 74 //If the toggle button is pressed and the screen isn't on Fault_Screen
tmccurbin 36:8544a8900884 75 ToggleScreen();
tmccurbin 36:8544a8900884 76 Thread::wait(250);
tmccurbin 36:8544a8900884 77 } else if (biSWTR.read() && CurrScreen == 5) {// If the screen was on Fault, go to Home
tmccurbin 36:8544a8900884 78 CurrScreen = 0;
tmccurbin 36:8544a8900884 79 Thread::wait(250);
tmccurbin 36:8544a8900884 80 }
tmccurbin 36:8544a8900884 81
tmccurbin 36:8544a8900884 82 if(biSWTL.read() && CurrScreen != 0) {
tmccurbin 36:8544a8900884 83 //If the Home button is pressed and the screen isn't on Fault_Screen
tmccurbin 36:8544a8900884 84 CurrScreen = 0;
tmccurbin 36:8544a8900884 85 Thread::wait(250);
tmccurbin 36:8544a8900884 86 } else if (biSWTL.read() && CurrScreen == 0) {// If the screen was on Fault, go to Home
tmccurbin 36:8544a8900884 87 CurrScreen = 5;
tmccurbin 36:8544a8900884 88 Thread::wait(250);
tmccurbin 36:8544a8900884 89 }
palimar 21:56890c41ecf1 90 }
palimar 35:b42afc973902 91 }
palimar 21:56890c41ecf1 92
tmccurbin 36:8544a8900884 93
tmccurbin 36:8544a8900884 94 void UpdateDisplay()
tmccurbin 36:8544a8900884 95 {
tmccurbin 36:8544a8900884 96 }
tmccurbin 36:8544a8900884 97
tmccurbin 36:8544a8900884 98
tmccurbin 36:8544a8900884 99 void ProcessCANMsg(CANMessage& Rxmsg)
tmccurbin 36:8544a8900884 100 {
tmccurbin 36:8544a8900884 101 if (SteeringCANPort.rxRead(Rxmsg)) {
tmccurbin 39:e6aa6dcf3f75 102 // Printing CAN message data:
tmccurbin 39:e6aa6dcf3f75 103 // printf("Message ID: 0x%x len: %d hex: 0x%x float: %f\r\n", Rxmsg.id, Rxmsg.len, *((int*)((void*)(&Rxmsg.data[0]))), *((float*)((void*)(&Rxmsg.data[0]))));
tmccurbin 39:e6aa6dcf3f75 104 // for (int i=0; i < Rxmsg.len; i++) printf("D[%d]: %x ", i, Rxmsg.data[i]);
tmccurbin 40:92f08fdc32df 105 if (Rxmsg.id == MODE_TX_ID) {
tmccurbin 40:92f08fdc32df 106 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 107 sprintf(&DriveStatus,"%3.2d", int(CANFloat)); //confirm that I am interpreting this correctly
tmccurbin 40:92f08fdc32df 108 DriveStatusRequestBuffer = !DriveStatus;
tmccurbin 40:92f08fdc32df 109 if (DriveStatus == 1) {
tmccurbin 40:92f08fdc32df 110 BLButtonGreen;
tmccurbin 40:92f08fdc32df 111 } else {
tmccurbin 40:92f08fdc32df 112 BLButtonRed;
tmccurbin 40:92f08fdc32df 113 }
tmccurbin 40:92f08fdc32df 114 }
tmccurbin 40:92f08fdc32df 115
tmccurbin 41:7c5ea411fad2 116 if (Rxmsg.id == POWER_TX_ID) {
tmccurbin 41:7c5ea411fad2 117 CANFloat = GetFloat;
tmccurbin 41:7c5ea411fad2 118 LEDBar = (CANFloat/85.0)*(2.6/3.3);
tmccurbin 41:7c5ea411fad2 119 }
tmccurbin 41:7c5ea411fad2 120
tmccurbin 40:92f08fdc32df 121 switch (CurrScreen) {
tmccurbin 40:92f08fdc32df 122 case HOME_SCREEN:
tmccurbin 40:92f08fdc32df 123 switch (Rxmsg.id) {
palimar 4:a4fb060e7840 124
tmccurbin 40:92f08fdc32df 125 // HOME SCREEN *******************************************************************************************
tmccurbin 40:92f08fdc32df 126 // Pedal Test
tmccurbin 41:7c5ea411fad2 127 /*case PCM_PEDALS_ID:
tmccurbin 41:7c5ea411fad2 128 CANFloat = GetFloat;
tmccurbin 41:7c5ea411fad2 129 if (abs(CANFloat*100 - float (*AccPedalBuffer)) >= 1) {
tmccurbin 41:7c5ea411fad2 130 sprintf(AccPedalBuffer,"%3.2d", int(CANFloat*100));
tmccurbin 41:7c5ea411fad2 131 display.PutString(1,40,AccPedalBuffer);
tmccurbin 41:7c5ea411fad2 132 }
tmccurbin 41:7c5ea411fad2 133 CANFloat2 = GetFloat4;
tmccurbin 41:7c5ea411fad2 134 if (abs(CANFloat2*100 - float (*BrkPedalBuffer)) >= 1) {
tmccurbin 41:7c5ea411fad2 135 sprintf(BrkPedalBuffer,"%3.2d", int(CANFloat2*100));
tmccurbin 41:7c5ea411fad2 136 display.PutString(1,60,BrkPedalBuffer);
tmccurbin 41:7c5ea411fad2 137 }
tmccurbin 41:7c5ea411fad2 138 break;*/
tmccurbin 41:7c5ea411fad2 139
tmccurbin 41:7c5ea411fad2 140 case SOC_TX_ID:
tmccurbin 40:92f08fdc32df 141 CANFloat = GetFloat;
tmccurbin 41:7c5ea411fad2 142 if (abs(CANFloat*100 - *BigBatLifeBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 143 sprintf(BigBatLifeBuffer,"%3.2d", int(CANFloat*100)); // Big battery life percentage
tmccurbin 41:7c5ea411fad2 144 display.PutString(1,40,BigBatLifeBuffer);
tmccurbin 40:92f08fdc32df 145 }
tmccurbin 41:7c5ea411fad2 146 break;
tmccurbin 41:7c5ea411fad2 147 case SYS_GLV_SOC_ID:
tmccurbin 41:7c5ea411fad2 148 CANFloat = GetFloat;
tmccurbin 41:7c5ea411fad2 149 if (abs(CANFloat*100 - *SmallBatLifeBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 150 sprintf(SmallBatLifeBuffer,"%3.2d", int(CANFloat*100)); // Small battery life percentage
tmccurbin 41:7c5ea411fad2 151 display.PutString(1,60,SmallBatLifeBuffer);
tmccurbin 41:7c5ea411fad2 152 }
tmccurbin 41:7c5ea411fad2 153 break;
tmccurbin 40:92f08fdc32df 154 case PCM_FRPM_ID:
tmccurbin 40:92f08fdc32df 155 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 156 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 157 if (abs((CANFloat+CANFloat2)*WheelCircumference*30 - *CarSpdBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 158 sprintf(CarSpdBuffer,"%3.2d", int((CANFloat+CANFloat2)*WheelCircumference*30)); // Miles per hour
tmccurbin 40:92f08fdc32df 159 display.PutString(1,108,CarSpdBuffer);
tmccurbin 40:92f08fdc32df 160 }
tmccurbin 40:92f08fdc32df 161 break;
tmccurbin 40:92f08fdc32df 162 case TEMP_MMA_TX_ID_BASE2:
tmccurbin 40:92f08fdc32df 163 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 164 if (abs((CANFloat*9.0/5.0)+32 - *AvgBatTBuffer) >=1) {
tmccurbin 40:92f08fdc32df 165 sprintf(AvgBatTBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Degrees F
tmccurbin 40:92f08fdc32df 166 display.PutString(3,39,AvgBatTBuffer);
tmccurbin 40:92f08fdc32df 167 }
tmccurbin 40:92f08fdc32df 168 break;
tmccurbin 40:92f08fdc32df 169 case TEMP_MMA_TX_ID_BASE:
tmccurbin 40:92f08fdc32df 170 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 171 if (abs((CANFloat2*9.0/5.0)+32 - *MaxBatTBuffer) >=1) {
tmccurbin 41:7c5ea411fad2 172 sprintf(MaxBatTBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 173 display.PutString(3,103,MaxBatTBuffer);
tmccurbin 40:92f08fdc32df 174 }
tmccurbin 40:92f08fdc32df 175 break;
tmccurbin 40:92f08fdc32df 176 case MOC_MOTEMP_ID:
tmccurbin 40:92f08fdc32df 177 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 178 if (abs((CANFloat*9.0/5.0)+32 - *LMtrTmpBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 179 sprintf(LMtrTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 180 display.PutString(5,34,LMtrTmpBuffer);
tmccurbin 40:92f08fdc32df 181 }
tmccurbin 40:92f08fdc32df 182 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 183 if (abs((CANFloat2*9.0/5.0)+32 - *RMtrTmpBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 184 sprintf(RMtrTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 185 display.PutString(5,34,RMtrTmpBuffer);
tmccurbin 40:92f08fdc32df 186 }
tmccurbin 40:92f08fdc32df 187 break;
tmccurbin 40:92f08fdc32df 188 default:
tmccurbin 40:92f08fdc32df 189 break;
tmccurbin 39:e6aa6dcf3f75 190 }
tmccurbin 39:e6aa6dcf3f75 191 break;
tmccurbin 40:92f08fdc32df 192 // BATTERY SCREEN***********************************************************************************
tmccurbin 40:92f08fdc32df 193 case BATTERY_SCREEN:
tmccurbin 40:92f08fdc32df 194 switch (Rxmsg.id) {
tmccurbin 40:92f08fdc32df 195 case VOLTAGE_TX_ID:
tmccurbin 40:92f08fdc32df 196 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 197 if (abs(CANFloat - *BigBatVoltBuffer) >= 0.1) {
tmccurbin 40:92f08fdc32df 198 sprintf(BigBatVoltBuffer,"%3.2d", int(CANFloat)); // Volts
tmccurbin 40:92f08fdc32df 199 display.PutString(1,10,BigBatVoltBuffer);
tmccurbin 40:92f08fdc32df 200 }
tmccurbin 40:92f08fdc32df 201 break;
tmccurbin 40:92f08fdc32df 202 case POWER_TX_ID:
tmccurbin 40:92f08fdc32df 203 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 204 LEDBar = (CANFloat/85.0)*(2.6/3.3);
tmccurbin 40:92f08fdc32df 205 if (abs(CANFloat - *BigBatPowerBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 206 sprintf(BigBatPowerBuffer,"%3.2d", int(CANFloat)); // Watts
tmccurbin 40:92f08fdc32df 207 display.PutString(1,55,BigBatPowerBuffer);
tmccurbin 40:92f08fdc32df 208 }
tmccurbin 40:92f08fdc32df 209 break;
tmccurbin 40:92f08fdc32df 210 case CURRENT_TX_ID:
tmccurbin 40:92f08fdc32df 211 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 212 if (abs(CANFloat - *BigBatCurrentBuffer) >= 0.2) {
tmccurbin 40:92f08fdc32df 213 sprintf(BigBatCurrentBuffer,"%3.2d", int(CANFloat)); // Amps
tmccurbin 40:92f08fdc32df 214 display.PutString(1,100,BigBatCurrentBuffer);
tmccurbin 40:92f08fdc32df 215 }
tmccurbin 40:92f08fdc32df 216 break;
tmccurbin 40:92f08fdc32df 217 case CELLV_MMA_TX_ID_BASE:
tmccurbin 40:92f08fdc32df 218 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 219 if (abs(CANFloat2 - *VmaxBuffer) >= 0.1) {
tmccurbin 41:7c5ea411fad2 220 sprintf(VmaxBuffer,"%3.2d", int(CANFloat2));
tmccurbin 40:92f08fdc32df 221 display.PutString(3,20,VmaxBuffer);
tmccurbin 40:92f08fdc32df 222 }
tmccurbin 40:92f08fdc32df 223 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 224 if (abs(CANFloat - *VminBuffer) >= 0.1) {
tmccurbin 40:92f08fdc32df 225 sprintf(VminBuffer,"%3.2d", int(CANFloat));
tmccurbin 40:92f08fdc32df 226 display.PutString(3,67,VminBuffer);
tmccurbin 40:92f08fdc32df 227 }
tmccurbin 40:92f08fdc32df 228 break;
tmccurbin 40:92f08fdc32df 229 case CELLV_MMA_TX_ID_BASE2:
tmccurbin 40:92f08fdc32df 230 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 231 if (abs(CANFloat - *VavgBuffer) >= 0.1) {
tmccurbin 40:92f08fdc32df 232 sprintf(VavgBuffer,"%3.2d", int(CANFloat)); // Volts
tmccurbin 40:92f08fdc32df 233 display.PutString(3,108,VavgBuffer);
tmccurbin 40:92f08fdc32df 234 }
tmccurbin 40:92f08fdc32df 235 break;
tmccurbin 40:92f08fdc32df 236 case TEMP_MMA_TX_ID_BASE:
tmccurbin 40:92f08fdc32df 237 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 238 if (abs((CANFloat*9.0/5.0)+32 - *MinBatTBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 239 sprintf(MinBatTBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 240 display.PutString(5,67,MinBatTBuffer);
tmccurbin 40:92f08fdc32df 241 }
tmccurbin 40:92f08fdc32df 242 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 243 if (abs((CANFloat2*9.0/5.0)+32 - *MaxBatTBuffer) >=1) {
tmccurbin 41:7c5ea411fad2 244 sprintf(MaxBatTBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 245 display.PutString(5,20,MaxBatTBuffer);
tmccurbin 40:92f08fdc32df 246 }
tmccurbin 40:92f08fdc32df 247 break;
tmccurbin 40:92f08fdc32df 248 case TEMP_MMA_TX_ID_BASE2:
tmccurbin 40:92f08fdc32df 249 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 250 if (abs((CANFloat*9.0/5.0)+32 - *AvgBatTBuffer) >=1) {
tmccurbin 40:92f08fdc32df 251 sprintf(AvgBatTBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Degrees F
tmccurbin 40:92f08fdc32df 252 display.PutString(5,108,AvgBatTBuffer);
tmccurbin 40:92f08fdc32df 253 }
tmccurbin 40:92f08fdc32df 254 break;
tmccurbin 40:92f08fdc32df 255 case BOARDTEMP_TX_ID:
tmccurbin 40:92f08fdc32df 256 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 257 if (abs((CANFloat*9.0/5.0)+32 - *BoardTempBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 258 sprintf(BoardTempBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Degrees F
tmccurbin 40:92f08fdc32df 259 display.PutString(7,87,BoardTempBuffer);
tmccurbin 40:92f08fdc32df 260 }
tmccurbin 40:92f08fdc32df 261 break;
tmccurbin 40:92f08fdc32df 262 default:
tmccurbin 40:92f08fdc32df 263 break;
tmccurbin 39:e6aa6dcf3f75 264 }
tmccurbin 39:e6aa6dcf3f75 265 break;
tmccurbin 36:8544a8900884 266 // MOTOR SCREEN*****************************************************************
tmccurbin 40:92f08fdc32df 267 case MOTOR_SCREEN:
tmccurbin 40:92f08fdc32df 268 switch (Rxmsg.id) {
tmccurbin 40:92f08fdc32df 269 case MOC_MOTEMP_ID:
tmccurbin 40:92f08fdc32df 270 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 271 if (abs((CANFloat*9.0/5.0)+32 - *LMtrTmpBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 272 sprintf(LMtrTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 273 display.PutString(1,34,LMtrTmpBuffer);
tmccurbin 40:92f08fdc32df 274 }
tmccurbin 40:92f08fdc32df 275 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 276 if (abs((CANFloat2*9.0/5.0)+32 - *RMtrTmpBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 277 sprintf(RMtrTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 278 display.PutString(1,98,LMtrTmpBuffer);
tmccurbin 40:92f08fdc32df 279 }
tmccurbin 40:92f08fdc32df 280 break;
tmccurbin 40:92f08fdc32df 281 case MOC_AIRTEMP_ID:
tmccurbin 40:92f08fdc32df 282 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 283 if (abs((CANFloat*9.0/5.0)+32 - *LAirTmpBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 284 sprintf(LAirTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 285 display.PutString(2,34,LAirTmpBuffer);
tmccurbin 40:92f08fdc32df 286 }
tmccurbin 40:92f08fdc32df 287 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 288 if (abs((CANFloat2*9.0/5.0)+32 - *RAirTmpBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 289 sprintf(RAirTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); // Degrees F
tmccurbin 40:92f08fdc32df 290 display.PutString(2,98,RAirTmpBuffer);
tmccurbin 40:92f08fdc32df 291 }
tmccurbin 40:92f08fdc32df 292 break;
tmccurbin 40:92f08fdc32df 293 case MOC_IGBTTEMP_ID:
tmccurbin 40:92f08fdc32df 294 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 295 if (abs((CANFloat*9.0/5.0)+32 - *LIGBTmpBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 296 sprintf(LIGBTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 297 display.PutString(3,34,LIGBTmpBuffer);
tmccurbin 40:92f08fdc32df 298 }
tmccurbin 40:92f08fdc32df 299 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 300 if (abs((CANFloat2*9.0/5.0)+32 - *RIGBTmpBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 301 sprintf(RIGBTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); // Degrees F
tmccurbin 40:92f08fdc32df 302 display.PutString(3,98,RIGBTmpBuffer);
tmccurbin 40:92f08fdc32df 303 }
tmccurbin 40:92f08fdc32df 304 break;
tmccurbin 40:92f08fdc32df 305 case MOC_RPM_ID:
tmccurbin 40:92f08fdc32df 306 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 307 if (abs(CANFloat - *Rpm_LBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 308 sprintf(Rpm_LBuffer,"%3.2d", int(CANFloat));
tmccurbin 40:92f08fdc32df 309 display.PutString(5,30,Rpm_LBuffer);
tmccurbin 40:92f08fdc32df 310 }
tmccurbin 40:92f08fdc32df 311 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 312 if (abs(CANFloat2 - *Rpm_RBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 313 sprintf(Rpm_RBuffer,"%3.2d", int(CANFloat2));
tmccurbin 40:92f08fdc32df 314 display.PutString(5,107,Rpm_RBuffer);
tmccurbin 40:92f08fdc32df 315 }
tmccurbin 40:92f08fdc32df 316 break;
tmccurbin 40:92f08fdc32df 317 case PCM_TORQUERQ_ID:
tmccurbin 40:92f08fdc32df 318 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 319 if (abs(CANFloat*100 - *TRequestBufferL) >= 1) {
tmccurbin 40:92f08fdc32df 320 sprintf(TRequestBufferL,"%3.2d", int(CANFloat*100)); // Percentage
tmccurbin 40:92f08fdc32df 321 display.PutString(7,89,TRequestBufferL);
tmccurbin 40:92f08fdc32df 322 }
tmccurbin 40:92f08fdc32df 323 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 324 if (abs(CANFloat2*100 - *TRequestBufferR) >= 1) {
tmccurbin 40:92f08fdc32df 325 sprintf(TRequestBufferR,"%3.2d", int(CANFloat2*100)); // Percentage
tmccurbin 40:92f08fdc32df 326 display.PutString(7,89,TRequestBufferR);
tmccurbin 40:92f08fdc32df 327 }
tmccurbin 40:92f08fdc32df 328 break;
tmccurbin 40:92f08fdc32df 329 default:
tmccurbin 40:92f08fdc32df 330 break;
tmccurbin 39:e6aa6dcf3f75 331 }
tmccurbin 39:e6aa6dcf3f75 332 break;
tmccurbin 36:8544a8900884 333
tmccurbin 36:8544a8900884 334 // SYSTEM MANAGEMENT SCREEN***************************************************
tmccurbin 40:92f08fdc32df 335 case SYS_MGMT_SCREEN:
tmccurbin 40:92f08fdc32df 336 switch (Rxmsg.id) {
tmccurbin 40:92f08fdc32df 337 case SYS_GLV_CURRENT_ID:
tmccurbin 40:92f08fdc32df 338 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 339 if (abs(CANFloat - *SmallBatCurrentBuffer) >= 0.2) {
tmccurbin 40:92f08fdc32df 340 sprintf(SmallBatCurrentBuffer,"%3.2d", int(CANFloat)); // Amps
tmccurbin 40:92f08fdc32df 341 display.PutString(1,30,SmallBatCurrentBuffer);
tmccurbin 40:92f08fdc32df 342 }
tmccurbin 40:92f08fdc32df 343 break;
tmccurbin 40:92f08fdc32df 344 case SYS_SWITCHES_ID:
tmccurbin 40:92f08fdc32df 345 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 346 sprintf(ShtdSwtchBuffer,"%3.2d", int(CANFloat)); // How the heck are we interpreting this data
tmccurbin 40:92f08fdc32df 347 display.PutString(1,108,ShtdSwtchBuffer);
tmccurbin 40:92f08fdc32df 348 break;
tmccurbin 40:92f08fdc32df 349 case SYS_PWM_FAN_ID:
tmccurbin 40:92f08fdc32df 350 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 351 if (abs(CANFloat*100 - *Fan1Buffer) >= 1) {
tmccurbin 41:7c5ea411fad2 352 sprintf(Fan1Buffer,"%3.2d", int(CANFloat*100));
tmccurbin 40:92f08fdc32df 353 display.PutString(3,30,Fan1Buffer);
tmccurbin 40:92f08fdc32df 354 }
tmccurbin 40:92f08fdc32df 355 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 356 if (abs(CANFloat2*100 - *Fan1Buffer) >= 1) {
tmccurbin 40:92f08fdc32df 357 sprintf(Fan2Buffer,"%3.2d", int(CANFloat2*100));
tmccurbin 40:92f08fdc32df 358 display.PutString(3,107,Fan2Buffer);
tmccurbin 40:92f08fdc32df 359 }
tmccurbin 40:92f08fdc32df 360 break;
tmccurbin 40:92f08fdc32df 361 case SYS_PWM_PUMP_ID:
tmccurbin 40:92f08fdc32df 362 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 363 if (abs(CANFloat*100 - *Pump1Buffer) >= 1) {
tmccurbin 41:7c5ea411fad2 364 sprintf(Pump1Buffer,"%3.2d", int(CANFloat*100));
tmccurbin 40:92f08fdc32df 365 display.PutString(5,30,Pump1Buffer);
tmccurbin 40:92f08fdc32df 366 }
tmccurbin 40:92f08fdc32df 367 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 368 if (abs(CANFloat2*100 - *Pump2Buffer) >= 1) {
tmccurbin 40:92f08fdc32df 369 sprintf(Pump2Buffer,"%3.2d", int(CANFloat2*100));
tmccurbin 40:92f08fdc32df 370 display.PutString(5,107,Pump2Buffer);
tmccurbin 40:92f08fdc32df 371 }
tmccurbin 40:92f08fdc32df 372 break;
tmccurbin 40:92f08fdc32df 373 case SYS_DCDC_STATUS_ID:
tmccurbin 40:92f08fdc32df 374 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 375 sprintf(DCDCBuffer,"%3.2d", int(CANFloat)); // How the heck are we interpreting this data
tmccurbin 40:92f08fdc32df 376 display.PutString(7,30,DCDCBuffer);
tmccurbin 40:92f08fdc32df 377 break;
tmccurbin 40:92f08fdc32df 378 case SYS_IMD_RESIST_ID:
tmccurbin 40:92f08fdc32df 379 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 380 if (abs(CANFloat - *IMDRBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 381 sprintf(IMDRBuffer,"%3.2d", int(CANFloat));
tmccurbin 40:92f08fdc32df 382 display.PutString(7,82,IMDRBuffer);
tmccurbin 40:92f08fdc32df 383 }
tmccurbin 40:92f08fdc32df 384 break;
tmccurbin 40:92f08fdc32df 385 default:
tmccurbin 40:92f08fdc32df 386 break;
tmccurbin 39:e6aa6dcf3f75 387 }
tmccurbin 39:e6aa6dcf3f75 388 break;
tmccurbin 36:8544a8900884 389
tmccurbin 40:92f08fdc32df 390 // CHARGE SCREEN *************************************************************
tmccurbin 40:92f08fdc32df 391 case CHARGE_SCREEN:
tmccurbin 40:92f08fdc32df 392 switch (Rxmsg.id) {
tmccurbin 40:92f08fdc32df 393 case CHARGECURR_TX_ID:
tmccurbin 40:92f08fdc32df 394 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 395 if (abs(CANFloat - *ChargeCurrBuffer) >= 0.1) {
tmccurbin 40:92f08fdc32df 396 sprintf(ChargeCurrBuffer,"%3.2d", int(CANFloat)); // Amps
tmccurbin 40:92f08fdc32df 397 display.PutString(3,94,ChargeCurrBuffer);
tmccurbin 40:92f08fdc32df 398 }
tmccurbin 40:92f08fdc32df 399 break;
tmccurbin 40:92f08fdc32df 400 case VOLTAGE_TX_ID:
tmccurbin 40:92f08fdc32df 401 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 402 if (abs(CANFloat - *BigBatVoltBuffer) >= 0.1) {
tmccurbin 40:92f08fdc32df 403 sprintf(BigBatVoltBuffer,"%3.2d", int(CANFloat)); // Volts
tmccurbin 40:92f08fdc32df 404 display.PutString(3,94,BigBatVoltBuffer);
tmccurbin 40:92f08fdc32df 405 }
tmccurbin 40:92f08fdc32df 406 break;
tmccurbin 40:92f08fdc32df 407 default:
tmccurbin 40:92f08fdc32df 408 break;
tmccurbin 36:8544a8900884 409 }
tmccurbin 39:e6aa6dcf3f75 410 break;
tmccurbin 36:8544a8900884 411 default:
tmccurbin 36:8544a8900884 412 break;
kiran_mbed 0:313541d8f8be 413 }
tmccurbin 36:8544a8900884 414 }
tmccurbin 36:8544a8900884 415 }
tmccurbin 36:8544a8900884 416
tmccurbin 36:8544a8900884 417 void ConnectedStatusCANMsg()
tmccurbin 36:8544a8900884 418 {
tmccurbin 36:8544a8900884 419 CANMessage ConnectedStatus(0x600, &ConnectedStatusBuffer,1);
tmccurbin 36:8544a8900884 420 SteeringCANPort.txWrite(ConnectedStatus);
tmccurbin 36:8544a8900884 421 }
tmccurbin 36:8544a8900884 422
palimar 23:6681a38918c6 423
tmccurbin 36:8544a8900884 424 void RequestStatusChange()
tmccurbin 36:8544a8900884 425 {
tmccurbin 36:8544a8900884 426 CANMessage TxDriveStatusRequest(0x601, &DriveStatusRequestBuffer,1);
tmccurbin 36:8544a8900884 427 for (int j=0; j<10; j++) {
tmccurbin 36:8544a8900884 428 SteeringCANPort.txWrite(TxDriveStatusRequest);
tmccurbin 36:8544a8900884 429 }
tmccurbin 36:8544a8900884 430 display.PutString(7,0," DRIVE REQUEST SENT ");
tmccurbin 36:8544a8900884 431 Thread::wait(750);
tmccurbin 36:8544a8900884 432 PrevScreen = !CurrScreen; // To force a screen update
tmccurbin 36:8544a8900884 433 }
tmccurbin 36:8544a8900884 434
tmccurbin 36:8544a8900884 435
tmccurbin 36:8544a8900884 436 void ResetSteeringWheel()
tmccurbin 36:8544a8900884 437 {
tmccurbin 36:8544a8900884 438 NVIC_SystemReset();
tmccurbin 36:8544a8900884 439 }
tmccurbin 36:8544a8900884 440
tmccurbin 36:8544a8900884 441
tmccurbin 36:8544a8900884 442 void ResetCar()
tmccurbin 36:8544a8900884 443 {
tmccurbin 36:8544a8900884 444 CANMessage TxCarReset(0x602,&TxResetBuffer,1);
tmccurbin 36:8544a8900884 445 for (int k=0; k<10; k++) {
tmccurbin 36:8544a8900884 446 SteeringCANPort.txWriteDirect(TxCarReset);
tmccurbin 36:8544a8900884 447 }
tmccurbin 36:8544a8900884 448 }