Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

<a title="Gringer, Public domain, via Wikimedia Commons" href="https://commons.wikimedia.org/wiki/File:Blended_colour_wheel.svg">
<img width="128" alt="Blended colour wheel" src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/Blended_colour_wheel.svg/128px-Blended_colour_wheel.svg.png">
</a>

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.
Expand Down
47 changes: 47 additions & 0 deletions src/rainbow-picker.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Inspired by ChaosNuggets's Diabolo-Lights-Rainbow:
// <https://github.com/ChaosNuggets/Diabolo-Lights-Rainbow/blob/3b8d74af665ea307387e30cf8260938542734877/src/main.cpp>

#include <Arduino.h>
#include <Diabolo_Light.h>
#include <Adafruit_NeoPixel.h>

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;
}
}