diff --git a/src/Sensors/DistanceSensor.cpp b/src/Sensors/DistanceSensor.cpp index be2d732..979c63f 100644 --- a/src/Sensors/DistanceSensor.cpp +++ b/src/Sensors/DistanceSensor.cpp @@ -10,6 +10,7 @@ namespace Dough DistanceSensor::DistanceSensor() : _logger("DISTANCE") { + _logger.log("s", "INIT distance sensor object");// TODO _hcsr04 = new SensorHCSR04(HCSR04_TRIG_PIN, HCSR04_ECHO_PIN); } diff --git a/src/Sensors/LowLevel/SensorDHT11.cpp b/src/Sensors/LowLevel/SensorDHT11.cpp index b2c1418..87625ff 100644 --- a/src/Sensors/LowLevel/SensorDHT11.cpp +++ b/src/Sensors/LowLevel/SensorDHT11.cpp @@ -2,10 +2,6 @@ namespace Dough { - // ---------------------------------------------------------------------- - // Constructor - // ---------------------------------------------------------------------- - // I am using a singleton here, to make it possible to use the physical // DHT11 sensor from the two logical sensors TemperatureSensor and // HumiditySensor. @@ -20,19 +16,16 @@ namespace Dough _dht = new DHT(DHT11_DATA_PIN, DHT11); } - // ---------------------------------------------------------------------- - // setup - // ---------------------------------------------------------------------- - void SensorDHT11::begin() { - _dht->begin(); + static bool begun = false; + if (!begun) + { + begun = true; + _dht->begin(); + } } - // ---------------------------------------------------------------------- - // loop - // ---------------------------------------------------------------------- - float SensorDHT11::readHumidity() { return _dht->readHumidity(); @@ -42,4 +35,4 @@ namespace Dough { return _dht->readTemperature(); } -} \ No newline at end of file +} // namespace Dough \ No newline at end of file diff --git a/src/Sensors/LowLevel/SensorHCSR04.cpp b/src/Sensors/LowLevel/SensorHCSR04.cpp index ed58f59..f7e02d8 100644 --- a/src/Sensors/LowLevel/SensorHCSR04.cpp +++ b/src/Sensors/LowLevel/SensorHCSR04.cpp @@ -64,7 +64,7 @@ namespace Dough void SensorHCSR04::_setEchoTimeout() { _echoTimeout = HCSR04_MAX_MM * 2 / _speedOfSound; - _logger.log("sfs", "Echo timeout = ", _echoTimeout, "Ms"); + _logger.log("sis", "Echo timeout = ", _echoTimeout, "Ms"); } void SensorHCSR04::_takeSamples() diff --git a/src/Sensors/LowLevel/SensorHCSR04.h b/src/Sensors/LowLevel/SensorHCSR04.h index d3683f4..396b70f 100644 --- a/src/Sensors/LowLevel/SensorHCSR04.h +++ b/src/Sensors/LowLevel/SensorHCSR04.h @@ -54,7 +54,7 @@ namespace Dough void _setSpeedOfSound(); float _speedOfSound; void _setEchoTimeout(); - int _echoTimeout; + unsigned int _echoTimeout; float _samples[HCSR04_SAMPLES_TAKE]; void _takeSamples(); bool _haveEnoughSamples(); diff --git a/src/UI/UI.cpp b/src/UI/UI.cpp index c75fe1b..7ae62e8 100644 --- a/src/UI/UI.cpp +++ b/src/UI/UI.cpp @@ -2,10 +2,6 @@ namespace Dough { - // ---------------------------------------------------------------------- - // Constructor - // ---------------------------------------------------------------------- - UI *UI::_instance = nullptr; UI *UI::Instance() @@ -24,10 +20,6 @@ namespace Dough led2(LED2_PIN), led3(LED3_PIN) {} - // ---------------------------------------------------------------------- - // Setup - // ---------------------------------------------------------------------- - void UI::setup() { // Setup the buttons. @@ -99,10 +91,6 @@ namespace Dough ; // Wait for synchronization } - // ---------------------------------------------------------------------- - // Loop - // ---------------------------------------------------------------------- - // Disables the TC4 interrupts, suspending timed async updates to // the user interface. void UI::suspend()