The Code Repository for the REV0 Steering Wheel.

Dependencies:   CANBuffer KS0108_fork mbed-rtos mbed CAN Addresses

Fork of REVO_Updated_Steering by Penn Electric

Revision:
36:8544a8900884
Parent:
35:b42afc973902
Child:
38:d04a430d7fe3
diff -r b42afc973902 -r 8544a8900884 Steering.h
--- a/Steering.h	Sat Nov 22 22:24:53 2014 +0000
+++ b/Steering.h	Thu Jan 29 04:27:19 2015 +0000
@@ -2,154 +2,49 @@
 #define _STEERING_H
 
 #include "mbed.h"
+#include <math.h>
 #include "rtos.h"
 #include "KS0108.h"
-
-#include "Arial10.h"
-#include "Arial12.h"
 #include "Arial14.h"
-#include "Comic24.h"
-#include "vivaldi16.h"
 #include "CANBuffer.h"
-#include "variables.h"
-
+#include "CAN_Address.h"
+#include "Screens.h"
 
-#include "LPCDigitalIn.h"
+#define GetFloat  *(float*)((void*)(&Rxmsg.data[0]))
+#define GetFloat4 *(float*)((void*)(&Rxmsg.data[4]))
 
-#define SWITCH_ID 410
+#define BLButtonGreen   DigitalOut l3(P1_24,1);  DigitalOut l4(P0_24,0);  // SW6,  SW8  respectively
+#define BLButtonRed     DigitalOut l3(P1_24,0);  DigitalOut l4(P0_24,1);
 
-#define BATTERY_VOLTAGE_ID 0x304
-#define BATTERY_POWER_ID 0x306
-#define BATTERY_CURRENT_ID 0x305
+#define BRButtonGreen   DigitalOut l1(P1_28,1);  DigitalOut l2(P1_26,0);  // SW2,  SW4  respectively
+#define BRButtonRed     DigitalOut l1(P1_28,0);  DigitalOut l2(P1_26,1);
 
-#define PCM_STATE_ID 0x201
-
-#define BATTERY_MIN_CELLVOLTAGE_ID 0x301
-#define BATTERY_MAX_CELLVOLTAGE_ID 0x300
-#define BATTERY_AVG_CELLVOLTAGE_ID 0x302
+#define TLButtonGreen   DigitalOut u3(P1_4,0);   DigitalOut u4(P1_0,1);   // SW13, SW15 respectively
+#define TLButtonRed     DigitalOut u3(P1_4,1);   DigitalOut u4(P1_0,0);
 
-#define BATTERY_MIN_CELLTEMPERATURE_ID 0x30A
-#define BATTERY_MAX_CELLTEMPERATURE_ID 0x309
-#define BATTERY_AVG_CELLTEMPERATURE_ID 0x30B
-#define AMS_BATTERY_STATE 0x30E          // AIRS 7 and 6 // Precharge 3
+#define TRButtonGreen   DigitalOut u1(P1_14,0);  DigitalOut u2(P1_9,1);   // SW9,  SW11 respectively
+#define TRButtonRed     DigitalOut u1(P1_14,1);  DigitalOut u2(P1_9,0);
 
-#define NUM_SCREEN 2
-
-#define HOME_SCREEN 0
-#define BATTERY_SCREEN 1
+float pi =                  3.14159;
+float WheelRadius =         5/6;              // In feet; same as 10 inches
+float WheelCircumference =  2*pi*WheelRadius; //In feet     
 
 Serial pc(USBTX,USBRX);
-CANBuffer CAN_Steering_Buffer(CAN1, MEDIUM, p3_26);
 
