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:
jayf
Date:
Sat May 30 02:26:23 2015 +0000
Revision:
47:5d3c6f85fa29
Parent:
42:701df58e923a
Fixed all known steering wheel issues

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kiran_mbed 0:313541d8f8be 1 #include "Steering.h"
tmccurbin 36:8544a8900884 2 // To-Do:
tmccurbin 38:d04a430d7fe3 3 // Look at SYS management CAN translations: shutdown switches, DCDC status, & IMD (this is a resistance, in ohms)
tmccurbin 38:d04a430d7fe3 4 // Figure out screen/variable updating options (hardware filter), NVIC_SetPriority(CAN_IRQn,####)LPC17xx.h
tmccurbin 36:8544a8900884 5 // Firgure out fault protocall
tmccurbin 36:8544a8900884 6
tmccurbin 36:8544a8900884 7 void Init();
tmccurbin 36:8544a8900884 8 void ProcessButtons(void const *args);
tmccurbin 36:8544a8900884 9 void RequestStatusChange();
tmccurbin 36:8544a8900884 10 void ResetSteeringWheel();
tmccurbin 36:8544a8900884 11 void ResetCar();
tmccurbin 36:8544a8900884 12 void ProcessCANMsg(CANMessage& msg);
tmccurbin 36:8544a8900884 13 void UpdateDisplay();
tmccurbin 36:8544a8900884 14 void ProcessButtons(void const *args);
tmccurbin 36:8544a8900884 15 void ConnectedStatusCANMsg();
tmccurbin 36:8544a8900884 16
tmccurbin 36:8544a8900884 17 float CANFloat;
tmccurbin 36:8544a8900884 18 float CANFloat2;
tmccurbin 36:8544a8900884 19 Ticker StatusMsg;
kiran_mbed 0:313541d8f8be 20
tmccurbin 36:8544a8900884 21 int main()
tmccurbin 36:8544a8900884 22 {
tmccurbin 36:8544a8900884 23 Init();
tmccurbin 36:8544a8900884 24
tmccurbin 39:e6aa6dcf3f75 25 CANMessage Rxmsg;
tmccurbin 36:8544a8900884 26
tmccurbin 36:8544a8900884 27 Thread Thread2(ProcessButtons);
tmccurbin 36:8544a8900884 28 Thread Thread1(DisplayCurrScreen);
tmccurbin 36:8544a8900884 29
tmccurbin 36:8544a8900884 30 while(1) {
tmccurbin 36:8544a8900884 31 if (SteeringCANPort.rxRead(Rxmsg)) {
tmccurbin 36:8544a8900884 32 ProcessCANMsg(Rxmsg);
tmccurbin 32:535acb159709 33 }
jayf 47:5d3c6f85fa29 34 else
jayf 47:5d3c6f85fa29 35 Thread::yield();
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]);
jayf 47:5d3c6f85fa29 105 if (Rxmsg.id == AMS_MODE_ID) {
kiran_mbed 42:701df58e923a 106 if(Rxmsg.data[0] != (1<<3))
kiran_mbed 42:701df58e923a 107 DriveStatusRequestBuffer=1;
kiran_mbed 42:701df58e923a 108 else
kiran_mbed 42:701df58e923a 109 DriveStatusRequestBuffer=0;
tmccurbin 40:92f08fdc32df 110 }
tmccurbin 40:92f08fdc32df 111
jayf 47:5d3c6f85fa29 112 if (Rxmsg.id == AMS_POWER_ID) {
tmccurbin 41:7c5ea411fad2 113 CANFloat = GetFloat;
tmccurbin 41:7c5ea411fad2 114 LEDBar = (CANFloat/85.0)*(2.6/3.3);
tmccurbin 41:7c5ea411fad2 115 }
tmccurbin 41:7c5ea411fad2 116
tmccurbin 40:92f08fdc32df 117 switch (CurrScreen) {
tmccurbin 40:92f08fdc32df 118 case HOME_SCREEN:
tmccurbin 40:92f08fdc32df 119 switch (Rxmsg.id) {
palimar 4:a4fb060e7840 120
tmccurbin 40:92f08fdc32df 121 // HOME SCREEN *******************************************************************************************
tmccurbin 40:92f08fdc32df 122 // Pedal Test
tmccurbin 41:7c5ea411fad2 123 /*case PCM_PEDALS_ID:
tmccurbin 41:7c5ea411fad2 124 CANFloat = GetFloat;
tmccurbin 41:7c5ea411fad2 125 if (abs(CANFloat*100 - float (*AccPedalBuffer)) >= 1) {
tmccurbin 41:7c5ea411fad2 126 sprintf(AccPedalBuffer,"%3.2d", int(CANFloat*100));
tmccurbin 41:7c5ea411fad2 127 display.PutString(1,40,AccPedalBuffer);
tmccurbin 41:7c5ea411fad2 128 }
tmccurbin 41:7c5ea411fad2 129 CANFloat2 = GetFloat4;
tmccurbin 41:7c5ea411fad2 130 if (abs(CANFloat2*100 - float (*BrkPedalBuffer)) >= 1) {
tmccurbin 41:7c5ea411fad2 131 sprintf(BrkPedalBuffer,"%3.2d", int(CANFloat2*100));
tmccurbin 41:7c5ea411fad2 132 display.PutString(1,60,BrkPedalBuffer);
tmccurbin 41:7c5ea411fad2 133 }
tmccurbin 41:7c5ea411fad2 134 break;*/
tmccurbin 41:7c5ea411fad2 135
jayf 47:5d3c6f85fa29 136 case AMS_SOC_ID:
tmccurbin 40:92f08fdc32df 137 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 138 //if (abs(CANFloat*100 - *BigBatLifeBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 139 sprintf(BigBatLifeBuffer,"%3.2d", int(CANFloat*100)); // Big battery life percentage
tmccurbin 41:7c5ea411fad2 140 display.PutString(1,40,BigBatLifeBuffer);
jayf 47:5d3c6f85fa29 141 //}
tmccurbin 41:7c5ea411fad2 142 break;
jayf 47:5d3c6f85fa29 143 case SYS_MGMT_GLV_SOC_ID:
tmccurbin 41:7c5ea411fad2 144 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 145 //if (abs(CANFloat*100 - *SmallBatLifeBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 146 sprintf(SmallBatLifeBuffer,"%3.2d", int(CANFloat*100)); // Small battery life percentage
tmccurbin 41:7c5ea411fad2 147 display.PutString(1,60,SmallBatLifeBuffer);
jayf 47:5d3c6f85fa29 148 //}
tmccurbin 41:7c5ea411fad2 149 break;
tmccurbin 40:92f08fdc32df 150 case PCM_FRPM_ID:
tmccurbin 40:92f08fdc32df 151 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 152 CANFloat2 = GetFloat4;
jayf 47:5d3c6f85fa29 153 //if (abs((CANFloat+CANFloat2)*WheelCircumference*30 - *CarSpdBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 154 sprintf(CarSpdBuffer,"%3.2d", int((CANFloat+CANFloat2)*WheelCircumference*30)); // Miles per hour
tmccurbin 40:92f08fdc32df 155 display.PutString(1,108,CarSpdBuffer);
jayf 47:5d3c6f85fa29 156 //}
tmccurbin 40:92f08fdc32df 157 break;
jayf 47:5d3c6f85fa29 158 case AMS_TEMP_MMA_ID_BASE:
jayf 47:5d3c6f85fa29 159 CANFloat2 = GetFloat4;
jayf 47:5d3c6f85fa29 160 //if (abs((CANFloat2*9.0/5.0)+32 - *MaxBatTBuffer) >=1) {
jayf 47:5d3c6f85fa29 161 sprintf(MaxBatTBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32));
jayf 47:5d3c6f85fa29 162 display.PutString(3,103,MaxBatTBuffer);
jayf 47:5d3c6f85fa29 163 //}
jayf 47:5d3c6f85fa29 164 CANFloat = GetFloat8;
jayf 47:5d3c6f85fa29 165 //if (abs((CANFloat*9.0/5.0)+32 - *AvgBatTBuffer) >=1) {
tmccurbin 40:92f08fdc32df 166 sprintf(AvgBatTBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Degrees F
tmccurbin 40:92f08fdc32df 167 display.PutString(3,39,AvgBatTBuffer);
jayf 47:5d3c6f85fa29 168 //}
tmccurbin 40:92f08fdc32df 169 break;
jayf 47:5d3c6f85fa29 170 case PCM_MOTEMP_ID:
tmccurbin 40:92f08fdc32df 171 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 172 //if (abs((CANFloat*9.0/5.0)+32 - *LMtrTmpBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 173 sprintf(LMtrTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 174 display.PutString(5,34,LMtrTmpBuffer);
jayf 47:5d3c6f85fa29 175 //}
tmccurbin 40:92f08fdc32df 176 CANFloat2 = GetFloat4;
jayf 47:5d3c6f85fa29 177 //if (abs((CANFloat2*9.0/5.0)+32 - *RMtrTmpBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 178 sprintf(RMtrTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 179 display.PutString(5,34,RMtrTmpBuffer);
jayf 47:5d3c6f85fa29 180 //}
tmccurbin 40:92f08fdc32df 181 break;
tmccurbin 40:92f08fdc32df 182 default:
tmccurbin 40:92f08fdc32df 183 break;
tmccurbin 39:e6aa6dcf3f75 184 }
tmccurbin 39:e6aa6dcf3f75 185 break;
tmccurbin 40:92f08fdc32df 186 // BATTERY SCREEN***********************************************************************************
tmccurbin 40:92f08fdc32df 187 case BATTERY_SCREEN:
tmccurbin 40:92f08fdc32df 188 switch (Rxmsg.id) {
jayf 47:5d3c6f85fa29 189 case AMS_VOLTAGE_ID:
tmccurbin 40:92f08fdc32df 190 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 191 //if (abs(CANFloat - *BigBatVoltBuffer) >= 0.1) {
tmccurbin 40:92f08fdc32df 192 sprintf(BigBatVoltBuffer,"%3.2d", int(CANFloat)); // Volts
tmccurbin 40:92f08fdc32df 193 display.PutString(1,10,BigBatVoltBuffer);
jayf 47:5d3c6f85fa29 194 //}
tmccurbin 40:92f08fdc32df 195 break;
jayf 47:5d3c6f85fa29 196 case AMS_POWER_ID:
tmccurbin 40:92f08fdc32df 197 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 198 LEDBar = (CANFloat/85.0)*(2.6/3.3);
jayf 47:5d3c6f85fa29 199 //if (abs(CANFloat - *BigBatPowerBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 200 sprintf(BigBatPowerBuffer,"%3.2d", int(CANFloat)); // Watts
tmccurbin 40:92f08fdc32df 201 display.PutString(1,55,BigBatPowerBuffer);
jayf 47:5d3c6f85fa29 202 //}
tmccurbin 40:92f08fdc32df 203 break;
jayf 47:5d3c6f85fa29 204 case AMS_CURRENT_ID:
tmccurbin 40:92f08fdc32df 205 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 206 //if (abs(CANFloat - *BigBatCurrentBuffer) >= 0.2) {
tmccurbin 40:92f08fdc32df 207 sprintf(BigBatCurrentBuffer,"%3.2d", int(CANFloat)); // Amps
tmccurbin 40:92f08fdc32df 208 display.PutString(1,100,BigBatCurrentBuffer);
jayf 47:5d3c6f85fa29 209 //}
tmccurbin 40:92f08fdc32df 210 break;
jayf 47:5d3c6f85fa29 211 case AMS_CELLV_MMA_ID_BASE:
tmccurbin 40:92f08fdc32df 212 CANFloat2 = GetFloat4;
jayf 47:5d3c6f85fa29 213 //if (abs(CANFloat2 - *VmaxBuffer) >= 0.1) {
tmccurbin 41:7c5ea411fad2 214 sprintf(VmaxBuffer,"%3.2d", int(CANFloat2));
tmccurbin 40:92f08fdc32df 215 display.PutString(3,20,VmaxBuffer);
jayf 47:5d3c6f85fa29 216 //}
tmccurbin 40:92f08fdc32df 217 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 218 //if (abs(CANFloat - *VminBuffer) >= 0.1) {
tmccurbin 40:92f08fdc32df 219 sprintf(VminBuffer,"%3.2d", int(CANFloat));
tmccurbin 40:92f08fdc32df 220 display.PutString(3,67,VminBuffer);
jayf 47:5d3c6f85fa29 221 //}
jayf 47:5d3c6f85fa29 222 CANFloat = GetFloat8;
jayf 47:5d3c6f85fa29 223 //if (abs(CANFloat - *VavgBuffer) >= 0.1) {
tmccurbin 40:92f08fdc32df 224 sprintf(VavgBuffer,"%3.2d", int(CANFloat)); // Volts
tmccurbin 40:92f08fdc32df 225 display.PutString(3,108,VavgBuffer);
jayf 47:5d3c6f85fa29 226 //
tmccurbin 40:92f08fdc32df 227 break;
jayf 47:5d3c6f85fa29 228 case AMS_TEMP_MMA_ID_BASE:
tmccurbin 40:92f08fdc32df 229 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 230 //if (abs((CANFloat*9.0/5.0)+32 - *MinBatTBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 231 sprintf(MinBatTBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 232 display.PutString(5,67,MinBatTBuffer);
jayf 47:5d3c6f85fa29 233 //}
tmccurbin 40:92f08fdc32df 234 CANFloat2 = GetFloat4;
jayf 47:5d3c6f85fa29 235 //if (abs((CANFloat2*9.0/5.0)+32 - *MaxBatTBuffer) >=1) {
tmccurbin 41:7c5ea411fad2 236 sprintf(MaxBatTBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 237 display.PutString(5,20,MaxBatTBuffer);
jayf 47:5d3c6f85fa29 238 //}
jayf 47:5d3c6f85fa29 239 CANFloat = GetFloat8;
jayf 47:5d3c6f85fa29 240 //if (abs((CANFloat*9.0/5.0)+32 - *AvgBatTBuffer) >=1) {
tmccurbin 40:92f08fdc32df 241 sprintf(AvgBatTBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Degrees F
tmccurbin 40:92f08fdc32df 242 display.PutString(5,108,AvgBatTBuffer);
jayf 47:5d3c6f85fa29 243 //}
tmccurbin 40:92f08fdc32df 244 break;
jayf 47:5d3c6f85fa29 245 case AMS_BOARDTEMP_ID:
tmccurbin 40:92f08fdc32df 246 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 247 //if (abs((CANFloat*9.0/5.0)+32 - *BoardTempBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 248 sprintf(BoardTempBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Degrees F
tmccurbin 40:92f08fdc32df 249 display.PutString(7,87,BoardTempBuffer);
jayf 47:5d3c6f85fa29 250 //}
tmccurbin 40:92f08fdc32df 251 break;
tmccurbin 40:92f08fdc32df 252 default:
tmccurbin 40:92f08fdc32df 253 break;
tmccurbin 39:e6aa6dcf3f75 254 }
tmccurbin 39:e6aa6dcf3f75 255 break;
tmccurbin 36:8544a8900884 256 // MOTOR SCREEN*****************************************************************
tmccurbin 40:92f08fdc32df 257 case MOTOR_SCREEN:
tmccurbin 40:92f08fdc32df 258 switch (Rxmsg.id) {
jayf 47:5d3c6f85fa29 259 case PCM_MOTEMP_ID:
tmccurbin 40:92f08fdc32df 260 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 261 //if (abs((CANFloat*9.0/5.0)+32 - *LMtrTmpBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 262 sprintf(LMtrTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 263 display.PutString(1,34,LMtrTmpBuffer);
jayf 47:5d3c6f85fa29 264 //}
tmccurbin 40:92f08fdc32df 265 CANFloat2 = GetFloat4;
jayf 47:5d3c6f85fa29 266 //if (abs((CANFloat2*9.0/5.0)+32 - *RMtrTmpBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 267 sprintf(RMtrTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 268 display.PutString(1,98,LMtrTmpBuffer);
jayf 47:5d3c6f85fa29 269 //}
tmccurbin 40:92f08fdc32df 270 break;
jayf 47:5d3c6f85fa29 271 case PCM_AIRTEMP_ID:
tmccurbin 40:92f08fdc32df 272 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 273 //if (abs((CANFloat*9.0/5.0)+32 - *LAirTmpBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 274 sprintf(LAirTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 275 display.PutString(2,34,LAirTmpBuffer);
jayf 47:5d3c6f85fa29 276 //}
tmccurbin 40:92f08fdc32df 277 CANFloat2 = GetFloat4;
jayf 47:5d3c6f85fa29 278 //if (abs((CANFloat2*9.0/5.0)+32 - *RAirTmpBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 279 sprintf(RAirTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); // Degrees F
tmccurbin 40:92f08fdc32df 280 display.PutString(2,98,RAirTmpBuffer);
jayf 47:5d3c6f85fa29 281 //}
tmccurbin 40:92f08fdc32df 282 break;
jayf 47:5d3c6f85fa29 283 case PCM_IGBTTEMP_ID:
tmccurbin 40:92f08fdc32df 284 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 285 //if (abs((CANFloat*9.0/5.0)+32 - *LIGBTmpBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 286 sprintf(LIGBTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 287 display.PutString(3,34,LIGBTmpBuffer);
jayf 47:5d3c6f85fa29 288 //}
tmccurbin 40:92f08fdc32df 289 CANFloat2 = GetFloat4;
jayf 47:5d3c6f85fa29 290 //if (abs((CANFloat2*9.0/5.0)+32 - *RIGBTmpBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 291 sprintf(RIGBTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); // Degrees F
tmccurbin 40:92f08fdc32df 292 display.PutString(3,98,RIGBTmpBuffer);
jayf 47:5d3c6f85fa29 293 //}
tmccurbin 40:92f08fdc32df 294 break;
jayf 47:5d3c6f85fa29 295 case PCM_RPM_ID:
tmccurbin 40:92f08fdc32df 296 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 297 //if (abs(CANFloat - *Rpm_LBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 298 sprintf(Rpm_LBuffer,"%3.2d", int(CANFloat));
tmccurbin 40:92f08fdc32df 299 display.PutString(5,30,Rpm_LBuffer);
jayf 47:5d3c6f85fa29 300 //}
tmccurbin 40:92f08fdc32df 301 CANFloat2 = GetFloat4;
jayf 47:5d3c6f85fa29 302 //if (abs(CANFloat2 - *Rpm_RBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 303 sprintf(Rpm_RBuffer,"%3.2d", int(CANFloat2));
tmccurbin 40:92f08fdc32df 304 display.PutString(5,107,Rpm_RBuffer);
jayf 47:5d3c6f85fa29 305 //}
tmccurbin 40:92f08fdc32df 306 break;
tmccurbin 40:92f08fdc32df 307 case PCM_TORQUERQ_ID:
tmccurbin 40:92f08fdc32df 308 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 309 //if (abs(CANFloat*100 - *TRequestBufferL) >= 1) {
tmccurbin 40:92f08fdc32df 310 sprintf(TRequestBufferL,"%3.2d", int(CANFloat*100)); // Percentage
tmccurbin 40:92f08fdc32df 311 display.PutString(7,89,TRequestBufferL);
jayf 47:5d3c6f85fa29 312 //}
tmccurbin 40:92f08fdc32df 313 CANFloat2 = GetFloat4;
jayf 47:5d3c6f85fa29 314 //if (abs(CANFloat2*100 - *TRequestBufferR) >= 1) {
tmccurbin 40:92f08fdc32df 315 sprintf(TRequestBufferR,"%3.2d", int(CANFloat2*100)); // Percentage
tmccurbin 40:92f08fdc32df 316 display.PutString(7,89,TRequestBufferR);
jayf 47:5d3c6f85fa29 317 //}
tmccurbin 40:92f08fdc32df 318 break;
tmccurbin 40:92f08fdc32df 319 default:
tmccurbin 40:92f08fdc32df 320 break;
tmccurbin 39:e6aa6dcf3f75 321 }
tmccurbin 39:e6aa6dcf3f75 322 break;
tmccurbin 36:8544a8900884 323
tmccurbin 36:8544a8900884 324 // SYSTEM MANAGEMENT SCREEN***************************************************
tmccurbin 40:92f08fdc32df 325 case SYS_MGMT_SCREEN:
tmccurbin 40:92f08fdc32df 326 switch (Rxmsg.id) {
jayf 47:5d3c6f85fa29 327 case SYS_MGMT_GLV_CURRENT_ID:
tmccurbin 40:92f08fdc32df 328 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 329 //if (abs(CANFloat - *SmallBatCurrentBuffer) >= 0.2) {
tmccurbin 40:92f08fdc32df 330 sprintf(SmallBatCurrentBuffer,"%3.2d", int(CANFloat)); // Amps
tmccurbin 40:92f08fdc32df 331 display.PutString(1,30,SmallBatCurrentBuffer);
jayf 47:5d3c6f85fa29 332 //}
tmccurbin 40:92f08fdc32df 333 break;
jayf 47:5d3c6f85fa29 334 case SYS_MGMT_SWITCHES_ID:
tmccurbin 40:92f08fdc32df 335 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 336 sprintf(ShtdSwtchBuffer,"%3.2d", int(CANFloat)); // How the heck are we interpreting this data
tmccurbin 40:92f08fdc32df 337 display.PutString(1,108,ShtdSwtchBuffer);
tmccurbin 40:92f08fdc32df 338 break;
jayf 47:5d3c6f85fa29 339 case SYS_MGMT_PWM_FAN_ID:
tmccurbin 40:92f08fdc32df 340 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 341 //if (abs(CANFloat*100 - *Fan1Buffer) >= 1) {
tmccurbin 41:7c5ea411fad2 342 sprintf(Fan1Buffer,"%3.2d", int(CANFloat*100));
tmccurbin 40:92f08fdc32df 343 display.PutString(3,30,Fan1Buffer);
jayf 47:5d3c6f85fa29 344 //}
tmccurbin 40:92f08fdc32df 345 CANFloat2 = GetFloat4;
jayf 47:5d3c6f85fa29 346 //if (abs(CANFloat2*100 - *Fan1Buffer) >= 1) {
tmccurbin 40:92f08fdc32df 347 sprintf(Fan2Buffer,"%3.2d", int(CANFloat2*100));
tmccurbin 40:92f08fdc32df 348 display.PutString(3,107,Fan2Buffer);
jayf 47:5d3c6f85fa29 349 //}
tmccurbin 40:92f08fdc32df 350 break;
jayf 47:5d3c6f85fa29 351 case SYS_MGMT_PWM_PUMP_ID:
tmccurbin 40:92f08fdc32df 352 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 353 //if (abs(CANFloat*100 - *Pump1Buffer) >= 1) {
tmccurbin 41:7c5ea411fad2 354 sprintf(Pump1Buffer,"%3.2d", int(CANFloat*100));
tmccurbin 40:92f08fdc32df 355 display.PutString(5,30,Pump1Buffer);
jayf 47:5d3c6f85fa29 356 //}
tmccurbin 40:92f08fdc32df 357 CANFloat2 = GetFloat4;
jayf 47:5d3c6f85fa29 358 //if (abs(CANFloat2*100 - *Pump2Buffer) >= 1) {
tmccurbin 40:92f08fdc32df 359 sprintf(Pump2Buffer,"%3.2d", int(CANFloat2*100));
tmccurbin 40:92f08fdc32df 360 display.PutString(5,107,Pump2Buffer);
jayf 47:5d3c6f85fa29 361 //}
tmccurbin 40:92f08fdc32df 362 break;
jayf 47:5d3c6f85fa29 363 case SYS_MGMT_DCDC_STATUS_ID:
tmccurbin 40:92f08fdc32df 364 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 365 sprintf(DCDCBuffer,"%3.2d", int(CANFloat)); // How the heck are we interpreting this data
tmccurbin 40:92f08fdc32df 366 display.PutString(7,30,DCDCBuffer);
tmccurbin 40:92f08fdc32df 367 break;
jayf 47:5d3c6f85fa29 368 case SYS_MGMT_IMD_RESIST_ID:
tmccurbin 40:92f08fdc32df 369 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 370 //if (abs(CANFloat - *IMDRBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 371 sprintf(IMDRBuffer,"%3.2d", int(CANFloat));
tmccurbin 40:92f08fdc32df 372 display.PutString(7,82,IMDRBuffer);
jayf 47:5d3c6f85fa29 373 //}
tmccurbin 40:92f08fdc32df 374 break;
tmccurbin 40:92f08fdc32df 375 default:
tmccurbin 40:92f08fdc32df 376 break;
tmccurbin 39:e6aa6dcf3f75 377 }
tmccurbin 39:e6aa6dcf3f75 378 break;
tmccurbin 36:8544a8900884 379
tmccurbin 40:92f08fdc32df 380 // CHARGE SCREEN *************************************************************
tmccurbin 40:92f08fdc32df 381 case CHARGE_SCREEN:
tmccurbin 40:92f08fdc32df 382 switch (Rxmsg.id) {
jayf 47:5d3c6f85fa29 383 case CHARGER_CHARGING_CURRENT_ID:
tmccurbin 40:92f08fdc32df 384 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 385 //if (abs(CANFloat - *ChargeCurrBuffer) >= 0.1) {
tmccurbin 40:92f08fdc32df 386 sprintf(ChargeCurrBuffer,"%3.2d", int(CANFloat)); // Amps
tmccurbin 40:92f08fdc32df 387 display.PutString(3,94,ChargeCurrBuffer);
jayf 47:5d3c6f85fa29 388 //}
tmccurbin 40:92f08fdc32df 389 break;
jayf 47:5d3c6f85fa29 390 case CHARGER_CHARGING_VOLTAGE_ID:
tmccurbin 40:92f08fdc32df 391 CANFloat = GetFloat;
jayf 47:5d3c6f85fa29 392 //if (abs(CANFloat - *BigBatVoltBuffer) >= 0.1) {
tmccurbin 40:92f08fdc32df 393 sprintf(BigBatVoltBuffer,"%3.2d", int(CANFloat)); // Volts
tmccurbin 40:92f08fdc32df 394 display.PutString(3,94,BigBatVoltBuffer);
jayf 47:5d3c6f85fa29 395 //}
tmccurbin 40:92f08fdc32df 396 break;
tmccurbin 40:92f08fdc32df 397 default:
tmccurbin 40:92f08fdc32df 398 break;
tmccurbin 36:8544a8900884 399 }
tmccurbin 39:e6aa6dcf3f75 400 break;
tmccurbin 36:8544a8900884 401 default:
tmccurbin 36:8544a8900884 402 break;
kiran_mbed 0:313541d8f8be 403 }
tmccurbin 36:8544a8900884 404 }
tmccurbin 36:8544a8900884 405 }
tmccurbin 36:8544a8900884 406
tmccurbin 36:8544a8900884 407 void ConnectedStatusCANMsg()
tmccurbin 36:8544a8900884 408 {
jayf 47:5d3c6f85fa29 409 CANMessage ConnectedStatus(STEERING_WHEEL_STATUS_ID, &ConnectedStatusBuffer,1);
tmccurbin 36:8544a8900884 410 SteeringCANPort.txWrite(ConnectedStatus);
tmccurbin 36:8544a8900884 411 }
tmccurbin 36:8544a8900884 412
palimar 23:6681a38918c6 413
tmccurbin 36:8544a8900884 414 void RequestStatusChange()
tmccurbin 36:8544a8900884 415 {
jayf 47:5d3c6f85fa29 416 CANMessage TxDriveStatusRequest(STEERING_WHEEL_DRIVE_STATUS_REQUEST_ID , &DriveStatusRequestBuffer,1);
tmccurbin 36:8544a8900884 417 for (int j=0; j<10; j++) {
tmccurbin 36:8544a8900884 418 SteeringCANPort.txWrite(TxDriveStatusRequest);
tmccurbin 36:8544a8900884 419 }
tmccurbin 36:8544a8900884 420 display.PutString(7,0," DRIVE REQUEST SENT ");
tmccurbin 36:8544a8900884 421 Thread::wait(750);
tmccurbin 36:8544a8900884 422 PrevScreen = !CurrScreen; // To force a screen update
tmccurbin 36:8544a8900884 423 }
tmccurbin 36:8544a8900884 424
tmccurbin 36:8544a8900884 425
tmccurbin 36:8544a8900884 426 void ResetSteeringWheel()
tmccurbin 36:8544a8900884 427 {
tmccurbin 36:8544a8900884 428 NVIC_SystemReset();
tmccurbin 36:8544a8900884 429 }
tmccurbin 36:8544a8900884 430
tmccurbin 36:8544a8900884 431
tmccurbin 36:8544a8900884 432 void ResetCar()
tmccurbin 36:8544a8900884 433 {
jayf 47:5d3c6f85fa29 434 CANMessage TxCarReset(STEERING_WHEEL_CAR_RESET_ID,&TxResetBuffer,1);
tmccurbin 36:8544a8900884 435 for (int k=0; k<10; k++) {
tmccurbin 36:8544a8900884 436 SteeringCANPort.txWriteDirect(TxCarReset);
tmccurbin 36:8544a8900884 437 }
tmccurbin 36:8544a8900884 438 }