123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- /*
- RGB Fill Lights
- Author: tobychui
- This is the firmware for tobychui's
- Programmable RGB Fill Light
- Recommend compiling with following board profiles
- - Wemos D1 Mini
- */
- #include <Adafruit_NeoPixel.h>
- // Hardware Configs
- #define PIN D4
- #define NUM_LEDS 46
- #define BUTTON_MODE D7
- #define BUTTON_ADD D6
- #define BUTTON_COLOR D5
- #define BUTTON_MINUS D0
- #define BUTTON_AUTOINC_DELAY 300 //Delay before auto increments
- #define BUTTON_HOLD_DELAY 50 //Auto-increment delays
- #define BUTTON_DEBOUNCE 50 //Naive debounce delay in ms
- #define MAX_BRIGHTNESS 256 //Make sure the battery you using can output the current required by LEDs
- #define MAX_CTRLBRIGHTNESS 32 //Max brightness for signaling LED (the one above the button)
- //Runtimes
- /*
- Current Mode
- 0 = White Mode (+/- Change the K value of the light)
- 1 = RGB Mode (+/C/- Change the RGB values of the light)
- 2 = Pure Color Mode (C Change the default color palletes, +- change brightness offset)
- */
- int currentMode = 0;
- /*
- Adjusting Catergory
- [White Mode]
- 0 = Color Temperature (K)
- 1 = Brightness
- [RGB Mode]
- 0 = Red
- 1 = Green
- 2 = Blue
- [Pallete Mode]
- 0 = Color Pallete
- 1 = Brightness
- */
- int adjustingCatergory = 0;
- /*
- Color Values
- [White Mode]
- TEMP, Brightness, (un-used)
- [RGB Mode]
- R, G, B
- [Pallete Mode]
- PalleteID, Brightness, (unused)
- */
- int values[] = {0, 0, 0};
- int currentCtrlLedRgb[] = {0,0,0};
- Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
- //Set the current control LED color
- void setControlLEDColor(int r, int g, int b){
- currentCtrlLedRgb[0] = r;
- currentCtrlLedRgb[1] = g;
- currentCtrlLedRgb[2] = b;
- strip.setPixelColor(0, strip.Color(r, g, b));
- strip.show();
- }
- //Set the current LED light color by given RGB values
- void setLightColor(int r, int g, int b) {
- for (int i = 1; i < NUM_LEDS; i++) {
- strip.setPixelColor(i, strip.Color(r, g, b));
- }
- strip.show();
- }
- void setup() {
- Serial.begin(115200);
- //Set the buttons to input pin
- pinMode(BUTTON_MODE, INPUT);
- pinMode(BUTTON_ADD, INPUT);
- pinMode(BUTTON_COLOR, INPUT);
- pinMode(BUTTON_MINUS, INPUT);
- strip.begin();
- // Initialize all pixels to natural warm white light
- loadWhiteModeDefault();
- }
- void loop() {
- handleButtonLogic();
- }
|