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