app critics will say it's money, cash, toes

Revision:
13:99ed8a3db67a
Parent:
12:3934b9d6d5a3
Child:
14:aa0029dbb3e2
--- a/source/main.cpp	Thu Nov 08 11:58:40 2018 +0000
+++ b/source/main.cpp	Mon Nov 12 16:27:10 2018 +0000
@@ -34,12 +34,9 @@
 short hrmCounter = 0;
 double step_threshold = 14.45;
 
-//long step_delay = 330;
-long step_delay = 5 * 3.3; // clock() increments by 5 for each millisecond ellapsed
-
 double oldAcceleration = 0.0;
-long lastStepTime = 0;
-long timeCurrent;
+int callback_cycles = 4;
+int step;
 
 static HeartRateService* hrService;
 MPU9250 mpu = MPU9250(P0_26, P0_27);
@@ -52,6 +49,9 @@
 }
 
 void updateSensorValue() {
+    step = 0;
+    callback_cycles++;
+    
     mpu.readAccelData(destination);
     
     double acc_x = destination[0] / 1000.0;
@@ -63,23 +63,14 @@
     double sqr_acc_z = acc_z*acc_z;
     
     double sum_acc = sqr_acc_x + sqr_acc_y + sqr_acc_z;
-
     double accel = sqrt(sum_acc);
-    
-    int step = 0;
 
-    timeCurrent = (unsigned long) clock();
-    
-            
-    printf("timeCurrent: " );
-    printf("%ld\n", timeCurrent);  
-        
-    printf("lastStepTime: " );
-    printf("%ld\n", lastStepTime);  
+    printf("calback cycles: " );
+    printf("%i\n", callback_cycles);  
      
-    if (accel < step_threshold && oldAcceleration >= step_threshold && (timeCurrent - lastStepTime > step_delay)) {
+    if (accel < step_threshold && oldAcceleration >= step_threshold && (callback_cycles > 4)) {
         step = 1;
-        lastStepTime = timeCurrent;
+        callback_cycles = 0;
     }
     
     oldAcceleration = accel;
@@ -167,7 +158,7 @@
 {    
     mpu.initMPU9250();
     
-    eventQueue.call_every(100, blinkCallback);
+    eventQueue.call_every(80, blinkCallback);
 
     BLE &ble = BLE::Instance();
     ble.onEventsToProcess(scheduleBleEventsProcessing);