-
-KS0108 display(p26, p21, p22, p23, p25, p24, p8, p7, p6, p5, p13, p14, p12, p11); 
-//Ticker call_ledstream;
-
-LPCDigitalOut l1(p1_28,1);//    SW2
-LPCDigitalOut l2(p1_26,1);//    SW4
-    
-LPCDigitalOut l3(p1_24,1);//    SW6
-LPCDigitalOut l4(p0_24,1);//    SW8
-
-LPCDigitalOut u1(p1_14,0);//    SW9 
-LPCDigitalOut u2(p1_9,0);//     SW11
-
-LPCDigitalOut u3(p1_4,0);//     SW13
-LPCDigitalOut u4(p1_0,0);//     SW15
-
-AnalogOut ledstream(p18);
-
-//SW1 - SW3
-LPCDigitalOut boSW1(p1_29,1);
-LPCDigitalIn biSWBR(p1_27, PullDown);     //BRight
+CANBuffer SteeringCANPort(CAN1, MEDIUM, P3_26);    // Initialize the CAN port/pin
 
-LPCDigitalOut boSW5(p1_25,1);
-LPCDigitalIn biSWBL(p1_22, PullDown);     //BLeft
-
-LPCDigitalOut boSW10(p1_10,1);
-LPCDigitalIn biSWTR(p1_8, PullDown);     //TRight
-
-LPCDigitalOut boSW14(p1_1,1);
-LPCDigitalIn biSWTL(p0_25, PullDown);    //TLeft
-
-typedef union convert{
-        float FLOAT;
-        char C_FLOAT[4];
-        }ftc;
+AnalogOut ledstream(p18);  // This appears to iniialize the pin as an analog out, and probably defaults to low.  Without this, the LED bar would have a few lights on.
 
-char SwitchName[15][13]={
-    "fuse",
-    "ams",
-    "imd",
-    "pcm",
-    "brkp",
-    "lft",
-    "intl",
-    "brko",
-    "ckpt",
-    "rgt",
-    "hvd",
-    "tsms"
-};
+DigitalOut boSW1(P1_29,1);//            SW1   
+DigitalIn biSWBR(P1_27, PullDown);//    SW3,  BRight
 
-int SwitchPosition[13][2]={
-    {0,16},     //fuse
-    {25,16},    //ams
-    {50,16},    //imd
-    {70,16},    //pcm
-    {93,16},    //brkp
-    {117,16},   //lft
-    {0,32},     //intl
-    {17,32},    //brko
-    {42,32},    //ckpt
-    {65,32},    //rgt
-    {81,32},    //hvd
-    {102,32},   //tsm
-    };
-    
-int curr_screen;
-int screen_flags[NUM_SCREEN]; 
-bool should_redraw;
-
-char drive_status;
-char drive_status_request;
-char reset_body;
-
-node * id_node = NULL;
-variables * vars_list;
-
-
-Mutex ds_mutex;
+DigitalOut boSW5(P1_25,1);//            SW5
+DigitalIn biSWBL(P1_22, PullDown);//    SW7,  BLeft
 
-/*
-void read_messages(void const *args) {
-    
-    while (true) {
-        CANMessage Rxmsg;
-     
-        if(CAN_Steering_Buffer.rxRead(Rxmsg))
-            if(Rxmsg.id == PCM_STATE_ID){
-              
-                // Mutex to protex shared variables
-                ds_mutex.lock();
-                drive_status = Rxmsg.data[0];
-                ds_mutex.unlock();
-            }
-            
-            if(Rxmsg.id == BATTERY_POWER_ID)
-            {
-                float power_ratio;
-                ftc rcv;
-                rcv.FLOAT=0.0;
-                
-                for(int i=0; i<4; i++){
-                    rcv.C_FLOAT[i] = Rxmsg.data[i];
-                }
-                power_ratio=rcv.FLOAT/80000;
-                ledstream.write(power_ratio);
-            }
-        }
-    }
-*/
+DigitalOut boSW10(P1_10,1);//           SW10
+DigitalIn biSWTR(P1_8, PullDown);//     SW12, TRight
 
-#endif /* STEERING_H */    
\ No newline at end of file
+DigitalOut boSW14(P1_1,1);//            SW14
+DigitalIn biSWTL(P0_25, PullDown);//    SW16, TLeft
+
+#endif //_STEERING_H
\ No newline at end of file