Auto-formatted
#include "Adafruit_NeoPixel.h"
#include <SPI.h>
#include <boards.h>
#include <ble_shield.h>
#include <services.h>
//Control Pin(s)
#define Left_Blinkers 5
#define Right_Blinkers 6
#define Left_Signal_Input 7
#define Right_Signal_Input 8
int lsiState = 0;
int rsiState = 0;
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_RGB Pixels are wired for RGB bitstream
// NEO_GRB Pixels are wired for GRB bitstream
// NEO_KHZ400 400 KHz bitstream (e.g. FLORA pixels)
// NEO_KHZ800 800 KHz bitstream (e.g. High Density LED strip)
Adafruit_NeoPixel strip_left = Adafruit_NeoPixel(4, Left_Blinkers, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip_right = Adafruit_NeoPixel(4, Right_Blinkers, NEO_GRB + NEO_KHZ800);
int R = 0;
int G = 0;
int B = 0;
void setup()
{
strip_left.begin();
strip_left.show(); // Initialize all pixels to 'off'
strip_right.begin();
strip_right.show(); // Initialize all pixels to 'off'
pinMode(Left_Signal_Input, INPUT);
pinMode(Right_Signal_Input, INPUT);
ble_begin();
}
void loop()
{
if(3 == ble_available())
{
R = ble_read();
G = ble_read();
B = ble_read();
colorWipe( strip_left.Color(R, G, B) );
colorWipe( strip_right.Color(R, G, B) );
}
ble_do_events();
//simplify syntax for yellow color
uint32_t yellowl = strip_left.Color(255, 255, 0);
uint32_t yellowr = strip_right.Color(255, 255, 0);
//Configure Input Pins
lsiState = digitalRead(Left_Signal_Input);
rsiState = digitalRead(Right_Signal_Input);
//Actions for Blinkers
if(lsiState == HIGH) {
strip_left.setPixelColor(0, yellowl);
strip_left.setPixelColor(1, yellowl);
strip_left.setPixelColor(2, yellowl);
strip_left.setPixelColor(3, yellowl);
strip_left.show();
}
if(lsiState == LOW) {
strip_left.show();
}
if(rsiState == HIGH) {
strip_right.setPixelColor(0, yellowr);
strip_right.setPixelColor(1, yellowr);
strip_right.setPixelColor(2, yellowr);
strip_right.setPixelColor(3, yellowr);
strip_right.show();
}
if(rsiState == LOW) {
strip_right.show();
}
}
// Fill the dots one after the other with a color
void colorWipe(uint32_t c)
{
for(uint16_t i=0; i<strip_left.numPixels(); i++)
{
strip_left.setPixelColor(i, c);
strip_left.show();
}
for(uint16_t i=0; i<strip_right.numPixels(); i++)
{
strip_right.setPixelColor(i, c);
strip_right.show();
}
}