123456789101112131415161718192021222324252627 |
- #include "application.h"
- #include <WString.h>
- void Application::init() noexcept {
- AbstractNode::init();
- lcd_.begin(16, 2);
- lcd_.clear();
- }
- void Application::update(unsigned long const deltaMillis) noexcept {
- AbstractNode::update(deltaMillis);
- updateDisplay_ += deltaMillis;
- auto const& hs = children_.getHeatSensor();
- if (hs.hasValueChanged() && updateDisplay_ > 250ul) {
- float const voltage = (hs.getValue() / 1024.0f) * 5.0f;
- float const temperature = (voltage - 0.5f) * 100.0f;
- lcd_.home();
- lcd_.write("Temperature: ");
- lcd_.setCursor(0, 1);
- lcd_.write(String{temperature, 2}.c_str());
- lcd_.write(" DC ");
- updateDisplay_ = 0ul;
- }
- }
|