Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: CANBuffer KS0108_fork mbed-rtos mbed CAN Addresses
Fork of REVO_Updated_Steering by
Revision 21:56890c41ecf1, committed 2014-10-25
- Comitter:
- palimar
- Date:
- Sat Oct 25 17:24:58 2014 +0000
- Parent:
- 20:c3f4828f3cbc
- Child:
- 22:ab33195882e3
- Child:
- 23:6681a38918c6
- Commit message:
- Added new thread to update drive status variable
Changed in this revision
| Steering.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Steering.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Steering.cpp Sat Oct 25 16:53:34 2014 +0000
+++ b/Steering.cpp Sat Oct 25 17:24:58 2014 +0000
@@ -2,7 +2,7 @@
void HomeScreen()
{
- CANMessage Rxmsg;
+
ftc rcv;
rcv.FLOAT=0.0;
char dat[4];
@@ -14,6 +14,7 @@
display.PrintString(" HOME SCREEN");
while( !(biSWTL.read() || biSWTR.read() || biSWBR.read()) )
{
+ CANMessage Rxmsg;
if(CAN_Steering_Buffer.rxRead(Rxmsg))
{
for(int i=0; i<4; i++)
@@ -227,11 +228,9 @@
display.ClearScreen();
display.SelectFont(Arial12,BLACK,ReadData);
display.GotoXY(26,16);
- display.PrintString("REQUEST SENT TO CHANGE\n\r DRIVE STATUS TO: \n\r");
- display.PrintString(status_string);
- display.PrintString(".\n\r");
+ display.PrintString("DRIVE STATUS REQUEST");
- printf(status_string);
+ printf("%s\n\r", status_string);
return;
}
@@ -277,6 +276,19 @@
call_ledstream.attach(&Powerstream,0.1);
}
+void update_vars(void const *args) {
+ while (true) {
+ CANMessage Rxmsg;
+ if(CAN_Steering_Buffer.rxRead(Rxmsg)){
+ if(Rxmsg.id == PCM_STATE_ID){
+ ds_mutex.lock();
+ drive_status = Rxmsg.data[0];
+ ds_mutex.unlock();
+ }
+ }
+ }
+}
+
int main()
{
// Init all
@@ -288,6 +300,8 @@
display.SelectFont(Arial_14,BLACK,ReadData);
display.PrintString("Penn Electric Racing");
+ Thread update_thread(update_vars);
+
wait(1);
// Start to read buttons on main thread
--- a/Steering.h Sat Oct 25 16:53:34 2014 +0000 +++ b/Steering.h Sat Oct 25 17:24:58 2014 +0000 @@ -19,7 +19,7 @@ #define BATTERY_POWER_ID 0x306 #define BATTERY_CURRENT_ID 0x305 -#define PCM_STATE_ID 20 +#define PCM_STATE_ID 0x201 #define BATTERY_MIN_CELLVOLTAGE_ID 0x301 #define BATTERY_MAX_CELLVOLTAGE_ID 0x300 @@ -111,4 +111,6 @@ CANMessage Txmsg_drive_status_request(0x501,&drive_status_request,1); CANMessage Txmsg_reset(0x502,&reset_body,1); +Mutex ds_mutex; + #endif /* STEERING_H */ \ No newline at end of file
