tortuga DataLogging Library: battery, speed, time, average...

Dependents:   TORTUGA_BLE

Fork of DataLogging by aapje monkey

Revision:
1:6e25c2b5c20c
Parent:
0:ec76b22829d5
Child:
2:f3c2bf5521e5
--- a/Data.cpp	Sat Apr 16 14:55:37 2016 +0000
+++ b/Data.cpp	Fri Apr 29 15:51:04 2016 +0000
@@ -1,10 +1,16 @@
 #include "mbed.h"
 #include "Data.h"
-#define Period 1 //5000ms
-#define PPR 1
+//#include "eeprom.h"
+
+#define Period 1 //1000ms
+#define PPR 1    // Pulses Per Rotation
 #define periphery 2.233168 //periphery of the wheel, in this example a 28" wheel.
 
+/*#define EEPROM_ADDR 0x0   // I2c EEPROM address is 0x00
+#define SDA PB_9            // I2C SDA pin
+#define SCL PB_8           // I2C SCL pin
 
+EEPROM mem(SDA,SCL,EEPROM_ADDR,EEPROM::T24C32);*/
 
 int count;
 time_t StartTime;
@@ -12,14 +18,15 @@
 double lastDistance;
 int lastCount;
 
-void interval(void){
+void Data::interval(void){
     lastDistance = count * periphery / PPR;
     distance += lastDistance;
     lastCount = count;
     count = 0;
+    printf("distance: %f \r\nTime Passed: %i:%i\nAverage: %f\nSpeed: %f\n\n",distance, (time(NULL) - StartTime)/60, (time(NULL) - StartTime)%60, (distance/(time(NULL) - StartTime) * 3.6),(lastDistance/Period * 3.6));
     }
     
-void pressed(void){
+void Data::pressed(){
     count++;
 }
     
@@ -27,8 +34,8 @@
     StartTime = time(NULL);
     count = 0;
     distance = 0;
-    tick.attach(interval,Period);
-    button.fall(pressed);
+    tick.attach(this,&Data::interval,Period);
+    button.fall(this,&Data::pressed);
     }
     
 double Data::getDistance(void){