Nice 8bar clock and default color

This commit is contained in:
Lukas Bachschwell 2016-07-15 20:33:00 +02:00
parent 0fdca16836
commit 7794f89525

View File

@ -4,6 +4,9 @@
//8 LEDs and Pin is 11
Adafruit_NeoPixel leds = Adafruit_NeoPixel(8, 11, NEO_GRB + NEO_KHZ800);
uint16_t gdef = 0;
uint16_t rdef = 100;
uint16_t bdef = 200;
bool oldValues[8] = {
1, 1, 1, 1, 1, 1, 1, 1
@ -25,13 +28,36 @@ int bar = 1;
int pedalNote = 10;
int clearNote = 9;
void tick()
{
void tick8() {
if (time == 24)
time = 0;
if (bar == 4)
if (bar >= 8)
bar = 0;
if (time == 0) {
for (uint16_t i = 0; i < leds.numPixels(); i++) {
leds.setPixelColor(i, gdef, rdef, bdef);
}
leds.setPixelColor(bar, 255, 255, 255);
leds.show();
}
if (time == 0)
bar++;
time++;
}
void tickSimple() {
if (time == 24)
time = 0;
if (bar >= 4)
bar = 0;
@ -68,14 +94,16 @@ void goClock()
void stopClock()
{
digitalWrite(13, LOW);
digitalWrite(12, LOW);
for (uint16_t i = 0; i < leds.numPixels(); i++) {
leds.setPixelColor(i, gdef, rdef, bdef);
}
leds.show();
}
void RealTimeSystem(byte realtimebyte) {
if (realtimebyte == 248) {
tick();
tick8();
}
if (realtimebyte == START || realtimebyte == CONTINUE) {
@ -106,12 +134,12 @@ void setup() {
usbMIDI.setHandleRealTimeSystem(RealTimeSystem);
leds.begin();
leds.show();
/*
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
leds.setPixelColor(i,255,255,255);
for (uint16_t i = 0; i < leds.numPixels(); i++) {
leds.setPixelColor(i, gdef, rdef, bdef);
}
leds.show();
*/
}
void loop() {
@ -163,11 +191,11 @@ void loop() {
{*/
if (tempState == 0) {
usbMIDI.sendNoteOn(i, 127, 1);
leds.setPixelColor(i,255,255,255);
leds.setPixelColor(i, 0, 255, 0);
leds.show();
} else {
usbMIDI.sendNoteOff(i, 0, 1);
leds.setPixelColor(i,0,0,0);
leds.setPixelColor(i, gdef, rdef, bdef);
leds.show();
}
// }