A bit of cleanup.

This commit is contained in:
Maurice Makaay 2020-07-14 21:12:55 +02:00
parent 19f754b577
commit e508f29a3e
5 changed files with 10 additions and 28 deletions

View File

@ -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);
}

View File

@ -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,18 +16,15 @@ namespace Dough
_dht = new DHT(DHT11_DATA_PIN, DHT11);
}
// ----------------------------------------------------------------------
// setup
// ----------------------------------------------------------------------
void SensorDHT11::begin()
{
static bool begun = false;
if (!begun)
{
begun = true;
_dht->begin();
}
// ----------------------------------------------------------------------
// loop
// ----------------------------------------------------------------------
}
float SensorDHT11::readHumidity()
{
@ -42,4 +35,4 @@ namespace Dough
{
return _dht->readTemperature();
}
}
} // namespace Dough

View File

@ -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()

View File

@ -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();

View File

@ -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()