embedded software for tortuga bike

Dependencies:   BLE_API BikeControl DataLogging X_NUCLEO_IDB0XA1 _24LCXXX mbed

Revision:
2:7eb0bb74a8b6
Parent:
1:ffdec767aa55
--- a/main.cpp	Mon Jul 18 09:33:08 2016 +0000
+++ b/main.cpp	Mon Jul 18 13:20:25 2016 +0000
@@ -1,6 +1,7 @@
 #include "mbed.h"
 #include "BikeData.h"
 #include "BatteryState.h"
+#include "BikeControl.h"
 #include "ble/BLE.h"
 #include "ble/services/BikeService.h"
 #include "ble/services/BikeBatteryService.h"
@@ -13,14 +14,16 @@
                                 VARIABLES
 ****************************************************************************/
 
-
+/*
 //LIGHT
 DigitalOut lightFront(PB_14);
 DigitalOut lightBack(PA_11);
 DigitalOut lightLeft(PC_6);
-DigitalOut lightRight(PC_8);
+DigitalOut lightRight(PC_8);*/
 
 
+static BikeControl *bc;
+
 
 //3 battery states
 static BatteryState *trailerBattery;
@@ -28,7 +31,7 @@
 static BatteryState *auxiliaryBattery;
 
 //BLE VARIABLES
-static char     DEVICE_NAME[] = "TORTUGA";  //Define default name of the BLE device
+static char     DEVICE_NAME[] = "NAME";  //Define default name of the BLE device
 static const uint16_t uuid16_list[] = {BikeService::BIKE_SERVICE_UUID, 
                                         //GattService::UUID_DEVICE_INFORMATION_SERVICE,
                                         BatteryService::BATTERY_SERVICE_UUID,
@@ -47,7 +50,7 @@
 /***************************************************************************
                                 CONTROL FUNCTIONS
 ****************************************************************************/
-void runTestLight()
+/*void runTestLight()
 {
     printf("front\n");
     lightFront =1;
@@ -66,7 +69,7 @@
     wait(1);
     lightRight = 0;
     wait(1);
-}
+}*/
 
 /***************************************************************************
                                 BLE FUNCTIONS
@@ -151,9 +154,12 @@
     bikeBattery = new BatteryState(bikeBatteryPin,BatteryState::Battery48V);
     auxiliaryBattery = new BatteryState(auxiliaryBatteryPin,BatteryState::Battery48V);
     
+    bc = new BikeControl(bd,trailerBattery, bikeBattery, auxiliaryBattery);
+    
     
     printf("run TestLight \n");
-    runTestLight();
+    //runTestLight();
+    bc->runTestLight();
     
     uint8_t size = bd->getBikeNameSize();
     printf("name length: %i\n", size);
@@ -181,6 +187,8 @@
     printf("START \n");
     
     
+    bc->startControlLoop();
+    
     while(true)
      {
          if (update){
@@ -203,7 +211,7 @@
             update = false;
         }
         ble.waitForEvent(); //wait for an event when idle.
-            
-            
+        
+        bc->checkStatus();            
     }
 }