#pragma once

// C++ system level
#include <vector>
// #include <cstring>     // memset, strncmp
// #include <cstdlib>     // TODO: is this for memcpy?
// #include <functional>

// ESP32 specific
#include "esp_log.h"

// project specific
#include <Types.hpp>
#include "Service.hpp"

// qthing stuff
#include "SiliconTorch/FxCyanRGB8.hpp"
// #include <qthing>


namespace SiliconTorch {

  namespace Service {

    namespace CyanStripe {

      constexpr u8 MAX_CHANNELS = 8;


      typedef struct {

        u8   gpio     = 0;
        u16  leds     = 0;
        u16  startIdx = 0;
        bool valid    = false;

      } ChannelInfo;


      typedef struct {

        ChannelInfo info;
        SiliconTorch::FxCyanRGB8::FxCyanRGB8* cyanRGB;

      } ChannelDriver;



      class CyanStripe : public ServiceManager::Service {

        public:


          void init();

          void start();


          ChannelInfo readChannelData(u8 channel) const;  // Read data from NVS

          // TODO: replace with our own LED driver!
          void configureQthingLEDs(qthing::Config* cfg) const;


          // TODO: should we block copy/assignment by default…?
          CyanStripe() {};
          CyanStripe(const CyanStripe&) = delete;
          CyanStripe& operator=(CyanStripe const&) = delete;

        private:

          std::vector<ChannelDriver> channels;


      };

    }
  }
}