diff --git a/README.md b/README.md index b18f83e..525ccd2 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,19 @@ This program is used to pick colors that look good on the LED kit. This program shows a color on initial button press, and will turn off on the 2nd press. +## `src/rainbow_picker.cpp` + + + Blended colour wheel + + +This program cycles through colors of the color wheel. Usage: + +1. Press to begin color cycling. +2. Press to stop at a color. +3. Press again to resume color cycling. +4. Long press to turn off. + ## `src/performance.cpp` This program defines a performance consisting of scenes which are defined by colors and transitions between colors. Contains generic structs which I hope to pull out into a separate file eventually. diff --git a/src/rainbow-picker.cpp b/src/rainbow-picker.cpp new file mode 100644 index 0000000..f708419 --- /dev/null +++ b/src/rainbow-picker.cpp @@ -0,0 +1,47 @@ +// Inspired by ChaosNuggets's Diabolo-Lights-Rainbow: +// + +#include +#include +#include + +Adafruit_NeoPixel pixels( + Diabolo_Light::NUM_LEDS, + Diabolo_Light::LED_PIN, + Diabolo_Light::LED_TYPE +); +uint16_t hue; + +void set_all_pixels(uint32_t color) { + for (unsigned int i = 0; i < Diabolo_Light::NUM_LEDS; i++) { + pixels.setPixelColor(i, color); + } + pixels.show(); +} + +void setup() { + pixels.begin(); + Diabolo_Light::begin( + // num_modes. set to maximum possible value + 255, + + // time_to_turn_on + 0, + + // on_wake_up + [](){ hue = -1000; }, + + // time_to_turn_off + 1000 + ); +} + +void loop() { + Diabolo_Light::handle_button(); + int mode = Diabolo_Light::get_current_mode(); + + if (mode % 2 == 1) { + set_all_pixels(pixels.ColorHSV(hue, 255, 255)); + hue += 3; + } +}