A bit of cleanup.
This commit is contained in:
parent
19f754b577
commit
e508f29a3e
|
|
@ -10,6 +10,7 @@ namespace Dough
|
||||||
|
|
||||||
DistanceSensor::DistanceSensor() : _logger("DISTANCE")
|
DistanceSensor::DistanceSensor() : _logger("DISTANCE")
|
||||||
{
|
{
|
||||||
|
_logger.log("s", "INIT distance sensor object");// TODO
|
||||||
_hcsr04 = new SensorHCSR04(HCSR04_TRIG_PIN, HCSR04_ECHO_PIN);
|
_hcsr04 = new SensorHCSR04(HCSR04_TRIG_PIN, HCSR04_ECHO_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,6 @@
|
||||||
|
|
||||||
namespace Dough
|
namespace Dough
|
||||||
{
|
{
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Constructor
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
// I am using a singleton here, to make it possible to use the physical
|
// I am using a singleton here, to make it possible to use the physical
|
||||||
// DHT11 sensor from the two logical sensors TemperatureSensor and
|
// DHT11 sensor from the two logical sensors TemperatureSensor and
|
||||||
// HumiditySensor.
|
// HumiditySensor.
|
||||||
|
|
@ -20,19 +16,16 @@ namespace Dough
|
||||||
_dht = new DHT(DHT11_DATA_PIN, DHT11);
|
_dht = new DHT(DHT11_DATA_PIN, DHT11);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// setup
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
void SensorDHT11::begin()
|
void SensorDHT11::begin()
|
||||||
{
|
{
|
||||||
_dht->begin();
|
static bool begun = false;
|
||||||
|
if (!begun)
|
||||||
|
{
|
||||||
|
begun = true;
|
||||||
|
_dht->begin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// loop
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
float SensorDHT11::readHumidity()
|
float SensorDHT11::readHumidity()
|
||||||
{
|
{
|
||||||
return _dht->readHumidity();
|
return _dht->readHumidity();
|
||||||
|
|
@ -42,4 +35,4 @@ namespace Dough
|
||||||
{
|
{
|
||||||
return _dht->readTemperature();
|
return _dht->readTemperature();
|
||||||
}
|
}
|
||||||
}
|
} // namespace Dough
|
||||||
|
|
@ -64,7 +64,7 @@ namespace Dough
|
||||||
void SensorHCSR04::_setEchoTimeout()
|
void SensorHCSR04::_setEchoTimeout()
|
||||||
{
|
{
|
||||||
_echoTimeout = HCSR04_MAX_MM * 2 / _speedOfSound;
|
_echoTimeout = HCSR04_MAX_MM * 2 / _speedOfSound;
|
||||||
_logger.log("sfs", "Echo timeout = ", _echoTimeout, "Ms");
|
_logger.log("sis", "Echo timeout = ", _echoTimeout, "Ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SensorHCSR04::_takeSamples()
|
void SensorHCSR04::_takeSamples()
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ namespace Dough
|
||||||
void _setSpeedOfSound();
|
void _setSpeedOfSound();
|
||||||
float _speedOfSound;
|
float _speedOfSound;
|
||||||
void _setEchoTimeout();
|
void _setEchoTimeout();
|
||||||
int _echoTimeout;
|
unsigned int _echoTimeout;
|
||||||
float _samples[HCSR04_SAMPLES_TAKE];
|
float _samples[HCSR04_SAMPLES_TAKE];
|
||||||
void _takeSamples();
|
void _takeSamples();
|
||||||
bool _haveEnoughSamples();
|
bool _haveEnoughSamples();
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,6 @@
|
||||||
|
|
||||||
namespace Dough
|
namespace Dough
|
||||||
{
|
{
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Constructor
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
UI *UI::_instance = nullptr;
|
UI *UI::_instance = nullptr;
|
||||||
|
|
||||||
UI *UI::Instance()
|
UI *UI::Instance()
|
||||||
|
|
@ -24,10 +20,6 @@ namespace Dough
|
||||||
led2(LED2_PIN),
|
led2(LED2_PIN),
|
||||||
led3(LED3_PIN) {}
|
led3(LED3_PIN) {}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Setup
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
void UI::setup()
|
void UI::setup()
|
||||||
{
|
{
|
||||||
// Setup the buttons.
|
// Setup the buttons.
|
||||||
|
|
@ -99,10 +91,6 @@ namespace Dough
|
||||||
; // Wait for synchronization
|
; // Wait for synchronization
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Loop
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Disables the TC4 interrupts, suspending timed async updates to
|
// Disables the TC4 interrupts, suspending timed async updates to
|
||||||
// the user interface.
|
// the user interface.
|
||||||
void UI::suspend()
|
void UI::suspend()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue