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:
Thu May 14 18:49:05 2015 +0000
Revision:
44:80d821b5a0e7
Parent:
42:701df58e923a
Parent:
43:47a3ac562be8
Child:
45:aea289639d6b
Fixed Merge Conflicts

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
kiran_mbed 0:313541d8f8be 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();
palimar 26:e0256fd314eb 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
jayf 44:80d821b5a0e7 23 int main2()
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
palimar 21:56890c41ecf1 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 }
palimar 4:a4fb060e7840 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 void ProcessCANMsg(CANMessage& Rxmsg)
tmccurbin 36:8544a8900884 94 {
tmccurbin 36:8544a8900884 95 if (SteeringCANPort.rxRead(Rxmsg)) {
tmccurbin 39:e6aa6dcf3f75 96 // Printing CAN message data:
tmccurbin 39:e6aa6dcf3f75 97 // 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 98 // for (int i=0; i < Rxmsg.len; i++) printf("D[%d]: %x ", i, Rxmsg.data[i]);
tmccurbin 40:92f08fdc32df 99 if (Rxmsg.id == MODE_TX_ID) {
kiran_mbed 42:701df58e923a 100 if(Rxmsg.data[0] != (1<<3))
kiran_mbed 42:701df58e923a 101 DriveStatusRequestBuffer=1;
kiran_mbed 42:701df58e923a 102 else
kiran_mbed 42:701df58e923a 103 DriveStatusRequestBuffer=0;
tmccurbin 40:92f08fdc32df 104 }
tmccurbin 40:92f08fdc32df 105
tmccurbin 41:7c5ea411fad2 106 if (Rxmsg.id == POWER_TX_ID) {
tmccurbin 41:7c5ea411fad2 107 CANFloat = GetFloat;
tmccurbin 41:7c5ea411fad2 108 LEDBar = (CANFloat/85.0)*(2.6/3.3);
kiran_mbed 0:313541d8f8be 109 }
tmccurbin 41:7c5ea411fad2 110
tmccurbin 40:92f08fdc32df 111 switch (CurrScreen) {
tmccurbin 40:92f08fdc32df 112 case HOME_SCREEN:
tmccurbin 40:92f08fdc32df 113 switch (Rxmsg.id) {
palimar 4:a4fb060e7840 114
tmccurbin 40:92f08fdc32df 115 // HOME SCREEN *******************************************************************************************
tmccurbin 40:92f08fdc32df 116 // Pedal Test
tmccurbin 41:7c5ea411fad2 117 /*case PCM_PEDALS_ID:
tmccurbin 41:7c5ea411fad2 118 CANFloat = GetFloat;
tmccurbin 41:7c5ea411fad2 119 if (abs(CANFloat*100 - float (*AccPedalBuffer)) >= 1) {
tmccurbin 41:7c5ea411fad2 120 sprintf(AccPedalBuffer,"%3.2d", int(CANFloat*100));
tmccurbin 41:7c5ea411fad2 121 display.PutString(1,40,AccPedalBuffer);
tmccurbin 41:7c5ea411fad2 122 }
tmccurbin 41:7c5ea411fad2 123 CANFloat2 = GetFloat4;
tmccurbin 41:7c5ea411fad2 124 if (abs(CANFloat2*100 - float (*BrkPedalBuffer)) >= 1) {
tmccurbin 41:7c5ea411fad2 125 sprintf(BrkPedalBuffer,"%3.2d", int(CANFloat2*100));
tmccurbin 41:7c5ea411fad2 126 display.PutString(1,60,BrkPedalBuffer);
tmccurbin 41:7c5ea411fad2 127 }
tmccurbin 41:7c5ea411fad2 128 break;*/
tmccurbin 41:7c5ea411fad2 129
tmccurbin 41:7c5ea411fad2 130 case SOC_TX_ID:
tmccurbin 40:92f08fdc32df 131 CANFloat = GetFloat;
tmccurbin 41:7c5ea411fad2 132 if (abs(CANFloat*100 - *BigBatLifeBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 133 sprintf(BigBatLifeBuffer,"%3.2d", int(CANFloat*100)); // Big battery life percentage
tmccurbin 41:7c5ea411fad2 134 display.PutString(1,40,BigBatLifeBuffer);
tmccurbin 40:92f08fdc32df 135 }
tmccurbin 41:7c5ea411fad2 136 break;
tmccurbin 41:7c5ea411fad2 137 case SYS_GLV_SOC_ID:
tmccurbin 41:7c5ea411fad2 138 CANFloat = GetFloat;
tmccurbin 41:7c5ea411fad2 139 if (abs(CANFloat*100 - *SmallBatLifeBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 140 sprintf(SmallBatLifeBuffer,"%3.2d", int(CANFloat*100)); // Small battery life percentage
tmccurbin 41:7c5ea411fad2 141 display.PutString(1,60,SmallBatLifeBuffer);
tmccurbin 41:7c5ea411fad2 142 }
tmccurbin 41:7c5ea411fad2 143 break;
tmccurbin 40:92f08fdc32df 144 case PCM_FRPM_ID:
tmccurbin 40:92f08fdc32df 145 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 146 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 147 if (abs((CANFloat+CANFloat2)*WheelCircumference*30 - *CarSpdBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 148 sprintf(CarSpdBuffer,"%3.2d", int((CANFloat+CANFloat2)*WheelCircumference*30)); // Miles per hour
tmccurbin 40:92f08fdc32df 149 display.PutString(1,108,CarSpdBuffer);
tmccurbin 40:92f08fdc32df 150 }
tmccurbin 40:92f08fdc32df 151 break;
tmccurbin 40:92f08fdc32df 152 case TEMP_MMA_TX_ID_BASE2:
tmccurbin 40:92f08fdc32df 153 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 154 if (abs((CANFloat*9.0/5.0)+32 - *AvgBatTBuffer) >=1) {
tmccurbin 40:92f08fdc32df 155 sprintf(AvgBatTBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Degrees F
tmccurbin 40:92f08fdc32df 156 display.PutString(3,39,AvgBatTBuffer);
tmccurbin 40:92f08fdc32df 157 }
tmccurbin 40:92f08fdc32df 158 break;
tmccurbin 40:92f08fdc32df 159 case TEMP_MMA_TX_ID_BASE:
tmccurbin 40:92f08fdc32df 160 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 161 if (abs((CANFloat2*9.0/5.0)+32 - *MaxBatTBuffer) >=1) {
tmccurbin 41:7c5ea411fad2 162 sprintf(MaxBatTBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 163 display.PutString(3,103,MaxBatTBuffer);
tmccurbin 40:92f08fdc32df 164 }
tmccurbin 40:92f08fdc32df 165 break;
tmccurbin 40:92f08fdc32df 166 case MOC_MOTEMP_ID:
tmccurbin 40:92f08fdc32df 167 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 168 if (abs((CANFloat*9.0/5.0)+32 - *LMtrTmpBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 169 sprintf(LMtrTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 170 display.PutString(5,34,LMtrTmpBuffer);
tmccurbin 40:92f08fdc32df 171 }
tmccurbin 40:92f08fdc32df 172 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 173 if (abs((CANFloat2*9.0/5.0)+32 - *RMtrTmpBuffer) >= 1) {
tmccurbin 41:7c5ea411fad2 174 sprintf(RMtrTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 175 display.PutString(5,34,RMtrTmpBuffer);
tmccurbin 40:92f08fdc32df 176 }
tmccurbin 40:92f08fdc32df 177 break;
tmccurbin 40:92f08fdc32df 178 default:
tmccurbin 40:92f08fdc32df 179 break;
tmccurbin 39:e6aa6dcf3f75 180 }
tmccurbin 39:e6aa6dcf3f75 181 break;
tmccurbin 40:92f08fdc32df 182 // BATTERY SCREEN***********************************************************************************
tmccurbin 40:92f08fdc32df 183 case BATTERY_SCREEN:
tmccurbin 40:92f08fdc32df 184 switch (Rxmsg.id) {
tmccurbin 40:92f08fdc32df 185 case VOLTAGE_TX_ID:
tmccurbin 40:92f08fdc32df 186 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 187 if (abs(CANFloat - *BigBatVoltBuffer) >= 0.1) {
tmccurbin 40:92f08fdc32df 188 sprintf(BigBatVoltBuffer,"%3.2d", int(CANFloat)); // Volts
tmccurbin 40:92f08fdc32df 189 display.PutString(1,10,BigBatVoltBuffer);
tmccurbin 40:92f08fdc32df 190 }
tmccurbin 40:92f08fdc32df 191 break;
tmccurbin 40:92f08fdc32df 192 case POWER_TX_ID:
tmccurbin 40:92f08fdc32df 193 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 194 LEDBar = (CANFloat/85.0)*(2.6/3.3);
tmccurbin 40:92f08fdc32df 195 if (abs(CANFloat - *BigBatPowerBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 196 sprintf(BigBatPowerBuffer,"%3.2d", int(CANFloat)); // Watts
tmccurbin 40:92f08fdc32df 197 display.PutString(1,55,BigBatPowerBuffer);
tmccurbin 40:92f08fdc32df 198 }
tmccurbin 40:92f08fdc32df 199 break;
tmccurbin 40:92f08fdc32df 200 case CURRENT_TX_ID:
tmccurbin 40:92f08fdc32df 201 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 202 if (abs(CANFloat - *BigBatCurrentBuffer) >= 0.2) {
tmccurbin 40:92f08fdc32df 203 sprintf(BigBatCurrentBuffer,"%3.2d", int(CANFloat)); // Amps
tmccurbin 40:92f08fdc32df 204 display.PutString(1,100,BigBatCurrentBuffer);
tmccurbin 40:92f08fdc32df 205 }
tmccurbin 40:92f08fdc32df 206 break;
tmccurbin 40:92f08fdc32df 207 case CELLV_MMA_TX_ID_BASE:
tmccurbin 40:92f08fdc32df 208 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 209 if (abs(CANFloat2 - *VmaxBuffer) >= 0.1) {
tmccurbin 41:7c5ea411fad2 210 sprintf(VmaxBuffer,"%3.2d", int(CANFloat2));
tmccurbin 40:92f08fdc32df 211 display.PutString(3,20,VmaxBuffer);
tmccurbin 40:92f08fdc32df 212 }
tmccurbin 40:92f08fdc32df 213 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 214 if (abs(CANFloat - *VminBuffer) >= 0.1) {
tmccurbin 40:92f08fdc32df 215 sprintf(VminBuffer,"%3.2d", int(CANFloat));
tmccurbin 40:92f08fdc32df 216 display.PutString(3,67,VminBuffer);
tmccurbin 40:92f08fdc32df 217 }
tmccurbin 40:92f08fdc32df 218 break;
tmccurbin 40:92f08fdc32df 219 case CELLV_MMA_TX_ID_BASE2:
tmccurbin 40:92f08fdc32df 220 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 221 if (abs(CANFloat - *VavgBuffer) >= 0.1) {
tmccurbin 40:92f08fdc32df 222 sprintf(VavgBuffer,"%3.2d", int(CANFloat)); // Volts
tmccurbin 40:92f08fdc32df 223 display.PutString(3,108,VavgBuffer);
tmccurbin 40:92f08fdc32df 224 }
tmccurbin 40:92f08fdc32df 225 break;
tmccurbin 40:92f08fdc32df 226 case TEMP_MMA_TX_ID_BASE:
tmccurbin 40:92f08fdc32df 227 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 228 if (abs((CANFloat*9.0/5.0)+32 - *MinBatTBuffer) >= 1) {
tmccurbin 40:92f08fdc32df 229 sprintf(MinBatTBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 230 display.PutString(5,67,MinBatTBuffer);
tmccurbin 40:92f08fdc32df 231 }
tmccurbin 40:92f08fdc32df 232 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 233 if (abs((CANFloat2*9.0/5.0)+32 - *MaxBatTBuffer) >=1) {
tmccurbin 41:7c5ea411fad2 234 sprintf(MaxBatTBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32));
tmccurbin 40:92f08fdc32df 235 display.PutString(5,20,MaxBatTBuffer);
tmccurbin 40:92f08fdc32df 236 }
tmccurbin 40:92f08fdc32df 237 break;
tmccurbin 40:92f08fdc32df 238 case TEMP_MMA_TX_ID_BASE2:
tmccurbin 40:92f08fdc32df 239 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 243 }
tmccurbin 40:92f08fdc32df 244 break;
tmccurbin 40:92f08fdc32df 245 case BOARDTEMP_TX_ID:
tmccurbin 40:92f08fdc32df 246 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 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) {
tmccurbin 40:92f08fdc32df 259 case MOC_MOTEMP_ID:
tmccurbin 40:92f08fdc32df 260 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 264 }
tmccurbin 40:92f08fdc32df 265 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 269 }
tmccurbin 40:92f08fdc32df 270 break;
tmccurbin 40:92f08fdc32df 271 case MOC_AIRTEMP_ID:
tmccurbin 40:92f08fdc32df 272 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 276 }
tmccurbin 40:92f08fdc32df 277 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 281 }
tmccurbin 40:92f08fdc32df 282 break;
tmccurbin 40:92f08fdc32df 283 case MOC_IGBTTEMP_ID:
tmccurbin 40:92f08fdc32df 284 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 288 }
tmccurbin 40:92f08fdc32df 289 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 293 }
tmccurbin 40:92f08fdc32df 294 break;
tmccurbin 40:92f08fdc32df 295 case MOC_RPM_ID:
tmccurbin 40:92f08fdc32df 296 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 300 }
tmccurbin 40:92f08fdc32df 301 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 305 }
tmccurbin 40:92f08fdc32df 306 break;
tmccurbin 40:92f08fdc32df 307 case PCM_TORQUERQ_ID:
tmccurbin 40:92f08fdc32df 308 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 312 }
tmccurbin 40:92f08fdc32df 313 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 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) {
tmccurbin 40:92f08fdc32df 327 case SYS_GLV_CURRENT_ID:
tmccurbin 40:92f08fdc32df 328 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 332 }
tmccurbin 40:92f08fdc32df 333 break;
tmccurbin 40:92f08fdc32df 334 case SYS_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;
tmccurbin 40:92f08fdc32df 339 case SYS_PWM_FAN_ID:
tmccurbin 40:92f08fdc32df 340 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 344 }
tmccurbin 40:92f08fdc32df 345 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 349 }
tmccurbin 40:92f08fdc32df 350 break;
tmccurbin 40:92f08fdc32df 351 case SYS_PWM_PUMP_ID:
tmccurbin 40:92f08fdc32df 352 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 356 }
tmccurbin 40:92f08fdc32df 357 CANFloat2 = GetFloat4;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 361 }
tmccurbin 40:92f08fdc32df 362 break;
tmccurbin 40:92f08fdc32df 363 case SYS_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;
tmccurbin 40:92f08fdc32df 368 case SYS_IMD_RESIST_ID:
tmccurbin 40:92f08fdc32df 369 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 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) {
tmccurbin 40:92f08fdc32df 383 case CHARGECURR_TX_ID:
tmccurbin 40:92f08fdc32df 384 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 388 }
tmccurbin 40:92f08fdc32df 389 break;
tmccurbin 40:92f08fdc32df 390 case VOLTAGE_TX_ID:
tmccurbin 40:92f08fdc32df 391 CANFloat = GetFloat;
tmccurbin 40:92f08fdc32df 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);
tmccurbin 40:92f08fdc32df 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;
tmccurbin 32:535acb159709 403 }
tmccurbin 36:8544a8900884 404 }
tmccurbin 36:8544a8900884 405 }
tmccurbin 36:8544a8900884 406
tmccurbin 36:8544a8900884 407 void ConnectedStatusCANMsg()
tmccurbin 36:8544a8900884 408 {
tmccurbin 36:8544a8900884 409 CANMessage ConnectedStatus(0x600, &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 {
tmccurbin 36:8544a8900884 416 CANMessage TxDriveStatusRequest(0x601, &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 {
tmccurbin 36:8544a8900884 434 CANMessage TxCarReset(0x602,&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 }