The Code Repository for the REV0 Steering Wheel.
Dependencies: CANBuffer KS0108_fork mbed-rtos mbed CAN Addresses
Fork of REVO_Updated_Steering by
Screens.h@47:5d3c6f85fa29, 2015-05-30 (annotated)
- Committer:
- jayf
- Date:
- Sat May 30 02:26:23 2015 +0000
- Revision:
- 47:5d3c6f85fa29
- Parent:
- 40:92f08fdc32df
Fixed all known steering wheel issues
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tmccurbin | 36:8544a8900884 | 1 | #include "KS0108.h" |
tmccurbin | 36:8544a8900884 | 2 | #include "Buffers.h" |
tmccurbin | 36:8544a8900884 | 3 | |
tmccurbin | 36:8544a8900884 | 4 | // Macro for printing to screen; Where y is the start poition of the text, and y2 is the start position of the variable |
tmccurbin | 36:8544a8900884 | 5 | #define PUT2SCREEN(string, var, unit, x, y, y2) display.PutString(x, y, string); display.PutString(x, y2, var); display.PutString(x,y2+15,unit); |
tmccurbin | 36:8544a8900884 | 6 | |
tmccurbin | 36:8544a8900884 | 7 | #define HOME_SCREEN 0 |
tmccurbin | 36:8544a8900884 | 8 | #define BATTERY_SCREEN 1 |
tmccurbin | 36:8544a8900884 | 9 | #define MOTOR_SCREEN 2 |
tmccurbin | 36:8544a8900884 | 10 | #define SYS_MGMT_SCREEN 3 |
tmccurbin | 36:8544a8900884 | 11 | #define CHARGE_SCREEN 4 |
tmccurbin | 36:8544a8900884 | 12 | #define FAULT_SCREEN 5 |
tmccurbin | 36:8544a8900884 | 13 | |
tmccurbin | 36:8544a8900884 | 14 | |
tmccurbin | 36:8544a8900884 | 15 | |
tmccurbin | 36:8544a8900884 | 16 | // Initialize Variables |
tmccurbin | 36:8544a8900884 | 17 | int CurrScreen = HOME_SCREEN; |
tmccurbin | 36:8544a8900884 | 18 | int PrevScreen = !CurrScreen; |
tmccurbin | 36:8544a8900884 | 19 | |
tmccurbin | 36:8544a8900884 | 20 | // Defines the pins for the dsiplay. These are hardwired. |
tmccurbin | 36:8544a8900884 | 21 | KS0108 display(p26, p21, p22, p23, p25, p24, p8, p7, p6, p5, p13, p14, p12, p11); |
tmccurbin | 36:8544a8900884 | 22 | |
tmccurbin | 36:8544a8900884 | 23 | void DisplayHomeScreen() |
tmccurbin | 36:8544a8900884 | 24 | { |
tmccurbin | 36:8544a8900884 | 25 | display.ClearScreen(); |
tmccurbin | 36:8544a8900884 | 26 | display.PutString(0, 54, "Home"); |
tmccurbin | 36:8544a8900884 | 27 | |
tmccurbin | 36:8544a8900884 | 28 | //Info line 1: Battery Life & Vehicle Speed |
tmccurbin | 36:8544a8900884 | 29 | PUT2SCREEN("BatLife:", BigBatLifeBuffer, "%", 1, 0, 39); |
tmccurbin | 36:8544a8900884 | 30 | PUT2SCREEN(",", SmallBatLifeBuffer, "%", 1, 59, 62); |
tmccurbin | 36:8544a8900884 | 31 | PUT2SCREEN("Spd:", CarSpdBuffer, "", 1, 89,108); |
tmccurbin | 36:8544a8900884 | 32 | |
tmccurbin | 36:8544a8900884 | 33 | //Info line 2: Average Battery Temp & Peak Battery Temp |
tmccurbin | 36:8544a8900884 | 34 | PUT2SCREEN("AvgBatT:", AvgBatTBuffer, "F", 3, 0, 39); |
tmccurbin | 36:8544a8900884 | 35 | PUT2SCREEN("PkBatT:", MaxBatTBuffer, "F", 3, 69,103); |
tmccurbin | 36:8544a8900884 | 36 | |
tmccurbin | 36:8544a8900884 | 37 | //Info line 3: Left Motor Temp & Right Motor Temp |
tmccurbin | 36:8544a8900884 | 38 | PUT2SCREEN("LMtTmp:", LMtrTmpBuffer, "F", 5, 0, 34); |
tmccurbin | 36:8544a8900884 | 39 | PUT2SCREEN("RMtTmp:", RMtrTmpBuffer, "F", 5, 69,103); |
tmccurbin | 36:8544a8900884 | 40 | |
tmccurbin | 36:8544a8900884 | 41 | //Fault line |
tmccurbin | 36:8544a8900884 | 42 | display.PutString(7, 14, "Reserved for faults"); |
tmccurbin | 36:8544a8900884 | 43 | } |
tmccurbin | 36:8544a8900884 | 44 | |
tmccurbin | 36:8544a8900884 | 45 | void DisplayBatteryScreen() |
tmccurbin | 36:8544a8900884 | 46 | { |
tmccurbin | 36:8544a8900884 | 47 | display.ClearScreen(); |
tmccurbin | 36:8544a8900884 | 48 | display.PutString(0, 34, "Main Battery"); |
tmccurbin | 36:8544a8900884 | 49 | |
tmccurbin | 36:8544a8900884 | 50 | //Info line 1: Battery Voltage, Power & Current |
tmccurbin | 36:8544a8900884 | 51 | PUT2SCREEN("V:", BigBatVoltBuffer, "V", 1, 0, 10); |
tmccurbin | 36:8544a8900884 | 52 | PUT2SCREEN("P:", BigBatPowerBuffer, "W", 1, 45, 55); |
tmccurbin | 36:8544a8900884 | 53 | PUT2SCREEN("I:", BigBatCurrentBuffer, "A", 1, 90,100); |
tmccurbin | 36:8544a8900884 | 54 | |
tmccurbin | 36:8544a8900884 | 55 | //Info line 2: High, Low, & Average Cell Voltage |
tmccurbin | 36:8544a8900884 | 56 | PUT2SCREEN("Vmx:", VmaxBuffer, "V", 3, 0, 20); |
tmccurbin | 36:8544a8900884 | 57 | PUT2SCREEN("Vmn:", VminBuffer, "", 3, 47, 67); |
tmccurbin | 36:8544a8900884 | 58 | PUT2SCREEN("Vav:", VavgBuffer, "", 3, 88,108); |
tmccurbin | 36:8544a8900884 | 59 | |
tmccurbin | 36:8544a8900884 | 60 | //Info line 3: High, Low, & Average Cell Temp |
tmccurbin | 36:8544a8900884 | 61 | PUT2SCREEN("Tmx:", MaxBatTBuffer, "F", 5, 0, 20); |
tmccurbin | 36:8544a8900884 | 62 | PUT2SCREEN("Tmn:", MinBatTBuffer, "", 5, 47, 67); |
tmccurbin | 36:8544a8900884 | 63 | PUT2SCREEN("Tav:", AvgBatTBuffer, "", 5, 88,108); |
tmccurbin | 36:8544a8900884 | 64 | |
tmccurbin | 36:8544a8900884 | 65 | //Info line 4: Highest Board Temp |
tmccurbin | 36:8544a8900884 | 66 | PUT2SCREEN("HighBoardTemp:", BoardTempBuffer, "F", 7, 17, 87); |
tmccurbin | 36:8544a8900884 | 67 | } |
tmccurbin | 36:8544a8900884 | 68 | |
tmccurbin | 36:8544a8900884 | 69 | void DisplayMotorScreen() |
tmccurbin | 36:8544a8900884 | 70 | { |
tmccurbin | 36:8544a8900884 | 71 | display.ClearScreen(); |
tmccurbin | 36:8544a8900884 | 72 | display.PutString(0, 52, "Motor"); |
tmccurbin | 36:8544a8900884 | 73 | |
tmccurbin | 36:8544a8900884 | 74 | //Info line 1: Left Motor Temp & Right Motor Temp |
tmccurbin | 36:8544a8900884 | 75 | PUT2SCREEN("LMtTmp:", LMtrTmpBuffer, "F", 1, 0, 34); |
tmccurbin | 36:8544a8900884 | 76 | PUT2SCREEN("RMtTmp:", RMtrTmpBuffer, "F", 1, 64, 98); |
tmccurbin | 36:8544a8900884 | 77 | |
tmccurbin | 36:8544a8900884 | 78 | //Info line 2: Left & Right Air Temp |
tmccurbin | 36:8544a8900884 | 79 | PUT2SCREEN("LAirTp:", LAirTmpBuffer, "F", 2, 0, 34); |
tmccurbin | 36:8544a8900884 | 80 | PUT2SCREEN("RairTp:", RAirTmpBuffer, "F", 2, 64, 98); |
tmccurbin | 36:8544a8900884 | 81 | |
tmccurbin | 36:8544a8900884 | 82 | //Info line 3: Left & Right IGBT Temp |
tmccurbin | 36:8544a8900884 | 83 | PUT2SCREEN("LIGBTp:", LIGBTmpBuffer, "F", 3, 0, 34); |
tmccurbin | 36:8544a8900884 | 84 | PUT2SCREEN("RIGBTp:", RIGBTmpBuffer, "F", 3, 64, 98); |
tmccurbin | 36:8544a8900884 | 85 | |
tmccurbin | 36:8544a8900884 | 86 | //Info line 4: Left & Right Motor RPM |
tmccurbin | 36:8544a8900884 | 87 | PUT2SCREEN("Rpm-L:", Rpm_LBuffer, "", 5, 0, 30); |
tmccurbin | 36:8544a8900884 | 88 | PUT2SCREEN("Rpm-R:", Rpm_RBuffer, "", 5, 77,107); |
tmccurbin | 36:8544a8900884 | 89 | |
tmccurbin | 36:8544a8900884 | 90 | //Info line 5: Torque Request (Throttle) |
tmccurbin | 36:8544a8900884 | 91 | PUT2SCREEN("Torque Request:", TRequestBufferL, "%", 7, 0, 75); |
tmccurbin | 36:8544a8900884 | 92 | PUT2SCREEN(",", TRequestBufferR, "%", 7, 95, 98); |
tmccurbin | 36:8544a8900884 | 93 | } |
tmccurbin | 36:8544a8900884 | 94 | |
tmccurbin | 36:8544a8900884 | 95 | void DisplaySysMgmtScreen() |
tmccurbin | 36:8544a8900884 | 96 | { |
tmccurbin | 36:8544a8900884 | 97 | display.ClearScreen(); |
tmccurbin | 36:8544a8900884 | 98 | display.PutString(0, 22, "System Management"); |
tmccurbin | 36:8544a8900884 | 99 | |
tmccurbin | 36:8544a8900884 | 100 | //Info line 1: Small Battery Current & Shutdown Switch State |
tmccurbin | 36:8544a8900884 | 101 | PUT2SCREEN("I_GLV:", SmallBatCurrentBuffer,"A", 1, 0, 30); |
tmccurbin | 36:8544a8900884 | 102 | PUT2SCREEN("ShtdSwtch:", ShtdSwtchBuffer, "", 1, 58,108); |
tmccurbin | 36:8544a8900884 | 103 | |
tmccurbin | 36:8544a8900884 | 104 | //Info line 2: Fan Duty Cycle |
tmccurbin | 36:8544a8900884 | 105 | PUT2SCREEN("Fan-1:", Fan1Buffer, "", 3, 0, 30); |
tmccurbin | 36:8544a8900884 | 106 | PUT2SCREEN("Fan-2:", Fan2Buffer, "", 3, 77,107); |
tmccurbin | 36:8544a8900884 | 107 | |
tmccurbin | 36:8544a8900884 | 108 | //Info line 3: Pump Duty Cycle |
tmccurbin | 36:8544a8900884 | 109 | PUT2SCREEN("Pump1:", Pump1Buffer, "", 5, 0, 30); |
tmccurbin | 36:8544a8900884 | 110 | PUT2SCREEN("Pump2:", Pump2Buffer, "", 5, 77,107); |
tmccurbin | 36:8544a8900884 | 111 | |
tmccurbin | 36:8544a8900884 | 112 | //Info line 4: DCDC & IMD Status |
tmccurbin | 36:8544a8900884 | 113 | PUT2SCREEN("DCDC :", DCDCBuffer, "", 7, 0, 30); |
tmccurbin | 40:92f08fdc32df | 114 | PUT2SCREEN(" IMD :", IMDRBuffer, "", 7, 52,82); |
tmccurbin | 36:8544a8900884 | 115 | } |
tmccurbin | 36:8544a8900884 | 116 | |
tmccurbin | 36:8544a8900884 | 117 | void DisplayFaultScreen() |
tmccurbin | 36:8544a8900884 | 118 | { |
tmccurbin | 36:8544a8900884 | 119 | display.ClearScreen(); |
tmccurbin | 36:8544a8900884 | 120 | display.PutString(0, 49, "Faults"); |
tmccurbin | 36:8544a8900884 | 121 | |
tmccurbin | 36:8544a8900884 | 122 | //Info line 1: Battery Voltage, Power & Current |
tmccurbin | 36:8544a8900884 | 123 | PUT2SCREEN("", Fault1Buffer, "", 1, 0, 0); |
tmccurbin | 36:8544a8900884 | 124 | PUT2SCREEN("", Fault1Buffer, "", 2, 0, 0); |
tmccurbin | 36:8544a8900884 | 125 | PUT2SCREEN("", Fault1Buffer, "", 3, 0, 0); |
tmccurbin | 36:8544a8900884 | 126 | PUT2SCREEN("", Fault1Buffer, "", 4, 0, 0); |
tmccurbin | 36:8544a8900884 | 127 | PUT2SCREEN("", Fault1Buffer, "", 5, 0, 0); |
tmccurbin | 36:8544a8900884 | 128 | PUT2SCREEN("", Fault1Buffer, "", 6, 0, 0); |
tmccurbin | 36:8544a8900884 | 129 | PUT2SCREEN("", Fault1Buffer, "", 7, 0, 0); |
tmccurbin | 36:8544a8900884 | 130 | } |
tmccurbin | 36:8544a8900884 | 131 | |
tmccurbin | 36:8544a8900884 | 132 | void DisplayChargeScreen() |
tmccurbin | 36:8544a8900884 | 133 | { |
tmccurbin | 36:8544a8900884 | 134 | display.ClearScreen(); |
tmccurbin | 36:8544a8900884 | 135 | display.PutString(0, 44, "CHARGING"); |
tmccurbin | 36:8544a8900884 | 136 | |
tmccurbin | 36:8544a8900884 | 137 | // Battery Voltage, Charge Current, & Source Voltage |
tmccurbin | 36:8544a8900884 | 138 | PUT2SCREEN("Battery Voltage :", BigBatVoltBuffer, "V", 1, 9, 94); |
tmccurbin | 36:8544a8900884 | 139 | PUT2SCREEN("Charging Current:", ChargeCurrBuffer, "V", 3, 9, 94); |
tmccurbin | 36:8544a8900884 | 140 | PUT2SCREEN("Source Voltage :", SourceVBuffer, "F", 5, 12, 92); |
tmccurbin | 36:8544a8900884 | 141 | } |
tmccurbin | 36:8544a8900884 | 142 | |
tmccurbin | 36:8544a8900884 | 143 | void ToggleScreen() |
tmccurbin | 36:8544a8900884 | 144 | { |
tmccurbin | 36:8544a8900884 | 145 | CurrScreen = (CurrScreen+1) %5; |
tmccurbin | 36:8544a8900884 | 146 | } |
tmccurbin | 36:8544a8900884 | 147 | |
tmccurbin | 36:8544a8900884 | 148 | void DisplayCurrScreen(void const *args) |
tmccurbin | 36:8544a8900884 | 149 | { |
tmccurbin | 36:8544a8900884 | 150 | while(1) { |
tmccurbin | 36:8544a8900884 | 151 | if(PrevScreen != CurrScreen) { |
tmccurbin | 36:8544a8900884 | 152 | switch(CurrScreen) { |
tmccurbin | 36:8544a8900884 | 153 | case 0: |
tmccurbin | 36:8544a8900884 | 154 | DisplayHomeScreen(); |
tmccurbin | 36:8544a8900884 | 155 | break; |
tmccurbin | 36:8544a8900884 | 156 | case 1: |
tmccurbin | 36:8544a8900884 | 157 | DisplayBatteryScreen(); |
tmccurbin | 36:8544a8900884 | 158 | break; |
tmccurbin | 36:8544a8900884 | 159 | case 2: |
tmccurbin | 36:8544a8900884 | 160 | DisplayMotorScreen(); |
tmccurbin | 36:8544a8900884 | 161 | break; |
tmccurbin | 36:8544a8900884 | 162 | case 3: |
tmccurbin | 36:8544a8900884 | 163 | DisplaySysMgmtScreen(); |
tmccurbin | 36:8544a8900884 | 164 | break; |
tmccurbin | 36:8544a8900884 | 165 | case 4: |
tmccurbin | 36:8544a8900884 | 166 | DisplayChargeScreen(); |
tmccurbin | 36:8544a8900884 | 167 | break; |
tmccurbin | 36:8544a8900884 | 168 | case 5: |
tmccurbin | 36:8544a8900884 | 169 | DisplayFaultScreen(); |
tmccurbin | 36:8544a8900884 | 170 | break; |
tmccurbin | 36:8544a8900884 | 171 | default: |
tmccurbin | 36:8544a8900884 | 172 | break; |
tmccurbin | 36:8544a8900884 | 173 | } |
tmccurbin | 36:8544a8900884 | 174 | PrevScreen = CurrScreen; |
tmccurbin | 36:8544a8900884 | 175 | } |
jayf | 47:5d3c6f85fa29 | 176 | Thread::yield(); |
tmccurbin | 36:8544a8900884 | 177 | } |
tmccurbin | 36:8544a8900884 | 178 | |
tmccurbin | 36:8544a8900884 | 179 | } |