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:
- 7:df257df56363
- Parent:
- 5:05f8a36b5cdd
- Parent:
- 6:99e754ac888f
- Child:
- 9:e946cafa3cae
diff -r 05f8a36b5cdd -r df257df56363 Steering.cpp --- a/Steering.cpp Sat Oct 04 17:55:27 2014 +0000 +++ b/Steering.cpp Sat Oct 04 17:57:44 2014 +0000 @@ -194,11 +194,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); @@ -218,7 +232,6 @@ display.GotoXY(16,16); display.PrintString(" RESET INITIATED"); printf("Reset Initiated\n\r"); - //screen=0; return; } @@ -233,8 +246,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); } @@ -245,8 +259,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); } @@ -261,6 +276,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;