Changed hts221 into Class.
Dependents: WeatherSensor-Joe PAG-CourseWork-NicksEdits SOFT253_Assignment SOFT253_Assignment_V2 ... more
Fork of hts221 by
Revision 2:6d7166d49741, committed 2016-02-10
- Comitter:
- kholland
- Date:
- Wed Feb 10 19:13:37 2016 +0000
- Parent:
- 1:da79e74eadd1
- Commit message:
- Added powerMode function to put it in shutdown
Changed in this revision
hts221.cpp | Show annotated file Show diff for this revision Revisions of this file |
hts221.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r da79e74eadd1 -r 6d7166d49741 hts221.cpp --- a/hts221.cpp Fri Jul 24 15:21:28 2015 +0000 +++ b/hts221.cpp Wed Feb 10 19:13:37 2016 +0000 @@ -136,4 +136,19 @@ float b = (float) -a*x0 + y0; float cal = (float) a * mes + b; return cal; +} +void HTS221::powerMode(PowerMode mode) +{ + char reg; + + register_read(0x20, ®, 1); + + //Set or clear the SHUTDOWN bit + if (mode == POWER_SHUTDOWN) + reg &= ~(PD_On); + else + reg |= PD_On; + + register_write(0x20 , reg); // Control register 1); + } \ No newline at end of file
diff -r da79e74eadd1 -r 6d7166d49741 hts221.h --- a/hts221.h Fri Jul 24 15:21:28 2015 +0000 +++ b/hts221.h Wed Feb 10 19:13:37 2016 +0000 @@ -83,10 +83,15 @@ class HTS221{ public: + enum PowerMode { + POWER_NORMAL, + POWER_SHUTDOWN /**< Chip is in low-power shutdown mode */ + }; HTS221 (PinName sda, PinName scl); void calib(void); bool init(void); void ReadTempHumi( float *pTemp , float *pHumi); + void powerMode(PowerMode mode); private: void register_write(uint8_t register_address, const uint8_t value);