AskSin++
Bh1750.h
1 //- -----------------------------------------------------------------------------------------------------------------------
2 // AskSin++
3 // 2018-04-03 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 //- -----------------------------------------------------------------------------------------------------------------------
5 
6 #ifndef __SENSORS_BH1750_h__
7 #define __SENSORS_BH1750_h__
8 
9 #include <Sensors.h>
10 #include <Wire.h>
11 #include <BH1750.h>
12 
13 namespace as {
14 
15 // https://github.com/claws/BH1750
16 template <byte ADDRESS=0x23,::BH1750::Mode MODE=::BH1750::Mode::CONTINUOUS_HIGH_RES_MODE>
17 class Bh1750 : public Brightness {
18  ::BH1750 _bh;
19 public:
20  Bh1750 () : _bh(ADDRESS) {}
21  void init () {
22  _present = _bh.begin(MODE);
23  }
24  void measure (__attribute__((unused)) bool async=false) {
25  if( present() == true ) {
26  _brightness = _bh.readLightLevel();
27  }
28  }
29 };
30 
31 }
32 
33 #endif
as::Bh1750
Definition: Bh1750.h:17
as::Brightness
Definition: Sensors.h:21