#pragma once

#include "node.h"
#include "heart_beat.h"
#include "analog_sensor.h"

// LED_BUILTIN, A0
#include <pins_arduino.h>

#include <LiquidCrystal.h>

class Application final : public AbstractNode {
public:
  void init() noexcept override;

  void update(unsigned long deltaMillis) noexcept override;

protected:
  NodeList& getChildren() noexcept override {
    return children_;
  }

private:
  LiquidCrystal lcd_{ 12, 11, 5, 4, 3, 2 };
  unsigned long updateDisplay_ = 0ul;

  class Children final : public NodeList {
  public:
    AnalogSensor const& getHeatSensor() const noexcept {
      return heatSensor_;
    }

    Node* get(size_t const index) noexcept override {
      switch (index) {
        case 0:
          return &heartBeat_;
        case 1:
          return &heatSensor_;
        default:
          return nullptr;
      }
    }

    size_t size() const noexcept override {
      return 2;
    }

  private:
    HeartBeat heartBeat_{ LED_BUILTIN };
    AnalogSensor heatSensor_{ A0 };
  } children_;
};