Commit 09f53f69 authored by Wolfgang Gaar's avatar Wolfgang Gaar Committed by user2684
Browse files

Allow to set power savings mode of BH1750 light level sensor (#197)

parent 83814b81
...@@ -1568,6 +1568,10 @@ SensorBH1750::SensorBH1750(NodeManager* node_manager, int child_id): Sensor(node ...@@ -1568,6 +1568,10 @@ SensorBH1750::SensorBH1750(NodeManager* node_manager, int child_id): Sensor(node
_lightSensor = new BH1750(); _lightSensor = new BH1750();
} }
void SensorBH1750::setMode(uint8_t mode) {
_lightSensor->configure(mode);
}
// what to do during before // what to do during before
void SensorBH1750::onBefore() { void SensorBH1750::onBefore() {
_lightSensor->begin(); _lightSensor->begin();
...@@ -1596,6 +1600,12 @@ void SensorBH1750::onReceive(const MyMessage & message) { ...@@ -1596,6 +1600,12 @@ void SensorBH1750::onReceive(const MyMessage & message) {
// what to do when receiving a remote message // what to do when receiving a remote message
void SensorBH1750::onProcess(Request & request) { void SensorBH1750::onProcess(Request & request) {
int function = request.getFunction();
switch(function) {
case 101: setMode(request.getValueInt()); break;
default: return;
}
_send(_msg_service.set(function));
} }
......
...@@ -972,6 +972,8 @@ class SensorDs18b20: public Sensor { ...@@ -972,6 +972,8 @@ class SensorDs18b20: public Sensor {
class SensorBH1750: public Sensor { class SensorBH1750: public Sensor {
public: public:
SensorBH1750(NodeManager* node_manager, int child_id); SensorBH1750(NodeManager* node_manager, int child_id);
// [101] set sensor reading mode, e.g. BH1750_ONE_TIME_HIGH_RES_MODE
void setMode(uint8_t mode);
// define what to do at each stage of the sketch // define what to do at each stage of the sketch
void onBefore(); void onBefore();
void onSetup(); void onSetup();
......
...@@ -685,6 +685,12 @@ Each sensor class can expose additional methods. ...@@ -685,6 +685,12 @@ Each sensor class can expose additional methods.
DeviceAddress* getDeviceAddress(); DeviceAddress* getDeviceAddress();
~~~ ~~~
* SensorBH1750
~~~c
// [101] set sensor reading mode, e.g. BH1750_ONE_TIME_HIGH_RES_MODE
void setMode(uint8_t mode);
~~~
* SensorBME280 / SensorBMP085 / SensorBMP280 * SensorBME280 / SensorBMP085 / SensorBMP280
~~~c ~~~c
// [101] define how many pressure samples to keep track of for calculating the forecast (default: 5) // [101] define how many pressure samples to keep track of for calculating the forecast (default: 5)
...@@ -1412,4 +1418,4 @@ v1.6: ...@@ -1412,4 +1418,4 @@ v1.6:
* SensorMQ now depends on its own module * SensorMQ now depends on its own module
* Added automatic off capability (safeguard) to SensorDigitalOutput * Added automatic off capability (safeguard) to SensorDigitalOutput
* Any sensor can now access all NodeManager's functions * Any sensor can now access all NodeManager's functions
* DHT sensor now using MySensors' DHT library * DHT sensor now using MySensors' DHT library
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment