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
_lightSensor = new BH1750();
}
void SensorBH1750::setMode(uint8_t mode) {
_lightSensor->configure(mode);
}
// what to do during before
void SensorBH1750::onBefore() {
_lightSensor->begin();
......@@ -1596,6 +1600,12 @@ void SensorBH1750::onReceive(const MyMessage & message) {
// what to do when receiving a remote message
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 {
class SensorBH1750: public Sensor {
public:
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
void onBefore();
void onSetup();
......
......@@ -685,6 +685,12 @@ Each sensor class can expose additional methods.
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
~~~c
// [101] define how many pressure samples to keep track of for calculating the forecast (default: 5)
......@@ -1412,4 +1418,4 @@ v1.6:
* SensorMQ now depends on its own module
* Added automatic off capability (safeguard) to SensorDigitalOutput
* Any sensor can now access all NodeManager's functions
* DHT sensor now using MySensors' DHT library
\ No newline at end of file
* DHT sensor now using MySensors' DHT library
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