a

Dependencies:   mbed mbed-rtos

Committer:
alexpirciu
Date:
Thu Mar 28 07:44:42 2019 +0000
Revision:
1:ceee5a608e7c
assa

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alexpirciu 1:ceee5a608e7c 1 #ifndef DRIVER_TASK_H
alexpirciu 1:ceee5a608e7c 2 #define DRIVER_TASK_H
alexpirciu 1:ceee5a608e7c 3
alexpirciu 1:ceee5a608e7c 4 #include <TaskManager.h>
alexpirciu 1:ceee5a608e7c 5 #include <DistanceDriver.h>
alexpirciu 1:ceee5a608e7c 6 #include <filter.h>
alexpirciu 1:ceee5a608e7c 7
alexpirciu 1:ceee5a608e7c 8
alexpirciu 1:ceee5a608e7c 9
alexpirciu 1:ceee5a608e7c 10
alexpirciu 1:ceee5a608e7c 11 template<class T>
alexpirciu 1:ceee5a608e7c 12 class CDriverTask: public task::CTask
alexpirciu 1:ceee5a608e7c 13 {
alexpirciu 1:ceee5a608e7c 14 public:
alexpirciu 1:ceee5a608e7c 15 using FilterFunc=filter::CFilterFunction<T>;
alexpirciu 1:ceee5a608e7c 16 CDriverTask( uint32_t f_period
alexpirciu 1:ceee5a608e7c 17 ,PinName f_pin
alexpirciu 1:ceee5a608e7c 18 ,FilterFunc& f_filter
alexpirciu 1:ceee5a608e7c 19 ,Serial& f_serial)
alexpirciu 1:ceee5a608e7c 20 :CTask(f_period)
alexpirciu 1:ceee5a608e7c 21 ,m_filter(f_filter)
alexpirciu 1:ceee5a608e7c 22 ,m_distanceDriver(f_pin)
alexpirciu 1:ceee5a608e7c 23 ,m_val_brut(0.0)
alexpirciu 1:ceee5a608e7c 24 ,m_val_filtrat(0.0)
alexpirciu 1:ceee5a608e7c 25 ,m_serial(f_serial)
alexpirciu 1:ceee5a608e7c 26 ,idx(0)
alexpirciu 1:ceee5a608e7c 27 {
alexpirciu 1:ceee5a608e7c 28 }
alexpirciu 1:ceee5a608e7c 29
alexpirciu 1:ceee5a608e7c 30 T getDistanceFiltered(){
alexpirciu 1:ceee5a608e7c 31 return m_val_filtrat;
alexpirciu 1:ceee5a608e7c 32 }
alexpirciu 1:ceee5a608e7c 33
alexpirciu 1:ceee5a608e7c 34 T getDistanceMeasured(){
alexpirciu 1:ceee5a608e7c 35 return m_val_brut;
alexpirciu 1:ceee5a608e7c 36 }
alexpirciu 1:ceee5a608e7c 37
alexpirciu 1:ceee5a608e7c 38
alexpirciu 1:ceee5a608e7c 39
alexpirciu 1:ceee5a608e7c 40 private:
alexpirciu 1:ceee5a608e7c 41 virtual void _run(){
alexpirciu 1:ceee5a608e7c 42 m_val_brut=m_distanceDriver.ReadDistance();
alexpirciu 1:ceee5a608e7c 43 m_val_filtrat=m_filter(m_val_brut);
alexpirciu 1:ceee5a608e7c 44 }
alexpirciu 1:ceee5a608e7c 45
alexpirciu 1:ceee5a608e7c 46 FilterFunc& m_filter;
alexpirciu 1:ceee5a608e7c 47 DistanceDriver m_distanceDriver;
alexpirciu 1:ceee5a608e7c 48 T m_val_brut;
alexpirciu 1:ceee5a608e7c 49 T m_val_filtrat;
alexpirciu 1:ceee5a608e7c 50 Serial& m_serial;
alexpirciu 1:ceee5a608e7c 51 int idx;
alexpirciu 1:ceee5a608e7c 52 };
alexpirciu 1:ceee5a608e7c 53 #endif