/* ============================================
            Uduino NeoPixel Project.
  FastLED library: https://github.com/FastLED/
  =============================================== */
  
  #include "FastLED.h"
#include "Uduino.h"
#define NUM_LEDS 60
#define DATA_PIN 3

CRGB leds[NUM_LEDS];

Uduino uduino("pixels");
uint8_t currentNeopixelMode = 0; // 0 = Manually set led

void setup() {
  Serial.begin(9600);
  delay(1000); // FastLedSanityCheck
  FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);

  uduino.addCommand("SetPixel", SetPixel);
}

void SetPixel() {
  char *arg;
  arg = uduino.next();
  int led =  atoi(arg);

  arg = uduino.next();
  int g = atoi(arg);

  arg = uduino.next();
  int r = (int)atoi(arg);

  arg = uduino.next();
  int b = (int)atoi(arg);
  
   leds[led].setRGB(r,g,b);
   FastLED.show();
}


void SetLuminosity(uint8_t brightness) {
  // Move a single white led 
   for(int led = 0; led < NUM_LEDS; led = led + 1) {
      // Turn our current led on to white, then show the leds
      leds[led].setRGB( brightness, brightness, brightness);
   }
   FastLED.show();

}
void loop() {
   uduino.readSerial();
   delay(15);
}


void NeoPixelMode(uint8_t brightness) {

}


