application.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include "node.h"
  3. #include "heart_beat.h"
  4. #include "analog_sensor.h"
  5. // LED_BUILTIN, A0
  6. #include <pins_arduino.h>
  7. #include <LiquidCrystal.h>
  8. class Application final : public AbstractNode {
  9. public:
  10. void init() noexcept override;
  11. void update(unsigned long deltaMillis) noexcept override;
  12. protected:
  13. NodeList& getChildren() noexcept override {
  14. return children_;
  15. }
  16. private:
  17. LiquidCrystal lcd_{ 12, 11, 5, 4, 3, 2 };
  18. unsigned long updateDisplay_ = 0ul;
  19. class Children final : public NodeList {
  20. public:
  21. AnalogSensor const& getHeatSensor() const noexcept {
  22. return heatSensor_;
  23. }
  24. Node* get(size_t const index) noexcept override {
  25. switch (index) {
  26. case 0:
  27. return &heartBeat_;
  28. case 1:
  29. return &heatSensor_;
  30. default:
  31. return nullptr;
  32. }
  33. }
  34. size_t size() const noexcept override {
  35. return 2;
  36. }
  37. private:
  38. HeartBeat heartBeat_{ LED_BUILTIN };
  39. AnalogSensor heatSensor_{ A0 };
  40. } children_;
  41. };