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@21:56890c41ecf1, 2014-10-25 (annotated)
- Committer:
- palimar
- Date:
- Sat Oct 25 17:24:58 2014 +0000
- Revision:
- 21:56890c41ecf1
- Parent:
- 20:c3f4828f3cbc
- Child:
- 22:ab33195882e3
- Child:
- 23:6681a38918c6
Added new thread to update drive status variable
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 | |
kiran_mbed | 0:313541d8f8be | 3 | void HomeScreen() |
kiran_mbed | 0:313541d8f8be | 4 | { |
palimar | 21:56890c41ecf1 | 5 | |
kiran_mbed | 0:313541d8f8be | 6 | ftc rcv; |
kiran_mbed | 0:313541d8f8be | 7 | rcv.FLOAT=0.0; |
kiran_mbed | 0:313541d8f8be | 8 | char dat[4]; |
kiran_mbed | 0:313541d8f8be | 9 | float power_ratio=0.0; |
kiran_mbed | 0:313541d8f8be | 10 | printf("Homescreen\n\r"); |
kiran_mbed | 0:313541d8f8be | 11 | display.ClearScreen(); |
kiran_mbed | 0:313541d8f8be | 12 | display.SelectFont(Arial12,BLACK,ReadData); |
kiran_mbed | 0:313541d8f8be | 13 | display.GotoXY(0,0); |
kiran_mbed | 0:313541d8f8be | 14 | display.PrintString(" HOME SCREEN"); |
kiran_mbed | 0:313541d8f8be | 15 | while( !(biSWTL.read() || biSWTR.read() || biSWBR.read()) ) |
kiran_mbed | 0:313541d8f8be | 16 | { |
palimar | 21:56890c41ecf1 | 17 | CANMessage Rxmsg; |
palimar | 16:d2953809fb31 | 18 | if(CAN_Steering_Buffer.rxRead(Rxmsg)) |
kiran_mbed | 0:313541d8f8be | 19 | { |
kiran_mbed | 0:313541d8f8be | 20 | for(int i=0; i<4; i++) |
kiran_mbed | 0:313541d8f8be | 21 | rcv.C_FLOAT[i]=Rxmsg.data[i]; |
kiran_mbed | 0:313541d8f8be | 22 | if(Rxmsg.id == BATTERY_VOLTAGE_ID) |
kiran_mbed | 0:313541d8f8be | 23 | { |
kiran_mbed | 0:313541d8f8be | 24 | display.GotoXY(0,16); |
kiran_mbed | 0:313541d8f8be | 25 | display.PrintString(" PV: "); |
kiran_mbed | 0:313541d8f8be | 26 | sprintf(dat,"%2.2f",rcv.FLOAT); |
kiran_mbed | 0:313541d8f8be | 27 | display.PrintString(dat); |
kiran_mbed | 0:313541d8f8be | 28 | display.PrintString("V"); |
kiran_mbed | 0:313541d8f8be | 29 | } |
kiran_mbed | 0:313541d8f8be | 30 | if(Rxmsg.id == BATTERY_POWER_ID) |
kiran_mbed | 0:313541d8f8be | 31 | { |
kiran_mbed | 0:313541d8f8be | 32 | display.GotoXY(64,16); |
kiran_mbed | 0:313541d8f8be | 33 | display.PrintString(" PP: "); |
kiran_mbed | 0:313541d8f8be | 34 | power_ratio=rcv.FLOAT/10000; |
kiran_mbed | 0:313541d8f8be | 35 | sprintf(dat,"%2.2f",power_ratio); |
kiran_mbed | 0:313541d8f8be | 36 | display.PrintString(dat); |
kiran_mbed | 0:313541d8f8be | 37 | display.PrintString("kW"); |
kiran_mbed | 0:313541d8f8be | 38 | } |
kiran_mbed | 0:313541d8f8be | 39 | if(Rxmsg.id == PCM_STATE_ID) |
kiran_mbed | 0:313541d8f8be | 40 | { |
kiran_mbed | 0:313541d8f8be | 41 | display.GotoXY(0,32); |
kiran_mbed | 0:313541d8f8be | 42 | display.PrintString(" STATE: "); |
kiran_mbed | 0:313541d8f8be | 43 | display.PrintNumber(rcv.FLOAT); |
kiran_mbed | 0:313541d8f8be | 44 | } |
kiran_mbed | 0:313541d8f8be | 45 | } |
kiran_mbed | 0:313541d8f8be | 46 | } |
kiran_mbed | 0:313541d8f8be | 47 | return; |
kiran_mbed | 0:313541d8f8be | 48 | } |
kiran_mbed | 0:313541d8f8be | 49 | |
kiran_mbed | 0:313541d8f8be | 50 | void AMSScreen1() |
kiran_mbed | 0:313541d8f8be | 51 | { |
kiran_mbed | 0:313541d8f8be | 52 | CANMessage Rxmsg; |
kiran_mbed | 0:313541d8f8be | 53 | ftc rcv; |
kiran_mbed | 0:313541d8f8be | 54 | char dat[4]; |
kiran_mbed | 0:313541d8f8be | 55 | rcv.FLOAT=0.0; |
kiran_mbed | 0:313541d8f8be | 56 | printf("AMSScreen1"); |
kiran_mbed | 0:313541d8f8be | 57 | display.ClearScreen(); |
kiran_mbed | 0:313541d8f8be | 58 | display.SelectFont(Arial12,BLACK,ReadData); |
kiran_mbed | 0:313541d8f8be | 59 | while( !(biSWTL.read() || biSWTR.read() || biSWBL.read()) ) |
kiran_mbed | 0:313541d8f8be | 60 | { |
kiran_mbed | 0:313541d8f8be | 61 | printf("iN LOOP1"); |
palimar | 16:d2953809fb31 | 62 | if(CAN_Steering_Buffer.rxRead(Rxmsg)) |
kiran_mbed | 0:313541d8f8be | 63 | { |
kiran_mbed | 0:313541d8f8be | 64 | for(int i=0; i<4; i++) |
kiran_mbed | 0:313541d8f8be | 65 | rcv.C_FLOAT[i]=Rxmsg.data[i]; |
kiran_mbed | 0:313541d8f8be | 66 | if(Rxmsg.id == BATTERY_VOLTAGE_ID) |
kiran_mbed | 0:313541d8f8be | 67 | { |
kiran_mbed | 0:313541d8f8be | 68 | display.GotoXY(0,0); |
kiran_mbed | 0:313541d8f8be | 69 | display.PrintString(" pv: "); |
kiran_mbed | 0:313541d8f8be | 70 | sprintf(dat,"%2.2f",rcv.FLOAT); |
kiran_mbed | 0:313541d8f8be | 71 | display.PrintString(dat); |
kiran_mbed | 0:313541d8f8be | 72 | } |
kiran_mbed | 0:313541d8f8be | 73 | if(Rxmsg.id == BATTERY_POWER_ID) |
kiran_mbed | 0:313541d8f8be | 74 | { |
kiran_mbed | 0:313541d8f8be | 75 | display.GotoXY(0,16); |
kiran_mbed | 0:313541d8f8be | 76 | display.PrintString(" pp: "); |
kiran_mbed | 0:313541d8f8be | 77 | sprintf(dat,"%2.2f",rcv.FLOAT); |
kiran_mbed | 0:313541d8f8be | 78 | display.PrintString(dat); |
kiran_mbed | 0:313541d8f8be | 79 | } |
kiran_mbed | 0:313541d8f8be | 80 | if(Rxmsg.id == BATTERY_CURRENT_ID) |
kiran_mbed | 0:313541d8f8be | 81 | { |
kiran_mbed | 0:313541d8f8be | 82 | display.GotoXY(0,32); |
kiran_mbed | 0:313541d8f8be | 83 | display.PrintString(" pi: "); |
kiran_mbed | 0:313541d8f8be | 84 | sprintf(dat,"%2.2f",rcv.FLOAT); |
kiran_mbed | 0:313541d8f8be | 85 | display.PrintString(dat); |
kiran_mbed | 0:313541d8f8be | 86 | } |
kiran_mbed | 0:313541d8f8be | 87 | |
kiran_mbed | 0:313541d8f8be | 88 | //Column 2 |
kiran_mbed | 0:313541d8f8be | 89 | if(Rxmsg.id == BATTERY_MIN_CELLVOLTAGE_ID) |
kiran_mbed | 0:313541d8f8be | 90 | { |
kiran_mbed | 0:313541d8f8be | 91 | display.GotoXY(49,0); |
kiran_mbed | 0:313541d8f8be | 92 | display.PrintString(" min cell V: "); |
kiran_mbed | 0:313541d8f8be | 93 | sprintf(dat,"%2.2f",rcv.FLOAT); |
kiran_mbed | 0:313541d8f8be | 94 | display.PrintString(dat); |
kiran_mbed | 0:313541d8f8be | 95 | } |
kiran_mbed | 0:313541d8f8be | 96 | if(Rxmsg.id == BATTERY_MAX_CELLVOLTAGE_ID) |
kiran_mbed | 0:313541d8f8be | 97 | { |
kiran_mbed | 0:313541d8f8be | 98 | display.GotoXY(49,16); |
kiran_mbed | 0:313541d8f8be | 99 | display.PrintString(" max cell V: "); |
kiran_mbed | 0:313541d8f8be | 100 | sprintf(dat,"%2.2f",rcv.FLOAT); |
kiran_mbed | 0:313541d8f8be | 101 | display.PrintString(dat); |
kiran_mbed | 0:313541d8f8be | 102 | } |
kiran_mbed | 0:313541d8f8be | 103 | if(Rxmsg.id == BATTERY_AVG_CELLVOLTAGE_ID) |
kiran_mbed | 0:313541d8f8be | 104 | { |
kiran_mbed | 0:313541d8f8be | 105 | display.GotoXY(49,32); |
kiran_mbed | 0:313541d8f8be | 106 | display.PrintString(" avg cell V: "); |
kiran_mbed | 0:313541d8f8be | 107 | sprintf(dat,"%2.2f",rcv.FLOAT); |
kiran_mbed | 0:313541d8f8be | 108 | display.PrintString(dat); |
kiran_mbed | 0:313541d8f8be | 109 | } |
kiran_mbed | 0:313541d8f8be | 110 | } |
kiran_mbed | 0:313541d8f8be | 111 | screen=1; |
kiran_mbed | 0:313541d8f8be | 112 | } |
kiran_mbed | 0:313541d8f8be | 113 | return; |
kiran_mbed | 0:313541d8f8be | 114 | } |
kiran_mbed | 0:313541d8f8be | 115 | |
kiran_mbed | 0:313541d8f8be | 116 | void AMSScreen2() |
kiran_mbed | 0:313541d8f8be | 117 | { |
kiran_mbed | 0:313541d8f8be | 118 | CANMessage Rxmsg; |
kiran_mbed | 0:313541d8f8be | 119 | ftc rcv; |
kiran_mbed | 0:313541d8f8be | 120 | char dat[4]; |
kiran_mbed | 0:313541d8f8be | 121 | //ftc send; |
kiran_mbed | 0:313541d8f8be | 122 | rcv.FLOAT=0.0; |
kiran_mbed | 0:313541d8f8be | 123 | //send.FLOAT=65.6432; |
kiran_mbed | 0:313541d8f8be | 124 | printf("AMSScreen2\n\r"); |
kiran_mbed | 0:313541d8f8be | 125 | display.ClearScreen(); |
kiran_mbed | 0:313541d8f8be | 126 | display.SelectFont(Arial12,BLACK,ReadData); |
kiran_mbed | 0:313541d8f8be | 127 | while( !(biSWTL.read() || biSWTR.read() || biSWBL.read()) ) |
kiran_mbed | 0:313541d8f8be | 128 | { |
kiran_mbed | 0:313541d8f8be | 129 | printf("iN LOOP2"); |
palimar | 16:d2953809fb31 | 130 | if(CAN_Steering_Buffer.rxRead(Rxmsg)) |
kiran_mbed | 0:313541d8f8be | 131 | { |
kiran_mbed | 0:313541d8f8be | 132 | for(int i=0; i<4; i++) |
kiran_mbed | 0:313541d8f8be | 133 | rcv.C_FLOAT[i]=Rxmsg.data[i]; |
kiran_mbed | 0:313541d8f8be | 134 | if(Rxmsg.id == BATTERY_MIN_CELLTEMPERATURE_ID) |
kiran_mbed | 0:313541d8f8be | 135 | { |
kiran_mbed | 0:313541d8f8be | 136 | display.GotoXY(0,0); |
kiran_mbed | 0:313541d8f8be | 137 | display.PrintString(" mn cll T: "); |
kiran_mbed | 0:313541d8f8be | 138 | sprintf(dat,"%2.2f",rcv.FLOAT); |
kiran_mbed | 0:313541d8f8be | 139 | display.PrintString(dat); |
kiran_mbed | 0:313541d8f8be | 140 | } |
kiran_mbed | 0:313541d8f8be | 141 | if(Rxmsg.id == BATTERY_MAX_CELLTEMPERATURE_ID) |
kiran_mbed | 0:313541d8f8be | 142 | { |
kiran_mbed | 0:313541d8f8be | 143 | display.GotoXY(0,16); |
kiran_mbed | 0:313541d8f8be | 144 | display.PrintString(" mx cll T: "); |
kiran_mbed | 0:313541d8f8be | 145 | sprintf(dat,"%2.2f",rcv.FLOAT); |
kiran_mbed | 0:313541d8f8be | 146 | display.PrintString(dat); |
kiran_mbed | 0:313541d8f8be | 147 | } |
kiran_mbed | 0:313541d8f8be | 148 | if(Rxmsg.id == BATTERY_AVG_CELLTEMPERATURE_ID) |
kiran_mbed | 0:313541d8f8be | 149 | { |
kiran_mbed | 0:313541d8f8be | 150 | display.GotoXY(0,32); |
kiran_mbed | 0:313541d8f8be | 151 | display.PrintString(" avg cell T: "); |
kiran_mbed | 0:313541d8f8be | 152 | sprintf(dat,"%2.2f",rcv.FLOAT); |
kiran_mbed | 0:313541d8f8be | 153 | display.PrintString(dat); |
kiran_mbed | 0:313541d8f8be | 154 | } |
kiran_mbed | 0:313541d8f8be | 155 | |
kiran_mbed | 0:313541d8f8be | 156 | //Column 2 |
kiran_mbed | 0:313541d8f8be | 157 | if(Rxmsg.id == AMS_BATTERY_STATE) |
kiran_mbed | 0:313541d8f8be | 158 | { |
kiran_mbed | 0:313541d8f8be | 159 | if((rcv.C_FLOAT[0] & 0xC0) == 0xC0) |
kiran_mbed | 0:313541d8f8be | 160 | { |
kiran_mbed | 0:313541d8f8be | 161 | display.GotoXY(70,0); |
kiran_mbed | 0:313541d8f8be | 162 | display.PrintString(" AIRS: "); |
kiran_mbed | 0:313541d8f8be | 163 | display.PrintString("CLOS"); |
kiran_mbed | 0:313541d8f8be | 164 | } |
kiran_mbed | 0:313541d8f8be | 165 | else |
kiran_mbed | 0:313541d8f8be | 166 | { |
kiran_mbed | 0:313541d8f8be | 167 | display.GotoXY(70,0); |
kiran_mbed | 0:313541d8f8be | 168 | display.PrintString(" AIRS: "); |
kiran_mbed | 0:313541d8f8be | 169 | display.PrintString("OPEN"); |
kiran_mbed | 0:313541d8f8be | 170 | } |
kiran_mbed | 0:313541d8f8be | 171 | |
kiran_mbed | 0:313541d8f8be | 172 | if((rcv.C_FLOAT[0] & 0x04) == 0x04) |
kiran_mbed | 0:313541d8f8be | 173 | { |
kiran_mbed | 0:313541d8f8be | 174 | display.GotoXY(70,16); |
kiran_mbed | 0:313541d8f8be | 175 | display.PrintString(" Prchrg: "); |
kiran_mbed | 0:313541d8f8be | 176 | display.PrintString("on"); |
kiran_mbed | 0:313541d8f8be | 177 | } |
kiran_mbed | 0:313541d8f8be | 178 | else |
kiran_mbed | 0:313541d8f8be | 179 | { |
kiran_mbed | 0:313541d8f8be | 180 | display.GotoXY(70,16); |
kiran_mbed | 0:313541d8f8be | 181 | display.PrintString(" Prchrg: "); |
kiran_mbed | 0:313541d8f8be | 182 | display.PrintString("off"); |
kiran_mbed | 0:313541d8f8be | 183 | } |
kiran_mbed | 0:313541d8f8be | 184 | } |
kiran_mbed | 0:313541d8f8be | 185 | if(Rxmsg.id == AMS_BATTERY_STATE) |
kiran_mbed | 0:313541d8f8be | 186 | { |
kiran_mbed | 0:313541d8f8be | 187 | display.GotoXY(70,16); |
kiran_mbed | 0:313541d8f8be | 188 | display.PrintString(" Prchrg: "); |
kiran_mbed | 0:313541d8f8be | 189 | display.PrintString("off"); |
kiran_mbed | 0:313541d8f8be | 190 | } |
kiran_mbed | 0:313541d8f8be | 191 | } |
kiran_mbed | 0:313541d8f8be | 192 | screen=0; |
kiran_mbed | 0:313541d8f8be | 193 | } |
kiran_mbed | 0:313541d8f8be | 194 | return; |
kiran_mbed | 0:313541d8f8be | 195 | } |
kiran_mbed | 0:313541d8f8be | 196 | |
palimar | 6:99e754ac888f | 197 | void display_speed_data(void const *args) { |
palimar | 6:99e754ac888f | 198 | while (true) { |
palimar | 6:99e754ac888f | 199 | display.GotoXY(10,16); |
palimar | 6:99e754ac888f | 200 | display.SelectFont(Arial_14,BLACK,ReadData); |
palimar | 6:99e754ac888f | 201 | char buf[10]; |
palimar | 6:99e754ac888f | 202 | int a = rand()%100; |
palimar | 6:99e754ac888f | 203 | sprintf(buf, "%d", a); |
palimar | 6:99e754ac888f | 204 | display.PrintString("Speed: "); |
palimar | 6:99e754ac888f | 205 | display.PrintString(buf); |
palimar | 6:99e754ac888f | 206 | display.PrintString("mph"); |
palimar | 6:99e754ac888f | 207 | } |
palimar | 6:99e754ac888f | 208 | } |
palimar | 6:99e754ac888f | 209 | |
palimar | 6:99e754ac888f | 210 | |
palimar | 9:e946cafa3cae | 211 | void request_status_change() |
kiran_mbed | 0:313541d8f8be | 212 | { |
palimar | 13:1f05dcd9ae0e | 213 | |
palimar | 13:1f05dcd9ae0e | 214 | char drive_status_request = !drive_status; |
palimar | 13:1f05dcd9ae0e | 215 | char * status_string; |
palimar | 9:e946cafa3cae | 216 | |
palimar | 13:1f05dcd9ae0e | 217 | if(drive_status_request){ |
palimar | 13:1f05dcd9ae0e | 218 | status_string = "ON"; |
palimar | 13:1f05dcd9ae0e | 219 | } |
palimar | 13:1f05dcd9ae0e | 220 | else{ |
palimar | 13:1f05dcd9ae0e | 221 | status_string = "OFF"; |
palimar | 13:1f05dcd9ae0e | 222 | } |
palimar | 13:1f05dcd9ae0e | 223 | |
palimar | 13:1f05dcd9ae0e | 224 | for(int i = 0; i < 10; i++){ |
palimar | 16:d2953809fb31 | 225 | CAN_Steering_Buffer.txWrite(Txmsg_drive_status_request); |
palimar | 13:1f05dcd9ae0e | 226 | } |
palimar | 6:99e754ac888f | 227 | |
kiran_mbed | 0:313541d8f8be | 228 | display.ClearScreen(); |
kiran_mbed | 0:313541d8f8be | 229 | display.SelectFont(Arial12,BLACK,ReadData); |
kiran_mbed | 0:313541d8f8be | 230 | display.GotoXY(26,16); |
palimar | 21:56890c41ecf1 | 231 | display.PrintString("DRIVE STATUS REQUEST"); |
palimar | 9:e946cafa3cae | 232 | |
palimar | 21:56890c41ecf1 | 233 | printf("%s\n\r", status_string); |
kiran_mbed | 0:313541d8f8be | 234 | return; |
kiran_mbed | 0:313541d8f8be | 235 | } |
kiran_mbed | 0:313541d8f8be | 236 | |
palimar | 9:e946cafa3cae | 237 | void reset() |
kiran_mbed | 0:313541d8f8be | 238 | { |
palimar | 16:d2953809fb31 | 239 | CAN_Steering_Buffer.txWriteDirect(Txmsg_reset); |
palimar | 16:d2953809fb31 | 240 | mbed_reset(); |
kiran_mbed | 0:313541d8f8be | 241 | display.ClearScreen(); |
kiran_mbed | 0:313541d8f8be | 242 | display.SelectFont(Arial12,BLACK,ReadData); |
kiran_mbed | 0:313541d8f8be | 243 | display.GotoXY(16,16); |
kiran_mbed | 0:313541d8f8be | 244 | display.PrintString(" RESET INITIATED"); |
kiran_mbed | 0:313541d8f8be | 245 | printf("Reset Initiated\n\r"); |
kiran_mbed | 0:313541d8f8be | 246 | |
kiran_mbed | 0:313541d8f8be | 247 | return; |
kiran_mbed | 0:313541d8f8be | 248 | } |
kiran_mbed | 0:313541d8f8be | 249 | |
kiran_mbed | 0:313541d8f8be | 250 | void Powerstream() |
kiran_mbed | 0:313541d8f8be | 251 | { |
kiran_mbed | 0:313541d8f8be | 252 | CANMessage Rxmsg; |
kiran_mbed | 0:313541d8f8be | 253 | float power_ratio; |
kiran_mbed | 0:313541d8f8be | 254 | ftc rcv; |
kiran_mbed | 0:313541d8f8be | 255 | rcv.FLOAT=0.0; |
palimar | 16:d2953809fb31 | 256 | if(CAN_Steering_Buffer.rxRead(Rxmsg)) |
kiran_mbed | 0:313541d8f8be | 257 | { |
kiran_mbed | 0:313541d8f8be | 258 | if(Rxmsg.id == BATTERY_POWER_ID) |
kiran_mbed | 0:313541d8f8be | 259 | { |
palimar | 6:99e754ac888f | 260 | for(int i=0; i<4; i++){ |
kiran_mbed | 0:313541d8f8be | 261 | rcv.C_FLOAT[i]=Rxmsg.data[i]; |
palimar | 6:99e754ac888f | 262 | } |
kiran_mbed | 0:313541d8f8be | 263 | power_ratio=rcv.FLOAT/80000; |
kiran_mbed | 0:313541d8f8be | 264 | ledstream.write(power_ratio); |
kiran_mbed | 0:313541d8f8be | 265 | } |
kiran_mbed | 0:313541d8f8be | 266 | } |
kiran_mbed | 0:313541d8f8be | 267 | } |
kiran_mbed | 0:313541d8f8be | 268 | |
kiran_mbed | 0:313541d8f8be | 269 | void Init() |
kiran_mbed | 0:313541d8f8be | 270 | { |
kiran_mbed | 0:313541d8f8be | 271 | pc.baud(230400); |
palimar | 9:e946cafa3cae | 272 | drive_status = 0; |
palimar | 13:1f05dcd9ae0e | 273 | drive_status_request = 1; |
palimar | 9:e946cafa3cae | 274 | reset_body = 0; |
kiran_mbed | 0:313541d8f8be | 275 | ledstream.write(0); |
kiran_mbed | 0:313541d8f8be | 276 | call_ledstream.attach(&Powerstream,0.1); |
kiran_mbed | 0:313541d8f8be | 277 | } |
kiran_mbed | 0:313541d8f8be | 278 | |
palimar | 21:56890c41ecf1 | 279 | void update_vars(void const *args) { |
palimar | 21:56890c41ecf1 | 280 | while (true) { |
palimar | 21:56890c41ecf1 | 281 | CANMessage Rxmsg; |
palimar | 21:56890c41ecf1 | 282 | if(CAN_Steering_Buffer.rxRead(Rxmsg)){ |
palimar | 21:56890c41ecf1 | 283 | if(Rxmsg.id == PCM_STATE_ID){ |
palimar | 21:56890c41ecf1 | 284 | ds_mutex.lock(); |
palimar | 21:56890c41ecf1 | 285 | drive_status = Rxmsg.data[0]; |
palimar | 21:56890c41ecf1 | 286 | ds_mutex.unlock(); |
palimar | 21:56890c41ecf1 | 287 | } |
palimar | 21:56890c41ecf1 | 288 | } |
palimar | 21:56890c41ecf1 | 289 | } |
palimar | 21:56890c41ecf1 | 290 | } |
palimar | 21:56890c41ecf1 | 291 | |
kiran_mbed | 0:313541d8f8be | 292 | int main() |
kiran_mbed | 0:313541d8f8be | 293 | { |
palimar | 4:a4fb060e7840 | 294 | // Init all |
kiran_mbed | 0:313541d8f8be | 295 | Init(); |
kiran_mbed | 0:313541d8f8be | 296 | wait(0.1); |
palimar | 4:a4fb060e7840 | 297 | |
palimar | 4:a4fb060e7840 | 298 | //Init Display |
kiran_mbed | 0:313541d8f8be | 299 | display.GotoXY(10,16); |
kiran_mbed | 0:313541d8f8be | 300 | display.SelectFont(Arial_14,BLACK,ReadData); |
kiran_mbed | 0:313541d8f8be | 301 | display.PrintString("Penn Electric Racing"); |
palimar | 6:99e754ac888f | 302 | |
palimar | 21:56890c41ecf1 | 303 | Thread update_thread(update_vars); |
palimar | 21:56890c41ecf1 | 304 | |
palimar | 6:99e754ac888f | 305 | wait(1); |
palimar | 4:a4fb060e7840 | 306 | |
palimar | 4:a4fb060e7840 | 307 | // Start to read buttons on main thread |
kiran_mbed | 0:313541d8f8be | 308 | |
kiran_mbed | 0:313541d8f8be | 309 | while(1) |
kiran_mbed | 0:313541d8f8be | 310 | { |
kiran_mbed | 0:313541d8f8be | 311 | if(biSWBL.read()) |
kiran_mbed | 0:313541d8f8be | 312 | { |
palimar | 9:e946cafa3cae | 313 | request_status_change(); |
kiran_mbed | 0:313541d8f8be | 314 | } |
kiran_mbed | 0:313541d8f8be | 315 | if(biSWBR.read()) |
kiran_mbed | 0:313541d8f8be | 316 | { |
palimar | 9:e946cafa3cae | 317 | reset(); |
kiran_mbed | 0:313541d8f8be | 318 | } |
palimar | 9:e946cafa3cae | 319 | |
kiran_mbed | 0:313541d8f8be | 320 | } |
kiran_mbed | 0:313541d8f8be | 321 | } |