new battery bar

Dependencies:   CAN_IDs CanControl Dashboard PinDetect PowerControl mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
zathorix
Date:
Mon May 22 18:12:08 2017 +0000
Parent:
15:56b25cffa523
Child:
17:91ba27c14991
Commit message:
Deprecated bms reader in main, implemented data acquisition

Changed in this revision

CAN_IDs.lib Show annotated file Show diff for this revision Revisions of this file
Dashboard.lib Show annotated file Show diff for this revision Revisions of this file
TelemetryAndDaq.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
pinout.h Show annotated file Show diff for this revision Revisions of this file
--- a/CAN_IDs.lib	Mon May 22 17:21:08 2017 +0000
+++ b/CAN_IDs.lib	Mon May 22 18:12:08 2017 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/Solarboat-Twente/code/CAN_IDs/#776e57f7ca89
+http://developer.mbed.org/teams/Solarboat-Twente/code/CAN_IDs/#cbf2bd8271f9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Dashboard.lib	Mon May 22 18:12:08 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/zathorix/code/Dashboard/#1627da2ca15b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TelemetryAndDaq.lib	Mon May 22 18:12:08 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/zathorix/code/TelemetryAndDaq/#16ab44ec2454
--- a/main.cpp	Mon May 22 17:21:08 2017 +0000
+++ b/main.cpp	Mon May 22 18:12:08 2017 +0000
@@ -25,6 +25,8 @@
 #include "pinout.h"
 #include "CAN_IDs.h"
 #include "PowerControl.h"
+#include "TelemetryAndDaq.h"
+#include "Dashboard.h"
 
 #define SPEED_THRESH 0.02 //threshold for setting speed to prevent CAN spam
 
@@ -49,56 +51,23 @@
 DigitalOut buckScreen(BUCK4);
 DigitalOut buck24V(BUCK5);
 
-
-// Thread 1 - Power
-void power(){
-    PowerControl powercontrol(PUSH_GREEN); 
-    
-#ifdef DEBUG
-    pc.printf("Thread 1 - Power started\r\n ");
-#endif
-
-    Thread::wait(osWaitForever);
-}
+//external classes
+extern DataAcquisition daq;
 
-// Thread X - Test
-void test(){
-    ledError = 0;
-    ledSD = 0;
-    ledFona = 0 ;
-    led24V=1;
+//external variables
+extern long long int starttime;
 
-//DigitalOut buckCan(BUCK2);
-    buckXSens = 0;
-    buckScreen = 0;
-    buck24V = 1;
-}
+//external threads
+extern Thread threadbg;
 
 //global var for speed; ugly solution but works
 float speed = 0;
-//send motor command
-void sendMotorSpeed(float throttle) {
-    if ((abs(throttle - speed)) > SPEED_THRESH) {
-        union {
-            char msg[4];
-            float value;
-        } packet;
-        packet.value = throttle;
-        can.write(CANMessage(MOTOR_COMMAND, packet.msg));
-        printf("Sent motor speed: %f\r\n", packet.value);
-        speed = throttle;
-    }
-}
 
-//throttle thread
-void readThrottle() {
-    float throttleread;
-    while(1) {
-        throttleread = 2*(0.5 - analogThrottle.read());
-        sendMotorSpeed(throttleread);
-        Thread::wait(10);   
-    }
-}  
+//thread function declarations
+void readThrottle();
+void power();
+void test();
+void background();
 
 // Thread 0 - DO NOT CHANGE THIS!
 int main() {  
@@ -116,15 +85,67 @@
     
     // start threads
     threadpower.start(&power);
+    threadbg.start(&background);
     threadtest.start(&test);
     threadthrottle.start(&readThrottle);
     
-    //stop this thread while keeping the other threads running
-    CANMessage msg;
+    daq.enable(starttime);
+    
+    //BMS message parser, now imlpemented in DAQ lib
+    /*CANMessage msg;
     while(1) {
         if(can.read(msg)) {
             pc.printf("Message received: 0x %x; %u %u%u %d%d %c %u %u\n", msg.id, msg.data[0], msg.data[1], msg.data[2], msg.data[3], msg.data[4], msg.data[5], msg.data[6], msg.data[7]);
-        } 
+        }
+        Thread::wait(10); 
+    }*/
+    Thread::wait(osWaitForever);
+}
+
+//send motor command
+void sendMotorSpeed(float throttle) {
+    if ((abs(throttle - speed)) > SPEED_THRESH) {
+        union {
+            char msg[4];
+            float value;
+        } packet;
+        packet.value = throttle;
+        can.write(CANMessage(MOTOR_COMMAND, packet.msg));
+        printf("Sent motor speed: %f\r\n", packet.value);
+        speed = throttle;
     }
+}
+
+//thread functions
+void readThrottle() {
+    float throttleread;
+    while(1) {
+        throttleread = 2*(0.5 - analogThrottle.read());
+        sendMotorSpeed(throttleread);
+        Thread::wait(10);   
+    }
+}  
+
+
+
+void power() {
+    PowerControl powercontrol(PUSH_GREEN); 
+    
+#ifdef DEBUG
+    pc.printf("Thread 1 - Power started\r\n ");
+#endif
+
     Thread::wait(osWaitForever);
-}
\ No newline at end of file
+}
+
+void test() {
+    ledError = 0;
+    ledSD = 0;
+    ledFona = 0 ;
+    led24V=1;
+
+//DigitalOut buckCan(BUCK2);
+    buckXSens = 0;
+    buckScreen = 0;
+    buck24V = 1;
+}
--- a/pinout.h	Mon May 22 17:21:08 2017 +0000
+++ b/pinout.h	Mon May 22 18:12:08 2017 +0000
@@ -68,7 +68,7 @@
 #define FONA_TX         PA_1
 
 #define FONA_RTS        PH_0
-#define FONA_RI         
+#define FONA_RI         PH_1
 #define FONA_NS         PH_1
 #define FONA_PS         PA_4
 #define FONA_KEY        PB_7