#ifndef __LED_STRIP_HPP__
#define __LED_STRIP_HPP__
#include <Arduino.h>

#if defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41)
#include <tinyNeoPixel_Static.h>
#else
#include <Adafruit_NeoPixel.h>
#endif /* defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41) */

#include "pin_map.hpp"
#include "global.hpp"


#if defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41)
class LedStrip : tinyNeoPixel {
#else
class LedStrip : Adafruit_NeoPixel {
#endif /* defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41) */

public:
#if defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41)
  LedStrip(void)
      : tinyNeoPixel{LedCount, LedPin, NEO_GRB + NEO_KHZ800, pixels}, firstLedOn{0},
        ledOnCount{LedCount}, hue{2048}, saturation{207}, brightness{239} {}
  void fill(uint32_t c = 0, uint16_t first = 0, uint16_t count = 0);
#else
  LedStrip(void)
      : Adafruit_NeoPixel{LedCount, LedPin, NEO_GRB + NEO_KHZ800}, firstLedOn{0}, ledOnCount{LedCount},
        hue{2048}, saturation{207}, brightness{239} {}
#endif /* defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41) */
  virtual ~LedStrip() {}

  void setup(bool is_diag_mode);

  void display_mode(unsigned int mode_index);
  void refresh();

  void shiftHue(int shift);
  void shiftSaturation(int shift);
  void shiftBrightness(int shift);
  void shiftFirstLedOn(int shift);
  void shiftLedOnLenght(int shift);

private:
  uint16_t static const LedCount{LED_STRIP_LEGNTH};

#if defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41)
  byte pixels[LedCount * 3];
#endif /* defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41) */

  unsigned int firstLedOn, ledOnCount;
  uint16_t hue;
  uint8_t saturation;
  uint8_t brightness;
};

#endif /* __LED_STRIP_HPP__ */
