Added a GPIO to power on/off for external I2C sensor(s) (with LEDs)

Dependencies:   UniGraphic mbed vt100

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers edge_accel.h Source File

edge_accel.h

00001 #ifndef _EDGE_ACCEL_H_
00002 #define _EDGE_ACCEL_H_
00003 #include "mbed.h"
00004 #include "edge_sensor.h"
00005 #include "MMA8451Q.h"
00006 
00007 /**
00008  * edge_accel edge_sensor which manage the accelerometer sensor (MMA8451Q)
00009  * @note The behavior of this class is somewhat exceptional as an edge_sensor
00010  * @note it samples and accumulates data which is the abs sum of current
00011  * @note values and previous values every 0.1 sec
00012  * @note and in each "interval" it delivers the averaged value 
00013  */
00014 
00015 class edge_accel : public edge_sensor {
00016 public:
00017 /**
00018  * constructor
00019  * @param the MMA8451Q object
00020  */
00021     edge_accel(MMA8451Q *accel) ;
00022     
00023 /**
00024  * destructor
00025  */
00026     ~edge_accel(void) ;
00027 
00028 /**
00029  * clear and reset interval values
00030  */
00031     virtual void    reset(void) ;
00032 //    virtual void    prepare(void) ;
00033 
00034 /**
00035  * sample calculate the average value
00036  * from _accumulation and _sample_count
00037  * the average value is assigned to _value
00038  * and currnt _sample_count is stored in _num_sampled
00039  * then both _accumuation and _sample_count will be cleared
00040  * @returns 0: success non-0: failure
00041  */
00042     virtual int    sample(void) ;
00043     
00044 /**
00045  * deliver the value to the afero cloud
00046  */
00047     virtual int     deliver(void) ;
00048     
00049 /**
00050  * show the data in the display (TFT)
00051  */
00052     virtual void    show(void) ;
00053         
00054 /**
00055  * accum this is the real sampling
00056  * and the differences of sampled values 
00057  * and previous values are calcurated and accumulated
00058  * @returns 0: success non-0: failure
00059  */
00060     int accum(void) ;
00061     
00062 /**
00063  * Clear internal values
00064  */
00065     void clear_value(void) ;
00066 
00067 private:
00068     MMA8451Q *_accel ;
00069     float   _value ;
00070     int32_t _num_sampled ;
00071     int32_t _sample_count ;
00072     int32_t _accumulation ;
00073     int16_t _prev_x ;
00074     int16_t _prev_y ;
00075     int16_t _prev_z ;
00076 } ;
00077 
00078 #endif /* _EDGE_ACCEL_H_ */