#include "Adafruit_NeoPixel.h"
#include "tapeLED.h"

TapeLED::TapeLED(int pin)
{
    pixels = new Adafruit_NeoPixel(NUMPIXELS, pin, NEO_GRB + NEO_KHZ800);
    init();
}

void TapeLED::init()
{
    pixels->begin();
}

void TapeLED::turnOn(int position, int red, int green, int blue)
{
    pixels->setPixelColor(position, pixels->Color(red, green, blue));
    pixels->show();
}

void TapeLED::turnOn(int position, long color)
{
    byte red = color >> 16 & 0xff;
    byte green = color >> 8 & 0xff;
    byte blue = color & 0xff;
    turnOn(position, red, green, blue);
}

void TapeLED::turnOnAll(int red, int green, int blue)
{
    for (int i = 0; i < NUMPIXELS; i++)
    {
        turnOn(i, red, green, blue);
    }
}

void TapeLED::turnOnAll(long color)
{
    byte red = color >> 16 & 0xff;
    byte green = color >> 8 & 0xff;
    byte blue = color & 0xff;
    turnOnAll(red, green, blue);
}

void TapeLED::turnOff()
{
    turnOnAll(0, 0, 0);
}

void TapeLED::setBlightness(uint8_t blightness)
{
    pixels->setBrightness(blightness);
}
