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@36:8544a8900884, 2015-01-29 (annotated)
- Committer:
- tmccurbin
- Date:
- Thu Jan 29 04:27:19 2015 +0000
- Revision:
- 36:8544a8900884
- Parent:
- 35:b42afc973902
- Child:
- 38:d04a430d7fe3
MAJOR UPDATE; New libraries added for screens, buffers, & CAN addresses.; CAN data displays in real-time.
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 | 36:8544a8900884 | 4 | // Look at SYS management CAN translations: shutdown switches, DCDC status, & IMD status |
tmccurbin | 36:8544a8900884 | 5 | // Figure out screen/variable updating options |
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 | 36:8544a8900884 | 27 | display.GotoXY(10,16); |
tmccurbin | 36:8544a8900884 | 28 | display.SelectFont(Arial_14,BLACK,ReadData); |
tmccurbin | 36:8544a8900884 | 29 | display.PrintString("Penn Electric Racing"); |
tmccurbin | 36:8544a8900884 | 30 | wait(2); |
tmccurbin | 36:8544a8900884 | 31 | display.ClearScreen(); |
tmccurbin | 36:8544a8900884 | 32 | display.GotoXY(10,16); |
tmccurbin | 36:8544a8900884 | 33 | display.PrintString("Live the dream."); |
tmccurbin | 36:8544a8900884 | 34 | wait(2); |
tmccurbin | 36:8544a8900884 | 35 | |
tmccurbin | 36:8544a8900884 | 36 | Thread Thread2(ProcessButtons); |
tmccurbin | 36:8544a8900884 | 37 | Thread Thread1(DisplayCurrScreen); |
tmccurbin | 36:8544a8900884 | 38 | |
tmccurbin | 36:8544a8900884 | 39 | while(1) { |
tmccurbin | 36:8544a8900884 | 40 | CANMessage Rxmsg; |
tmccurbin | 36:8544a8900884 | 41 | if (SteeringCANPort.rxRead(Rxmsg)) { |
tmccurbin | 36:8544a8900884 | 42 | ProcessCANMsg(Rxmsg); |
tmccurbin | 32:535acb159709 | 43 | } |
tmccurbin | 32:535acb159709 | 44 | } |
tmccurbin | 32:535acb159709 | 45 | } |
tmccurbin | 32:535acb159709 | 46 | |
kiran_mbed | 0:313541d8f8be | 47 | |
kiran_mbed | 0:313541d8f8be | 48 | void Init() |
kiran_mbed | 0:313541d8f8be | 49 | { |
tmccurbin | 36:8544a8900884 | 50 | StatusMsg.attach(&ConnectedStatusCANMsg,0.1); |
palimar | 23:6681a38918c6 | 51 | pc.baud(921600); |
tmccurbin | 36:8544a8900884 | 52 | BLButtonRed; |
tmccurbin | 36:8544a8900884 | 53 | BRButtonGreen; |
tmccurbin | 36:8544a8900884 | 54 | TLButtonGreen; |
tmccurbin | 36:8544a8900884 | 55 | TRButtonGreen; |
tmccurbin | 36:8544a8900884 | 56 | DriveStatus = 0; // Off |
tmccurbin | 36:8544a8900884 | 57 | //initialize screen Startup Process |
tmccurbin | 36:8544a8900884 | 58 | wait(2); |
kiran_mbed | 0:313541d8f8be | 59 | } |
kiran_mbed | 0:313541d8f8be | 60 | |
tmccurbin | 36:8544a8900884 | 61 | |
tmccurbin | 36:8544a8900884 | 62 | void ProcessButtons(void const *args) |
tmccurbin | 36:8544a8900884 | 63 | { |
tmccurbin | 36:8544a8900884 | 64 | while(1) { |
tmccurbin | 36:8544a8900884 | 65 | Thread::wait(50); |
tmccurbin | 36:8544a8900884 | 66 | if(biSWBR.read()) { |
tmccurbin | 36:8544a8900884 | 67 | Thread::wait(750); |
tmccurbin | 36:8544a8900884 | 68 | if (biSWBR.read()) { |
tmccurbin | 36:8544a8900884 | 69 | ResetCar(); |
tmccurbin | 36:8544a8900884 | 70 | } |
tmccurbin | 36:8544a8900884 | 71 | NVIC_SystemReset(); |
tmccurbin | 36:8544a8900884 | 72 | ResetSteeringWheel(); |
tmccurbin | 36:8544a8900884 | 73 | } |
tmccurbin | 36:8544a8900884 | 74 | |
tmccurbin | 36:8544a8900884 | 75 | if(biSWBL.read()) { |
tmccurbin | 36:8544a8900884 | 76 | Thread::wait(1000); |
tmccurbin | 36:8544a8900884 | 77 | if (biSWBL.read()) { |
tmccurbin | 36:8544a8900884 | 78 | RequestStatusChange(); |
palimar | 23:6681a38918c6 | 79 | } |
palimar | 21:56890c41ecf1 | 80 | } |
tmccurbin | 36:8544a8900884 | 81 | |
tmccurbin | 36:8544a8900884 | 82 | if(biSWTR.read() && CurrScreen != 5) { |
tmccurbin | 36:8544a8900884 | 83 | //If the toggle button is pressed and the screen isn't on Fault_Screen |
tmccurbin | 36:8544a8900884 | 84 | ToggleScreen(); |
tmccurbin | 36:8544a8900884 | 85 | Thread::wait(250); |
tmccurbin | 36:8544a8900884 | 86 | } else if (biSWTR.read() && CurrScreen == 5) {// If the screen was on Fault, go to Home |
tmccurbin | 36:8544a8900884 | 87 | CurrScreen = 0; |
tmccurbin | 36:8544a8900884 | 88 | Thread::wait(250); |
tmccurbin | 36:8544a8900884 | 89 | } |
tmccurbin | 36:8544a8900884 | 90 | |
tmccurbin | 36:8544a8900884 | 91 | if(biSWTL.read() && CurrScreen != 0) { |
tmccurbin | 36:8544a8900884 | 92 | //If the Home button is pressed and the screen isn't on Fault_Screen |
tmccurbin | 36:8544a8900884 | 93 | CurrScreen = 0; |
tmccurbin | 36:8544a8900884 | 94 | Thread::wait(250); |
tmccurbin | 36:8544a8900884 | 95 | } else if (biSWTL.read() && CurrScreen == 0) {// If the screen was on Fault, go to Home |
tmccurbin | 36:8544a8900884 | 96 | CurrScreen = 5; |
tmccurbin | 36:8544a8900884 | 97 | Thread::wait(250); |
tmccurbin | 36:8544a8900884 | 98 | } |
palimar | 21:56890c41ecf1 | 99 | } |
palimar | 35:b42afc973902 | 100 | } |
palimar | 21:56890c41ecf1 | 101 | |
tmccurbin | 36:8544a8900884 | 102 | |
tmccurbin | 36:8544a8900884 | 103 | void UpdateDisplay() |
tmccurbin | 36:8544a8900884 | 104 | { |
tmccurbin | 36:8544a8900884 | 105 | } |
tmccurbin | 36:8544a8900884 | 106 | |
tmccurbin | 36:8544a8900884 | 107 | |
tmccurbin | 36:8544a8900884 | 108 | void ProcessCANMsg(CANMessage& Rxmsg) |
tmccurbin | 36:8544a8900884 | 109 | { |
tmccurbin | 36:8544a8900884 | 110 | if (SteeringCANPort.rxRead(Rxmsg)) { |
tmccurbin | 36:8544a8900884 | 111 | 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 | 36:8544a8900884 | 112 | for (int i=0; i < Rxmsg.len; i++) printf("D[%d]: %x ", i, Rxmsg.data[i]); |
tmccurbin | 36:8544a8900884 | 113 | switch (Rxmsg.id) { |
palimar | 4:a4fb060e7840 | 114 | |
tmccurbin | 36:8544a8900884 | 115 | // HOME SCREEN ******************************************************************************************* |
tmccurbin | 36:8544a8900884 | 116 | case SOC_TX_ID: |
tmccurbin | 36:8544a8900884 | 117 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 118 | sprintf(BigBatLifeBuffer,"%3.2d", int(CANFloat*100)); // Big battery life percentage |
tmccurbin | 36:8544a8900884 | 119 | display.PutString(1,40,BigBatLifeBuffer); |
tmccurbin | 36:8544a8900884 | 120 | break; |
tmccurbin | 36:8544a8900884 | 121 | case SYS_GLV_SOC_ID: |
tmccurbin | 36:8544a8900884 | 122 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 123 | sprintf(SmallBatLifeBuffer,"%3.2d", int(CANFloat*100)); // Small battery life percentage |
tmccurbin | 36:8544a8900884 | 124 | display.PutString(1,60,SmallBatLifeBuffer); |
tmccurbin | 36:8544a8900884 | 125 | break; |
tmccurbin | 36:8544a8900884 | 126 | case PCM_FRPM_ID: |
tmccurbin | 36:8544a8900884 | 127 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 128 | CANFloat2 = GetFloat4; |
tmccurbin | 36:8544a8900884 | 129 | sprintf(CarSpdBuffer,"%3.2d", int((CANFloat+CANFloat2)*WheelCircumference*30)); // Miles per hour |
tmccurbin | 36:8544a8900884 | 130 | display.PutString(1,108,CarSpdBuffer); |
tmccurbin | 36:8544a8900884 | 131 | case TEMP_MMA_TX_ID_BASE2: |
tmccurbin | 36:8544a8900884 | 132 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 133 | sprintf(AvgBatTBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Degrees F |
tmccurbin | 36:8544a8900884 | 134 | display.PutString(3,39,AvgBatTBuffer); |
tmccurbin | 36:8544a8900884 | 135 | //display.PutString(5,108,AvgBatTBuffer); this is for the battery screen |
tmccurbin | 36:8544a8900884 | 136 | case TEMP_MMA_TX_ID_BASE: |
tmccurbin | 36:8544a8900884 | 137 | CANFloat2 = GetFloat4; |
tmccurbin | 36:8544a8900884 | 138 | sprintf(MaxBatTBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); // Figure out Max/Min and Figure out various screen display |
tmccurbin | 36:8544a8900884 | 139 | display.PutString(3,103,MaxBatTBuffer); |
tmccurbin | 36:8544a8900884 | 140 | //display.PutString(5,20,MaxBatTBuffer); this is for the battery screen |
tmccurbin | 36:8544a8900884 | 141 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 142 | sprintf(MinBatTBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); |
tmccurbin | 36:8544a8900884 | 143 | //display.PutString(5,67,MinBatTBuffer); this is for the battery screen |
tmccurbin | 36:8544a8900884 | 144 | case MOC_MOTEMP_ID: |
tmccurbin | 36:8544a8900884 | 145 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 146 | sprintf(LMtrTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // We need to figure out how to handle the bytes for left and right motors |
tmccurbin | 36:8544a8900884 | 147 | display.PutString(5,34,LMtrTmpBuffer); |
tmccurbin | 36:8544a8900884 | 148 | // display.PutString(1,34,LMtrTmpBuffer); this is for the motor screen |
tmccurbin | 36:8544a8900884 | 149 | CANFloat2 = GetFloat4; |
tmccurbin | 36:8544a8900884 | 150 | sprintf(RMtrTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); // We need to figure out how to handle the bytes for left and right motors |
tmccurbin | 36:8544a8900884 | 151 | display.PutString(5,34,RMtrTmpBuffer); |
tmccurbin | 36:8544a8900884 | 152 | //display.PutString(1,98,LMtrTmpBuffer); this is for the motor screen |
tmccurbin | 36:8544a8900884 | 153 | // BATTERY SCREEN*********************************************************************************** |
tmccurbin | 36:8544a8900884 | 154 | case VOLTAGE_TX_ID: |
tmccurbin | 36:8544a8900884 | 155 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 156 | sprintf(BigBatVoltBuffer,"%3.2d", int(CANFloat)); // Volts |
tmccurbin | 36:8544a8900884 | 157 | //display.PutString(1,10,BigBatVoltBuffer); |
tmccurbin | 36:8544a8900884 | 158 | //display.PutString(3,94,BigBatVoltBuffer); this is for the charging screen |
tmccurbin | 36:8544a8900884 | 159 | case POWER_TX_ID: |
tmccurbin | 36:8544a8900884 | 160 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 161 | sprintf(BigBatPowerBuffer,"%3.2d", int(CANFloat)); // Watts |
tmccurbin | 36:8544a8900884 | 162 | //display.PutString(1,55,BigBatPowerBuffer); |
tmccurbin | 36:8544a8900884 | 163 | case CURRENT_TX_ID: |
tmccurbin | 36:8544a8900884 | 164 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 165 | sprintf(BigBatCurrentBuffer,"%3.2d", int(CANFloat)); // Amps |
tmccurbin | 36:8544a8900884 | 166 | //display.PutString(1,100,BigBatCurrentBuffer); |
tmccurbin | 36:8544a8900884 | 167 | case CELLV_MMA_TX_ID_BASE: |
tmccurbin | 36:8544a8900884 | 168 | CANFloat2 = GetFloat4; |
tmccurbin | 36:8544a8900884 | 169 | sprintf(VmaxBuffer,"%3.2d", int(CANFloat2)); // We need to figure out how to handle max and min |
tmccurbin | 36:8544a8900884 | 170 | //display.PutString(3,20,VmaxBuffer); |
tmccurbin | 36:8544a8900884 | 171 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 172 | sprintf(VminBuffer,"%3.2d", int(CANFloat)); |
tmccurbin | 36:8544a8900884 | 173 | //display.PutString(3,67,VminBuffer); |
tmccurbin | 36:8544a8900884 | 174 | case CELLV_MMA_TX_ID_BASE2: |
tmccurbin | 36:8544a8900884 | 175 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 176 | sprintf(VavgBuffer,"%3.2d", int(CANFloat)); // Volts |
tmccurbin | 36:8544a8900884 | 177 | //display.PutString(3,108,VavgBuffer); |
tmccurbin | 36:8544a8900884 | 178 | case BOARDTEMP_TX_ID: |
tmccurbin | 36:8544a8900884 | 179 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 180 | sprintf(BoardTempBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Degrees F |
tmccurbin | 36:8544a8900884 | 181 | //display.PutString(7,87,BoardTempBuffer); |
tmccurbin | 36:8544a8900884 | 182 | |
tmccurbin | 36:8544a8900884 | 183 | // MOTOR SCREEN***************************************************************** |
tmccurbin | 36:8544a8900884 | 184 | case MOC_AIRTEMP_ID: |
tmccurbin | 36:8544a8900884 | 185 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 186 | sprintf(LAirTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Figure out the left and the right |
tmccurbin | 36:8544a8900884 | 187 | //display.PutString(2,34,LAirTmpBuffer); |
tmccurbin | 36:8544a8900884 | 188 | CANFloat2 = GetFloat4; |
tmccurbin | 36:8544a8900884 | 189 | sprintf(RAirTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); // Degrees F |
tmccurbin | 36:8544a8900884 | 190 | //display.PutString(2,98,RAirTmpBuffer); |
tmccurbin | 36:8544a8900884 | 191 | case MOC_IGBTTEMP_ID: |
tmccurbin | 36:8544a8900884 | 192 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 193 | sprintf(LIGBTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Figure out the left and the right |
tmccurbin | 36:8544a8900884 | 194 | //display.PutString(3,34,LIGBTmpBuffer); |
tmccurbin | 36:8544a8900884 | 195 | CANFloat2 = GetFloat4; |
tmccurbin | 36:8544a8900884 | 196 | sprintf(RIGBTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); // Degrees F |
tmccurbin | 36:8544a8900884 | 197 | //display.PutString(3,98,RIGBTmpBuffer); |
tmccurbin | 36:8544a8900884 | 198 | case MOC_RPM_ID: |
tmccurbin | 36:8544a8900884 | 199 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 200 | sprintf(Rpm_LBuffer,"%3.2d", int(CANFloat)); // Figure out the left and the right |
tmccurbin | 36:8544a8900884 | 201 | //display.PutString(5,30,Rpm_LBuffer); |
tmccurbin | 36:8544a8900884 | 202 | CANFloat2 = GetFloat4; |
tmccurbin | 36:8544a8900884 | 203 | sprintf(Rpm_RBuffer,"%3.2d", int(CANFloat2)); |
tmccurbin | 36:8544a8900884 | 204 | //display.PutString(5,107,Rpm_RBuffer); |
tmccurbin | 36:8544a8900884 | 205 | case PCM_TORQUERQ_ID: |
tmccurbin | 36:8544a8900884 | 206 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 207 | sprintf(TRequestBufferL,"%3.2d", int(CANFloat*100)); // Percentage |
tmccurbin | 36:8544a8900884 | 208 | //display.PutString(7,89,TRequestBufferL); |
tmccurbin | 36:8544a8900884 | 209 | CANFloat2 = GetFloat4; |
tmccurbin | 36:8544a8900884 | 210 | sprintf(TRequestBufferR,"%3.2d", int(CANFloat2*100)); // Percentage |
tmccurbin | 36:8544a8900884 | 211 | //display.PutString(7,89,TRequestBufferR); |
tmccurbin | 36:8544a8900884 | 212 | |
tmccurbin | 36:8544a8900884 | 213 | // SYSTEM MANAGEMENT SCREEN*************************************************** |
tmccurbin | 36:8544a8900884 | 214 | case SYS_GLV_CURRENT_ID: |
tmccurbin | 36:8544a8900884 | 215 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 216 | sprintf(SmallBatCurrentBuffer,"%3.2d", int(CANFloat)); // Amps |
tmccurbin | 36:8544a8900884 | 217 | //display.PutString(1,30,SmallBatCurrentBuffer); |
tmccurbin | 36:8544a8900884 | 218 | case SYS_SWITCHES_ID: |
tmccurbin | 36:8544a8900884 | 219 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 220 | sprintf(ShtdSwtchBuffer,"%3.2d", int(CANFloat)); // How the heck are we interpreting this data |
tmccurbin | 36:8544a8900884 | 221 | //display.PutString(1,108,ShtdSwtchBuffer); |
tmccurbin | 36:8544a8900884 | 222 | case SYS_PWM_FAN_ID: |
tmccurbin | 36:8544a8900884 | 223 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 224 | sprintf(Fan1Buffer,"%3.2d", int(CANFloat*100)); // Duty Cycle. Figure out the left and the right |
tmccurbin | 36:8544a8900884 | 225 | //display.PutString(3,30,Fan1Buffer); |
tmccurbin | 36:8544a8900884 | 226 | CANFloat2 = GetFloat4; |
tmccurbin | 36:8544a8900884 | 227 | sprintf(Fan2Buffer,"%3.2d", int(CANFloat2*100)); |
tmccurbin | 36:8544a8900884 | 228 | //display.PutString(3,107,Fan2Buffer); |
tmccurbin | 36:8544a8900884 | 229 | case SYS_PWM_PUMP_ID: |
tmccurbin | 36:8544a8900884 | 230 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 231 | sprintf(Pump1Buffer,"%3.2d", int(CANFloat*100)); // Duty Cycle. Figure out the left and the right |
tmccurbin | 36:8544a8900884 | 232 | //display.PutString(5,30,Pump1Buffer); |
tmccurbin | 36:8544a8900884 | 233 | CANFloat2 = GetFloat4; |
tmccurbin | 36:8544a8900884 | 234 | sprintf(Pump2Buffer,"%3.2d", int(CANFloat2*100)); |
tmccurbin | 36:8544a8900884 | 235 | //display.PutString(5,107,Pump2Buffer); |
tmccurbin | 36:8544a8900884 | 236 | case SYS_DCDC_STATUS_ID: |
tmccurbin | 36:8544a8900884 | 237 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 238 | sprintf(DCDCBuffer,"%3.2d", int(CANFloat)); // How the heck are we interpreting this data |
tmccurbin | 36:8544a8900884 | 239 | //display.PutString(7,30,DCDCBuffer); |
tmccurbin | 36:8544a8900884 | 240 | case SYS_IMD_RESIST_ID: |
tmccurbin | 36:8544a8900884 | 241 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 242 | sprintf(IMDRBuffer,"%3.2d", int(CANFloat)); // How the heck are we interpreting this data |
tmccurbin | 36:8544a8900884 | 243 | //display.PutString(7,107,IMDRBuffer); |
tmccurbin | 36:8544a8900884 | 244 | |
tmccurbin | 36:8544a8900884 | 245 | // CHARGER SCREEN ************************************************************* |
tmccurbin | 36:8544a8900884 | 246 | case CHARGECURR_TX_ID: |
tmccurbin | 36:8544a8900884 | 247 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 248 | sprintf(ChargeCurrBuffer,"%3.2d", int(CANFloat)); // Amps |
tmccurbin | 36:8544a8900884 | 249 | //display.PutString(3,94,ChargeCurrBuffer); |
tmccurbin | 36:8544a8900884 | 250 | // OTHER ********************************************************************** |
tmccurbin | 36:8544a8900884 | 251 | case MODE_TX_ID: |
tmccurbin | 36:8544a8900884 | 252 | CANFloat = GetFloat; |
tmccurbin | 36:8544a8900884 | 253 | sprintf(&DriveStatus,"%3.2d", int(CANFloat)); //confirm that I am interpreting this correctly |
tmccurbin | 36:8544a8900884 | 254 | if (DriveStatus == 1) { |
tmccurbin | 36:8544a8900884 | 255 | BLButtonGreen; |
tmccurbin | 36:8544a8900884 | 256 | } else { |
tmccurbin | 36:8544a8900884 | 257 | BLButtonRed; |
tmccurbin | 36:8544a8900884 | 258 | } |
tmccurbin | 36:8544a8900884 | 259 | default: |
tmccurbin | 36:8544a8900884 | 260 | break; |
kiran_mbed | 0:313541d8f8be | 261 | } |
tmccurbin | 36:8544a8900884 | 262 | } |
tmccurbin | 36:8544a8900884 | 263 | } |
tmccurbin | 36:8544a8900884 | 264 | |
tmccurbin | 36:8544a8900884 | 265 | void ConnectedStatusCANMsg() |
tmccurbin | 36:8544a8900884 | 266 | { |
tmccurbin | 36:8544a8900884 | 267 | CANMessage ConnectedStatus(0x600, &ConnectedStatusBuffer,1); |
tmccurbin | 36:8544a8900884 | 268 | SteeringCANPort.txWrite(ConnectedStatus); |
tmccurbin | 36:8544a8900884 | 269 | } |
tmccurbin | 36:8544a8900884 | 270 | |
palimar | 23:6681a38918c6 | 271 | |
tmccurbin | 36:8544a8900884 | 272 | void RequestStatusChange() |
tmccurbin | 36:8544a8900884 | 273 | { |
tmccurbin | 36:8544a8900884 | 274 | DriveStatusRequestBuffer = !DriveStatus; |
tmccurbin | 36:8544a8900884 | 275 | CANMessage TxDriveStatusRequest(0x601, &DriveStatusRequestBuffer,1); |
tmccurbin | 36:8544a8900884 | 276 | for (int j=0; j<10; j++) { |
tmccurbin | 36:8544a8900884 | 277 | SteeringCANPort.txWrite(TxDriveStatusRequest); |
tmccurbin | 36:8544a8900884 | 278 | } |
tmccurbin | 36:8544a8900884 | 279 | display.PutString(7,0," DRIVE REQUEST SENT "); |
tmccurbin | 36:8544a8900884 | 280 | Thread::wait(750); |
tmccurbin | 36:8544a8900884 | 281 | PrevScreen = !CurrScreen; // To force a screen update |
tmccurbin | 36:8544a8900884 | 282 | } |
tmccurbin | 36:8544a8900884 | 283 | |
tmccurbin | 36:8544a8900884 | 284 | |
tmccurbin | 36:8544a8900884 | 285 | void ResetSteeringWheel() |
tmccurbin | 36:8544a8900884 | 286 | { |
tmccurbin | 36:8544a8900884 | 287 | NVIC_SystemReset(); |
tmccurbin | 36:8544a8900884 | 288 | } |
tmccurbin | 36:8544a8900884 | 289 | |
tmccurbin | 36:8544a8900884 | 290 | |
tmccurbin | 36:8544a8900884 | 291 | void ResetCar() |
tmccurbin | 36:8544a8900884 | 292 | { |
tmccurbin | 36:8544a8900884 | 293 | CANMessage TxCarReset(0x602,&TxResetBuffer,1); |
tmccurbin | 36:8544a8900884 | 294 | for (int k=0; k<10; k++) { |
tmccurbin | 36:8544a8900884 | 295 | SteeringCANPort.txWriteDirect(TxCarReset); |
tmccurbin | 36:8544a8900884 | 296 | } |
tmccurbin | 36:8544a8900884 | 297 | } |