new battery bar

Dependencies:   CAN_IDs CanControl Dashboard PinDetect PowerControl mbed-rtos mbed

Revision:
15:56b25cffa523
Parent:
14:0ad1bc8be76b
Child:
16:c5427db9edf0
--- a/main.cpp	Mon May 22 15:16:34 2017 +0000
+++ b/main.cpp	Mon May 22 17:21:08 2017 +0000
@@ -26,7 +26,7 @@
 #include "CAN_IDs.h"
 #include "PowerControl.h"
 
-#define SPEED_THRESH 0.05
+#define SPEED_THRESH 0.02 //threshold for setting speed to prevent CAN spam
 
 // initialize serial connection for debug
 #ifdef DEBUG
@@ -45,7 +45,6 @@
 DigitalOut ledFona(LED5);
 DigitalOut led24V(LED4);
 
-//DigitalOut buckCan(BUCK2);
 DigitalOut buckXSens(BUCK3);
 DigitalOut buckScreen(BUCK4);
 DigitalOut buck24V(BUCK5);
@@ -73,11 +72,10 @@
     buckXSens = 0;
     buckScreen = 0;
     buck24V = 1;
-    
 }
 
+//global var for speed; ugly solution but works
 float speed = 0;
-
 //send motor command
 void sendMotorSpeed(float throttle) {
     if ((abs(throttle - speed)) > SPEED_THRESH) {
@@ -96,9 +94,9 @@
 void readThrottle() {
     float throttleread;
     while(1) {
-        throttleread = floor(2*(0.5 - analogThrottle.read())*1000)/1000;
+        throttleread = 2*(0.5 - analogThrottle.read());
         sendMotorSpeed(throttleread);
-        Thread::wait(100);   
+        Thread::wait(10);   
     }
 }  
 
@@ -112,22 +110,13 @@
     can.frequency(250000);
     
     // initialze threads
-    Thread thread1;
-    //Thread thread2;
-    //Thread thread3;
-    //Thread thread4;
-    Thread threadx;
+    Thread threadpower;
+    Thread threadtest;
     Thread threadthrottle;
     
-    // change thread priority
-    //thread2.set_priority(osPriorityBelowNormal);
-    
     // start threads
-    thread1.start(&power);
-    //thread2.start(&calcPi);
-    //thread3.start(&motorTest);
-    //thread4.start(&canReceive);
-    threadx.start(&test);
+    threadpower.start(&power);
+    threadtest.start(&test);
     threadthrottle.start(&readThrottle);
     
     //stop this thread while keeping the other threads running