grove_heartrate
Revision 0:746f515e2564, committed 2015-06-09
- Comitter:
- JackyZhangFromSeeed
- Date:
- Tue Jun 09 10:19:07 2015 +0000
- Commit message:
- grove_heartrate
Changed in this revision
diff -r 000000000000 -r 746f515e2564 grove_heartrate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/grove_heartrate.cpp Tue Jun 09 10:19:07 2015 +0000 @@ -0,0 +1,26 @@ + + +#include "suli2.h" +#include "grove_heartrate.h" + + + +//local functions + +//local variables + + +void grove_heartrate_init(I2C_T *i2c, int pinsda, int pinscl) +{ + suli_i2c_init(i2c, pinsda, pinscl); +} + +bool grove_heartrate_write_setup(I2C_T *i2c) +{ + return true; +} + +bool grove_heartrate_getheartrate(I2C_T *i2c, uint8_t *heartrate) +{ + suli_i2c_read(i2c, HEARTRATE_ADDRESS, heartrate, 1); +}
diff -r 000000000000 -r 746f515e2564 grove_heartrate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/grove_heartrate.h Tue Jun 09 10:19:07 2015 +0000 @@ -0,0 +1,15 @@ + + + +#ifndef __GROVE_HEARTRATE_H__ +#define __GROVE_HEARTRATE_H__ + +#include "suli2.h" + +#define HEARTRATE_ADDRESS (0xA0) + +void grove_heartrate_init(I2C_T *i2c, int pinsda, int pinscl); +bool grove_heartrate_write_setup(I2C_T *i2c); +bool grove_heartrate_getheartrate(I2C_T *i2c, uint8_t *heartrate); + +#endif
diff -r 000000000000 -r 746f515e2564 grove_heartrate_class.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/grove_heartrate_class.cpp Tue Jun 09 10:19:07 2015 +0000 @@ -0,0 +1,19 @@ + + +#include "grove_heartrate_class.h" + +GroveHeartrate::GroveHeartrate(int pinsda, int pinscl) +{ + this->i2c = (I2C_T *)malloc(sizeof(I2C_T)); + grove_heartrate_init(this->i2c, pinsda, pinscl); +} + +bool GroveHeartrate::write_setup(void) +{ + return grove_heartrate_write_setup(this->i2c); +} + +bool GroveHeartrate::read_heartrate(uint8_t *lux) +{ + return grove_heartrate_getheartrate(this->i2c, lux); +}
diff -r 000000000000 -r 746f515e2564 grove_heartrate_class.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/grove_heartrate_class.h Tue Jun 09 10:19:07 2015 +0000 @@ -0,0 +1,24 @@ + + + +#ifndef __GROVE_HEARTRATE_CLASS_H__ +#define __GROVE_HEARTRATE_CLASS_H__ + +#include "grove_heartrate.h" + +//GROVE_NAME "Grove_Heartrate" +//IF_TYPE I2C +//IMAGE_URL http://www.seeedstudio.com/wiki/File:Grove_-_Finger-clip_Heart_Rate_Sensor.jpg + +class GroveHeartrate +{ +public: + GroveHeartrate(int pinsda, int pinscl); + bool write_setup(void); + bool read_heartrate(uint8_t *lux); + +private: + I2C_T *i2c; +}; + +#endif