A bit of cleanup.
This commit is contained in:
parent
19f754b577
commit
e508f29a3e
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
} // namespace Dough
|
||||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue