diff --git a/NodeManager.cpp b/NodeManager.cpp index 54e451f332f9fd8c031ef64129147ed93fac18df..9f86a1333be462bc890451df67a741133ead6dd7 100755 --- a/NodeManager.cpp +++ b/NodeManager.cpp @@ -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)); } diff --git a/NodeManager.h b/NodeManager.h index ac40f34efdea9b2a161619f6757419ea471438f5..4ed5a24fedc75247bb89230de7471be149e64484 100755 --- a/NodeManager.h +++ b/NodeManager.h @@ -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(); diff --git a/README.md b/README.md index 9bc784fe1128cb318ab1ff15ba741e9ea0ad6223..094fe2d34c0a39c12351b0af239e0848bfe4d91a 100755 --- a/README.md +++ b/README.md @@ -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