diff --git a/src/main.cpp b/src/main.cpp index 96ac93b..6d240cc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,6 +5,31 @@ Adafruit_NeoKey_1x4 neokey; // Create the NeoKey object +uint32_t Wheel(byte WheelPos); +NeoKey1x4Callback blink(keyEvent evt); + +//define a callback for key presses +NeoKey1x4Callback blink(keyEvent evt) { + uint8_t key = evt.bit.NUM; + + if (evt.bit.EDGE == SEESAW_KEYPAD_EDGE_RISING) { + Serial.print("Key press "); + Serial.println(key); + neokey.pixels.setPixelColor(key, Wheel(map(key, 0, neokey.pixels.numPixels(), 0, 255))); + + } else if (evt.bit.EDGE == SEESAW_KEYPAD_EDGE_FALLING) { + Serial.print("Key release "); + Serial.println(key); + + neokey.pixels.setPixelColor(key, 0); + } + + // Turn on/off the neopixels! + neokey.pixels.show(); + return 0; +} + + void setup() { Serial.begin(115200); while (! Serial) delay(10); @@ -27,43 +52,17 @@ void setup() { neokey.pixels.show(); delay(50); } + + // set callbacks + for(int i=0; i