The Code Repository for the REV0 Steering Wheel.
Dependencies: CANBuffer KS0108_fork mbed-rtos mbed CAN Addresses
Fork of REVO_Updated_Steering by
Steering.cpp@40:92f08fdc32df, 2015-02-08 (annotated)
- Committer:
- tmccurbin
- Date:
- Sun Feb 08 08:48:17 2015 +0000
- Revision:
- 40:92f08fdc32df
- Parent:
- 39:e6aa6dcf3f75
- Child:
- 41:7c5ea411fad2
All variables show on proper screen
Who changed what in which revision?
User | Revision | Line number | New 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 | 40:92f08fdc32df | 116 | switch (CurrScreen) { |
tmccurbin | 40:92f08fdc32df | 117 | case HOME_SCREEN: |
tmccurbin | 40:92f08fdc32df | 118 | switch (Rxmsg.id) { |
palimar | 4:a4fb060e7840 | 119 | |
tmccurbin | 40:92f08fdc32df | 120 | // HOME SCREEN ******************************************************************************************* |
tmccurbin | 40:92f08fdc32df | 121 | // Pedal Test |
tmccurbin | 40:92f08fdc32df | 122 | /*case PCM_PEDALS_ID: |
tmccurbin | 40:92f08fdc32df | 123 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 124 | if (abs(CANFloat*100 - float (*AccPedalBuffer)) >= 1) { |
tmccurbin | 40:92f08fdc32df | 125 | sprintf(AccPedalBuffer,"%3.2d", int(CANFloat*100)); |
tmccurbin | 40:92f08fdc32df | 126 | display.PutString(1,40,AccPedalBuffer); |
tmccurbin | 40:92f08fdc32df | 127 | } |
tmccurbin | 40:92f08fdc32df | 128 | CANFloat2 = GetFloat4; |
tmccurbin | 40:92f08fdc32df | 129 | if (abs(CANFloat2*100 - float (*BrkPedalBuffer)) >= 1) { |
tmccurbin | 40:92f08fdc32df | 130 | sprintf(BrkPedalBuffer,"%3.2d", int(CANFloat2*100)); |
tmccurbin | 40:92f08fdc32df | 131 | display.PutString(1,60,BrkPedalBuffer); |
tmccurbin | 40:92f08fdc32df | 132 | } |
tmccurbin | 40:92f08fdc32df | 133 | break;*/ |
tmccurbin | 40:92f08fdc32df | 134 | |
tmccurbin | 40:92f08fdc32df | 135 | case SOC_TX_ID: |
tmccurbin | 40:92f08fdc32df | 136 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 137 | if (abs(CANFloat*100 - *BigBatLifeBuffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 138 | sprintf(BigBatLifeBuffer,"%3.2d", int(CANFloat*100)); // Big battery life percentage |
tmccurbin | 40:92f08fdc32df | 139 | display.PutString(1,40,BigBatLifeBuffer); |
tmccurbin | 40:92f08fdc32df | 140 | } |
tmccurbin | 40:92f08fdc32df | 141 | break; |
tmccurbin | 40:92f08fdc32df | 142 | case SYS_GLV_SOC_ID: |
tmccurbin | 40:92f08fdc32df | 143 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 144 | if (abs(CANFloat*100 - *SmallBatLifeBuffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 145 | sprintf(SmallBatLifeBuffer,"%3.2d", int(CANFloat*100)); // Small battery life percentage |
tmccurbin | 40:92f08fdc32df | 146 | display.PutString(1,60,SmallBatLifeBuffer); |
tmccurbin | 40:92f08fdc32df | 147 | } |
tmccurbin | 40:92f08fdc32df | 148 | break; |
tmccurbin | 40:92f08fdc32df | 149 | case PCM_FRPM_ID: |
tmccurbin | 40:92f08fdc32df | 150 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 151 | CANFloat2 = GetFloat4; |
tmccurbin | 40:92f08fdc32df | 152 | if (abs((CANFloat+CANFloat2)*WheelCircumference*30 - *CarSpdBuffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 153 | sprintf(CarSpdBuffer,"%3.2d", int((CANFloat+CANFloat2)*WheelCircumference*30)); // Miles per hour |
tmccurbin | 40:92f08fdc32df | 154 | display.PutString(1,108,CarSpdBuffer); |
tmccurbin | 40:92f08fdc32df | 155 | } |
tmccurbin | 40:92f08fdc32df | 156 | break; |
tmccurbin | 40:92f08fdc32df | 157 | case TEMP_MMA_TX_ID_BASE2: |
tmccurbin | 40:92f08fdc32df | 158 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 159 | if (abs((CANFloat*9.0/5.0)+32 - *AvgBatTBuffer) >=1) { |
tmccurbin | 40:92f08fdc32df | 160 | sprintf(AvgBatTBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Degrees F |
tmccurbin | 40:92f08fdc32df | 161 | display.PutString(3,39,AvgBatTBuffer); |
tmccurbin | 40:92f08fdc32df | 162 | } |
tmccurbin | 40:92f08fdc32df | 163 | break; |
tmccurbin | 40:92f08fdc32df | 164 | case TEMP_MMA_TX_ID_BASE: |
tmccurbin | 40:92f08fdc32df | 165 | CANFloat2 = GetFloat4; |
tmccurbin | 40:92f08fdc32df | 166 | if (abs((CANFloat2*9.0/5.0)+32 - *MaxBatTBuffer) >=1) { |
tmccurbin | 40:92f08fdc32df | 167 | sprintf(MaxBatTBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); |
tmccurbin | 40:92f08fdc32df | 168 | display.PutString(3,103,MaxBatTBuffer); |
tmccurbin | 40:92f08fdc32df | 169 | } |
tmccurbin | 40:92f08fdc32df | 170 | break; |
tmccurbin | 40:92f08fdc32df | 171 | case MOC_MOTEMP_ID: |
tmccurbin | 40:92f08fdc32df | 172 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 173 | if (abs((CANFloat*9.0/5.0)+32 - *LMtrTmpBuffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 174 | sprintf(LMtrTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); |
tmccurbin | 40:92f08fdc32df | 175 | display.PutString(5,34,LMtrTmpBuffer); |
tmccurbin | 40:92f08fdc32df | 176 | } |
tmccurbin | 40:92f08fdc32df | 177 | CANFloat2 = GetFloat4; |
tmccurbin | 40:92f08fdc32df | 178 | if (abs((CANFloat2*9.0/5.0)+32 - *RMtrTmpBuffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 179 | sprintf(RMtrTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); |
tmccurbin | 40:92f08fdc32df | 180 | display.PutString(5,34,RMtrTmpBuffer); |
tmccurbin | 40:92f08fdc32df | 181 | } |
tmccurbin | 40:92f08fdc32df | 182 | break; |
tmccurbin | 40:92f08fdc32df | 183 | default: |
tmccurbin | 40:92f08fdc32df | 184 | break; |
tmccurbin | 39:e6aa6dcf3f75 | 185 | } |
tmccurbin | 39:e6aa6dcf3f75 | 186 | break; |
tmccurbin | 40:92f08fdc32df | 187 | // BATTERY SCREEN*********************************************************************************** |
tmccurbin | 40:92f08fdc32df | 188 | case BATTERY_SCREEN: |
tmccurbin | 40:92f08fdc32df | 189 | switch (Rxmsg.id) { |
tmccurbin | 40:92f08fdc32df | 190 | case VOLTAGE_TX_ID: |
tmccurbin | 40:92f08fdc32df | 191 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 192 | if (abs(CANFloat - *BigBatVoltBuffer) >= 0.1) { |
tmccurbin | 40:92f08fdc32df | 193 | sprintf(BigBatVoltBuffer,"%3.2d", int(CANFloat)); // Volts |
tmccurbin | 40:92f08fdc32df | 194 | display.PutString(1,10,BigBatVoltBuffer); |
tmccurbin | 40:92f08fdc32df | 195 | } |
tmccurbin | 40:92f08fdc32df | 196 | break; |
tmccurbin | 40:92f08fdc32df | 197 | case POWER_TX_ID: |
tmccurbin | 40:92f08fdc32df | 198 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 199 | LEDBar = (CANFloat/85.0)*(2.6/3.3); |
tmccurbin | 40:92f08fdc32df | 200 | if (abs(CANFloat - *BigBatPowerBuffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 201 | sprintf(BigBatPowerBuffer,"%3.2d", int(CANFloat)); // Watts |
tmccurbin | 40:92f08fdc32df | 202 | display.PutString(1,55,BigBatPowerBuffer); |
tmccurbin | 40:92f08fdc32df | 203 | } |
tmccurbin | 40:92f08fdc32df | 204 | break; |
tmccurbin | 40:92f08fdc32df | 205 | case CURRENT_TX_ID: |
tmccurbin | 40:92f08fdc32df | 206 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 207 | if (abs(CANFloat - *BigBatCurrentBuffer) >= 0.2) { |
tmccurbin | 40:92f08fdc32df | 208 | sprintf(BigBatCurrentBuffer,"%3.2d", int(CANFloat)); // Amps |
tmccurbin | 40:92f08fdc32df | 209 | display.PutString(1,100,BigBatCurrentBuffer); |
tmccurbin | 40:92f08fdc32df | 210 | } |
tmccurbin | 40:92f08fdc32df | 211 | break; |
tmccurbin | 40:92f08fdc32df | 212 | case CELLV_MMA_TX_ID_BASE: |
tmccurbin | 40:92f08fdc32df | 213 | CANFloat2 = GetFloat4; |
tmccurbin | 40:92f08fdc32df | 214 | if (abs(CANFloat2 - *VmaxBuffer) >= 0.1) { |
tmccurbin | 40:92f08fdc32df | 215 | sprintf(VmaxBuffer,"%3.2d", int(CANFloat2)); |
tmccurbin | 40:92f08fdc32df | 216 | display.PutString(3,20,VmaxBuffer); |
tmccurbin | 40:92f08fdc32df | 217 | } |
tmccurbin | 40:92f08fdc32df | 218 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 219 | if (abs(CANFloat - *VminBuffer) >= 0.1) { |
tmccurbin | 40:92f08fdc32df | 220 | sprintf(VminBuffer,"%3.2d", int(CANFloat)); |
tmccurbin | 40:92f08fdc32df | 221 | display.PutString(3,67,VminBuffer); |
tmccurbin | 40:92f08fdc32df | 222 | } |
tmccurbin | 40:92f08fdc32df | 223 | break; |
tmccurbin | 40:92f08fdc32df | 224 | case CELLV_MMA_TX_ID_BASE2: |
tmccurbin | 40:92f08fdc32df | 225 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 226 | if (abs(CANFloat - *VavgBuffer) >= 0.1) { |
tmccurbin | 40:92f08fdc32df | 227 | sprintf(VavgBuffer,"%3.2d", int(CANFloat)); // Volts |
tmccurbin | 40:92f08fdc32df | 228 | display.PutString(3,108,VavgBuffer); |
tmccurbin | 40:92f08fdc32df | 229 | } |
tmccurbin | 40:92f08fdc32df | 230 | break; |
tmccurbin | 40:92f08fdc32df | 231 | case TEMP_MMA_TX_ID_BASE: |
tmccurbin | 40:92f08fdc32df | 232 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 233 | if (abs((CANFloat*9.0/5.0)+32 - *MinBatTBuffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 234 | sprintf(MinBatTBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); |
tmccurbin | 40:92f08fdc32df | 235 | display.PutString(5,67,MinBatTBuffer); |
tmccurbin | 40:92f08fdc32df | 236 | } |
tmccurbin | 40:92f08fdc32df | 237 | CANFloat2 = GetFloat4; |
tmccurbin | 40:92f08fdc32df | 238 | if (abs((CANFloat2*9.0/5.0)+32 - *MaxBatTBuffer) >=1) { |
tmccurbin | 40:92f08fdc32df | 239 | sprintf(MaxBatTBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); |
tmccurbin | 40:92f08fdc32df | 240 | display.PutString(5,20,MaxBatTBuffer); |
tmccurbin | 40:92f08fdc32df | 241 | } |
tmccurbin | 40:92f08fdc32df | 242 | break; |
tmccurbin | 40:92f08fdc32df | 243 | case TEMP_MMA_TX_ID_BASE2: |
tmccurbin | 40:92f08fdc32df | 244 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 245 | if (abs((CANFloat*9.0/5.0)+32 - *AvgBatTBuffer) >=1) { |
tmccurbin | 40:92f08fdc32df | 246 | sprintf(AvgBatTBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Degrees F |
tmccurbin | 40:92f08fdc32df | 247 | display.PutString(5,108,AvgBatTBuffer); |
tmccurbin | 40:92f08fdc32df | 248 | } |
tmccurbin | 40:92f08fdc32df | 249 | break; |
tmccurbin | 40:92f08fdc32df | 250 | case BOARDTEMP_TX_ID: |
tmccurbin | 40:92f08fdc32df | 251 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 252 | if (abs((CANFloat*9.0/5.0)+32 - *BoardTempBuffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 253 | sprintf(BoardTempBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Degrees F |
tmccurbin | 40:92f08fdc32df | 254 | display.PutString(7,87,BoardTempBuffer); |
tmccurbin | 40:92f08fdc32df | 255 | } |
tmccurbin | 40:92f08fdc32df | 256 | break; |
tmccurbin | 40:92f08fdc32df | 257 | default: |
tmccurbin | 40:92f08fdc32df | 258 | break; |
tmccurbin | 39:e6aa6dcf3f75 | 259 | } |
tmccurbin | 39:e6aa6dcf3f75 | 260 | break; |
tmccurbin | 36:8544a8900884 | 261 | // MOTOR SCREEN***************************************************************** |
tmccurbin | 40:92f08fdc32df | 262 | case MOTOR_SCREEN: |
tmccurbin | 40:92f08fdc32df | 263 | switch (Rxmsg.id) { |
tmccurbin | 40:92f08fdc32df | 264 | case MOC_MOTEMP_ID: |
tmccurbin | 40:92f08fdc32df | 265 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 266 | if (abs((CANFloat*9.0/5.0)+32 - *LMtrTmpBuffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 267 | sprintf(LMtrTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); |
tmccurbin | 40:92f08fdc32df | 268 | display.PutString(1,34,LMtrTmpBuffer); |
tmccurbin | 40:92f08fdc32df | 269 | } |
tmccurbin | 40:92f08fdc32df | 270 | CANFloat2 = GetFloat4; |
tmccurbin | 40:92f08fdc32df | 271 | if (abs((CANFloat2*9.0/5.0)+32 - *RMtrTmpBuffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 272 | sprintf(RMtrTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); |
tmccurbin | 40:92f08fdc32df | 273 | display.PutString(1,98,LMtrTmpBuffer); |
tmccurbin | 40:92f08fdc32df | 274 | } |
tmccurbin | 40:92f08fdc32df | 275 | break; |
tmccurbin | 40:92f08fdc32df | 276 | case MOC_AIRTEMP_ID: |
tmccurbin | 40:92f08fdc32df | 277 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 278 | if (abs((CANFloat*9.0/5.0)+32 - *LAirTmpBuffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 279 | sprintf(LAirTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); |
tmccurbin | 40:92f08fdc32df | 280 | display.PutString(2,34,LAirTmpBuffer); |
tmccurbin | 40:92f08fdc32df | 281 | } |
tmccurbin | 40:92f08fdc32df | 282 | CANFloat2 = GetFloat4; |
tmccurbin | 40:92f08fdc32df | 283 | if (abs((CANFloat2*9.0/5.0)+32 - *RAirTmpBuffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 284 | sprintf(RAirTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); // Degrees F |
tmccurbin | 40:92f08fdc32df | 285 | display.PutString(2,98,RAirTmpBuffer); |
tmccurbin | 40:92f08fdc32df | 286 | } |
tmccurbin | 40:92f08fdc32df | 287 | break; |
tmccurbin | 40:92f08fdc32df | 288 | case MOC_IGBTTEMP_ID: |
tmccurbin | 40:92f08fdc32df | 289 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 290 | if (abs((CANFloat*9.0/5.0)+32 - *LIGBTmpBuffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 291 | sprintf(LIGBTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); |
tmccurbin | 40:92f08fdc32df | 292 | display.PutString(3,34,LIGBTmpBuffer); |
tmccurbin | 40:92f08fdc32df | 293 | } |
tmccurbin | 40:92f08fdc32df | 294 | CANFloat2 = GetFloat4; |
tmccurbin | 40:92f08fdc32df | 295 | if (abs((CANFloat2*9.0/5.0)+32 - *RIGBTmpBuffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 296 | sprintf(RIGBTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); // Degrees F |
tmccurbin | 40:92f08fdc32df | 297 | display.PutString(3,98,RIGBTmpBuffer); |
tmccurbin | 40:92f08fdc32df | 298 | } |
tmccurbin | 40:92f08fdc32df | 299 | break; |
tmccurbin | 40:92f08fdc32df | 300 | case MOC_RPM_ID: |
tmccurbin | 40:92f08fdc32df | 301 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 302 | if (abs(CANFloat - *Rpm_LBuffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 303 | sprintf(Rpm_LBuffer,"%3.2d", int(CANFloat)); |
tmccurbin | 40:92f08fdc32df | 304 | display.PutString(5,30,Rpm_LBuffer); |
tmccurbin | 40:92f08fdc32df | 305 | } |
tmccurbin | 40:92f08fdc32df | 306 | CANFloat2 = GetFloat4; |
tmccurbin | 40:92f08fdc32df | 307 | if (abs(CANFloat2 - *Rpm_RBuffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 308 | sprintf(Rpm_RBuffer,"%3.2d", int(CANFloat2)); |
tmccurbin | 40:92f08fdc32df | 309 | display.PutString(5,107,Rpm_RBuffer); |
tmccurbin | 40:92f08fdc32df | 310 | } |
tmccurbin | 40:92f08fdc32df | 311 | break; |
tmccurbin | 40:92f08fdc32df | 312 | case PCM_TORQUERQ_ID: |
tmccurbin | 40:92f08fdc32df | 313 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 314 | if (abs(CANFloat*100 - *TRequestBufferL) >= 1) { |
tmccurbin | 40:92f08fdc32df | 315 | sprintf(TRequestBufferL,"%3.2d", int(CANFloat*100)); // Percentage |
tmccurbin | 40:92f08fdc32df | 316 | display.PutString(7,89,TRequestBufferL); |
tmccurbin | 40:92f08fdc32df | 317 | } |
tmccurbin | 40:92f08fdc32df | 318 | CANFloat2 = GetFloat4; |
tmccurbin | 40:92f08fdc32df | 319 | if (abs(CANFloat2*100 - *TRequestBufferR) >= 1) { |
tmccurbin | 40:92f08fdc32df | 320 | sprintf(TRequestBufferR,"%3.2d", int(CANFloat2*100)); // Percentage |
tmccurbin | 40:92f08fdc32df | 321 | display.PutString(7,89,TRequestBufferR); |
tmccurbin | 40:92f08fdc32df | 322 | } |
tmccurbin | 40:92f08fdc32df | 323 | break; |
tmccurbin | 40:92f08fdc32df | 324 | default: |
tmccurbin | 40:92f08fdc32df | 325 | break; |
tmccurbin | 39:e6aa6dcf3f75 | 326 | } |
tmccurbin | 39:e6aa6dcf3f75 | 327 | break; |
tmccurbin | 36:8544a8900884 | 328 | |
tmccurbin | 36:8544a8900884 | 329 | // SYSTEM MANAGEMENT SCREEN*************************************************** |
tmccurbin | 40:92f08fdc32df | 330 | case SYS_MGMT_SCREEN: |
tmccurbin | 40:92f08fdc32df | 331 | switch (Rxmsg.id) { |
tmccurbin | 40:92f08fdc32df | 332 | case SYS_GLV_CURRENT_ID: |
tmccurbin | 40:92f08fdc32df | 333 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 334 | if (abs(CANFloat - *SmallBatCurrentBuffer) >= 0.2) { |
tmccurbin | 40:92f08fdc32df | 335 | sprintf(SmallBatCurrentBuffer,"%3.2d", int(CANFloat)); // Amps |
tmccurbin | 40:92f08fdc32df | 336 | display.PutString(1,30,SmallBatCurrentBuffer); |
tmccurbin | 40:92f08fdc32df | 337 | } |
tmccurbin | 40:92f08fdc32df | 338 | break; |
tmccurbin | 40:92f08fdc32df | 339 | case SYS_SWITCHES_ID: |
tmccurbin | 40:92f08fdc32df | 340 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 341 | sprintf(ShtdSwtchBuffer,"%3.2d", int(CANFloat)); // How the heck are we interpreting this data |
tmccurbin | 40:92f08fdc32df | 342 | display.PutString(1,108,ShtdSwtchBuffer); |
tmccurbin | 40:92f08fdc32df | 343 | break; |
tmccurbin | 40:92f08fdc32df | 344 | case SYS_PWM_FAN_ID: |
tmccurbin | 40:92f08fdc32df | 345 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 346 | if (abs(CANFloat*100 - *Fan1Buffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 347 | sprintf(Fan1Buffer,"%3.2d", int(CANFloat*100)); |
tmccurbin | 40:92f08fdc32df | 348 | display.PutString(3,30,Fan1Buffer); |
tmccurbin | 40:92f08fdc32df | 349 | } |
tmccurbin | 40:92f08fdc32df | 350 | CANFloat2 = GetFloat4; |
tmccurbin | 40:92f08fdc32df | 351 | if (abs(CANFloat2*100 - *Fan1Buffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 352 | sprintf(Fan2Buffer,"%3.2d", int(CANFloat2*100)); |
tmccurbin | 40:92f08fdc32df | 353 | display.PutString(3,107,Fan2Buffer); |
tmccurbin | 40:92f08fdc32df | 354 | } |
tmccurbin | 40:92f08fdc32df | 355 | break; |
tmccurbin | 40:92f08fdc32df | 356 | case SYS_PWM_PUMP_ID: |
tmccurbin | 40:92f08fdc32df | 357 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 358 | if (abs(CANFloat*100 - *Pump1Buffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 359 | sprintf(Pump1Buffer,"%3.2d", int(CANFloat*100)); |
tmccurbin | 40:92f08fdc32df | 360 | display.PutString(5,30,Pump1Buffer); |
tmccurbin | 40:92f08fdc32df | 361 | } |
tmccurbin | 40:92f08fdc32df | 362 | CANFloat2 = GetFloat4; |
tmccurbin | 40:92f08fdc32df | 363 | if (abs(CANFloat2*100 - *Pump2Buffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 364 | sprintf(Pump2Buffer,"%3.2d", int(CANFloat2*100)); |
tmccurbin | 40:92f08fdc32df | 365 | display.PutString(5,107,Pump2Buffer); |
tmccurbin | 40:92f08fdc32df | 366 | } |
tmccurbin | 40:92f08fdc32df | 367 | break; |
tmccurbin | 40:92f08fdc32df | 368 | case SYS_DCDC_STATUS_ID: |
tmccurbin | 40:92f08fdc32df | 369 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 370 | sprintf(DCDCBuffer,"%3.2d", int(CANFloat)); // How the heck are we interpreting this data |
tmccurbin | 40:92f08fdc32df | 371 | display.PutString(7,30,DCDCBuffer); |
tmccurbin | 40:92f08fdc32df | 372 | break; |
tmccurbin | 40:92f08fdc32df | 373 | case SYS_IMD_RESIST_ID: |
tmccurbin | 40:92f08fdc32df | 374 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 375 | if (abs(CANFloat - *IMDRBuffer) >= 1) { |
tmccurbin | 40:92f08fdc32df | 376 | sprintf(IMDRBuffer,"%3.2d", int(CANFloat)); |
tmccurbin | 40:92f08fdc32df | 377 | display.PutString(7,82,IMDRBuffer); |
tmccurbin | 40:92f08fdc32df | 378 | } |
tmccurbin | 40:92f08fdc32df | 379 | break; |
tmccurbin | 40:92f08fdc32df | 380 | default: |
tmccurbin | 40:92f08fdc32df | 381 | break; |
tmccurbin | 39:e6aa6dcf3f75 | 382 | } |
tmccurbin | 39:e6aa6dcf3f75 | 383 | break; |
tmccurbin | 36:8544a8900884 | 384 | |
tmccurbin | 40:92f08fdc32df | 385 | // CHARGE SCREEN ************************************************************* |
tmccurbin | 40:92f08fdc32df | 386 | case CHARGE_SCREEN: |
tmccurbin | 40:92f08fdc32df | 387 | switch (Rxmsg.id) { |
tmccurbin | 40:92f08fdc32df | 388 | case CHARGECURR_TX_ID: |
tmccurbin | 40:92f08fdc32df | 389 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 390 | if (abs(CANFloat - *ChargeCurrBuffer) >= 0.1) { |
tmccurbin | 40:92f08fdc32df | 391 | sprintf(ChargeCurrBuffer,"%3.2d", int(CANFloat)); // Amps |
tmccurbin | 40:92f08fdc32df | 392 | display.PutString(3,94,ChargeCurrBuffer); |
tmccurbin | 40:92f08fdc32df | 393 | } |
tmccurbin | 40:92f08fdc32df | 394 | break; |
tmccurbin | 40:92f08fdc32df | 395 | case VOLTAGE_TX_ID: |
tmccurbin | 40:92f08fdc32df | 396 | CANFloat = GetFloat; |
tmccurbin | 40:92f08fdc32df | 397 | if (abs(CANFloat - *BigBatVoltBuffer) >= 0.1) { |
tmccurbin | 40:92f08fdc32df | 398 | sprintf(BigBatVoltBuffer,"%3.2d", int(CANFloat)); // Volts |
tmccurbin | 40:92f08fdc32df | 399 | display.PutString(3,94,BigBatVoltBuffer); |
tmccurbin | 40:92f08fdc32df | 400 | } |
tmccurbin | 40:92f08fdc32df | 401 | break; |
tmccurbin | 40:92f08fdc32df | 402 | default: |
tmccurbin | 40:92f08fdc32df | 403 | break; |
tmccurbin | 36:8544a8900884 | 404 | } |
tmccurbin | 39:e6aa6dcf3f75 | 405 | break; |
tmccurbin | 36:8544a8900884 | 406 | default: |
tmccurbin | 36:8544a8900884 | 407 | break; |
kiran_mbed | 0:313541d8f8be | 408 | } |
tmccurbin | 36:8544a8900884 | 409 | } |
tmccurbin | 36:8544a8900884 | 410 | } |
tmccurbin | 36:8544a8900884 | 411 | |
tmccurbin | 36:8544a8900884 | 412 | void ConnectedStatusCANMsg() |
tmccurbin | 36:8544a8900884 | 413 | { |
tmccurbin | 36:8544a8900884 | 414 | CANMessage ConnectedStatus(0x600, &ConnectedStatusBuffer,1); |
tmccurbin | 36:8544a8900884 | 415 | SteeringCANPort.txWrite(ConnectedStatus); |
tmccurbin | 36:8544a8900884 | 416 | } |
tmccurbin | 36:8544a8900884 | 417 | |
palimar | 23:6681a38918c6 | 418 | |
tmccurbin | 36:8544a8900884 | 419 | void RequestStatusChange() |
tmccurbin | 36:8544a8900884 | 420 | { |
tmccurbin | 36:8544a8900884 | 421 | CANMessage TxDriveStatusRequest(0x601, &DriveStatusRequestBuffer,1); |
tmccurbin | 36:8544a8900884 | 422 | for (int j=0; j<10; j++) { |
tmccurbin | 36:8544a8900884 | 423 | SteeringCANPort.txWrite(TxDriveStatusRequest); |
tmccurbin | 36:8544a8900884 | 424 | } |
tmccurbin | 36:8544a8900884 | 425 | display.PutString(7,0," DRIVE REQUEST SENT "); |
tmccurbin | 36:8544a8900884 | 426 | Thread::wait(750); |
tmccurbin | 36:8544a8900884 | 427 | PrevScreen = !CurrScreen; // To force a screen update |
tmccurbin | 36:8544a8900884 | 428 | } |
tmccurbin | 36:8544a8900884 | 429 | |
tmccurbin | 36:8544a8900884 | 430 | |
tmccurbin | 36:8544a8900884 | 431 | void ResetSteeringWheel() |
tmccurbin | 36:8544a8900884 | 432 | { |
tmccurbin | 36:8544a8900884 | 433 | NVIC_SystemReset(); |
tmccurbin | 36:8544a8900884 | 434 | } |
tmccurbin | 36:8544a8900884 | 435 | |
tmccurbin | 36:8544a8900884 | 436 | |
tmccurbin | 36:8544a8900884 | 437 | void ResetCar() |
tmccurbin | 36:8544a8900884 | 438 | { |
tmccurbin | 36:8544a8900884 | 439 | CANMessage TxCarReset(0x602,&TxResetBuffer,1); |
tmccurbin | 36:8544a8900884 | 440 | for (int k=0; k<10; k++) { |
tmccurbin | 36:8544a8900884 | 441 | SteeringCANPort.txWriteDirect(TxCarReset); |
tmccurbin | 36:8544a8900884 | 442 | } |
tmccurbin | 36:8544a8900884 | 443 | } |