a fork of priustroller

Dependencies:   mbed

Fork of priustroller_current by N K

Revision:
54:e8d9bc885723
Parent:
33:e7b132029bae
--- a/sensors/sensors.h	Sat May 02 00:21:00 2015 +0000
+++ b/sensors/sensors.h	Tue May 19 08:50:42 2015 +0000
@@ -2,6 +2,7 @@
 #define __SENSORS_H
 
 #include "includes.h"
+#include "filters.h"
 
 class CurrentSensor {
 public:
@@ -18,6 +19,7 @@
 class PositionSensor {
 public:
     virtual float GetPosition() {return 0.0f;}
+    virtual float GetSpeed() {return 0.0f;}
 };
 
 class TempSensor {
@@ -50,11 +52,17 @@
     AnalogHallPositionSensor(PinName pin_a, PinName pin_b, float cal1_a, float cal2_a, 
                              float cal1_b, float cal2_b, float offset);
     virtual float GetPosition();
+    virtual float GetSpeed() {return _speed * 1000000.0f / 360.0f;}
 private:
+    void upd_function() {_time += 50;}
     float _cal1_a, _cal2_a;
     float _cal1_b, _cal2_b;
     float _offset;
     AnalogIn *_in_a, *_in_b;
+private:
+    Ticker *_time_upd_ticker;
+    unsigned long _time;
+    float _last_time, _last_position, _speed;
 };
 
 class NtcTempSensor: public TempSensor {