The Code Repository for the REV0 Steering Wheel.
Dependencies: CANBuffer KS0108_fork mbed-rtos mbed CAN Addresses
Fork of REVO_Updated_Steering by
Diff: Steering.cpp
- Revision:
- 6:99e754ac888f
- Parent:
- 4:a4fb060e7840
- Child:
- 7:df257df56363
diff -r a4fb060e7840 -r 99e754ac888f Steering.cpp --- a/Steering.cpp Sat Oct 04 17:35:15 2014 +0000 +++ b/Steering.cpp Sat Oct 04 17:56:28 2014 +0000 @@ -193,11 +193,25 @@ return; } +void display_speed_data(void const *args) { + while (true) { + display.GotoXY(10,16); + display.SelectFont(Arial_14,BLACK,ReadData); + char buf[10]; + int a = rand()%100; + sprintf(buf, "%d", a); + display.PrintString("Speed: "); + display.PrintString(buf); + display.PrintString("mph"); + } +} + + void ON() { Txmsg_Drive.data[0]|=(1<<0); wait(0.1); - + display.ClearScreen(); display.SelectFont(Arial12,BLACK,ReadData); display.GotoXY(26,16); @@ -217,7 +231,6 @@ display.GotoXY(16,16); display.PrintString(" RESET INITIATED"); printf("Reset Initiated\n\r"); - //screen=0; return; } @@ -232,8 +245,9 @@ { if(Rxmsg.id == BATTERY_POWER_ID) { - for(int i=0; i<4; i++) + for(int i=0; i<4; i++){ rcv.C_FLOAT[i]=Rxmsg.data[i]; + } power_ratio=rcv.FLOAT/80000; ledstream.write(power_ratio); } @@ -244,8 +258,9 @@ { pc.baud(230400); CAN_Steering.frequency(500000); - for(int i = 0; i<4; i++) + for(int i = 0; i<4; i++){ drive[i] = (0x00); + } ledstream.write(0); call_ledstream.attach(&Powerstream,0.1); } @@ -260,6 +275,10 @@ display.GotoXY(10,16); display.SelectFont(Arial_14,BLACK,ReadData); display.PrintString("Penn Electric Racing"); + + wait(1); + + Thread thread(display_speed_data); // Start to read buttons on main thread screen=0;