rgbfill.ino 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. RGB Fill Lights
  3. Author: tobychui
  4. This is the firmware for tobychui's
  5. Programmable RGB Fill Light
  6. Recommend compiling with following board profiles
  7. - Wemos D1 Mini
  8. */
  9. #include <Adafruit_NeoPixel.h>
  10. // Hardware Configs
  11. #define PIN D2
  12. #define NUM_LEDS 46
  13. #define BUTTON_MODE D7
  14. #define BUTTON_ADD D6
  15. #define BUTTON_COLOR D5
  16. #define BUTTON_MINUS D0
  17. #define BUTTON_AUTOINC_DELAY 300 //Delay before auto increments
  18. #define BUTTON_HOLD_DELAY 50 //Auto-increment delays
  19. #define BUTTON_DEBOUNCE 50 //Naive debounce delay in ms
  20. #define MAX_BRIGHTNESS 256 //Make sure the battery you using can output the current required by LEDs
  21. #define MAX_CTRLBRIGHTNESS 32 //Max brightness for signaling LED (the one above the button)
  22. //Runtimes
  23. /*
  24. Current Mode
  25. 0 = White Mode (+/- Change the K value of the light)
  26. 1 = RGB Mode (+/C/- Change the RGB values of the light)
  27. 2 = Pure Color Mode (C Change the default color palletes, +- change brightness offset)
  28. */
  29. int currentMode = 0;
  30. /*
  31. Adjusting Catergory
  32. [White Mode]
  33. 0 = Color Temperature (K)
  34. 1 = Brightness
  35. [RGB Mode]
  36. 0 = Red
  37. 1 = Green
  38. 2 = Blue
  39. [Pallete Mode]
  40. 0 = Color Pallete
  41. 1 = Brightness
  42. */
  43. int adjustingCatergory = 0;
  44. /*
  45. Color Values
  46. [White Mode]
  47. TEMP, Brightness, (un-used)
  48. [RGB Mode]
  49. R, G, B
  50. [Pallete Mode]
  51. PalleteID, Brightness, (unused)
  52. */
  53. int values[] = {0, 0, 0};
  54. int currentCtrlLedRgb[] = {0,0,0};
  55. Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
  56. //Set the current control LED color
  57. void setControlLEDColor(int r, int g, int b){
  58. currentCtrlLedRgb[0] = r;
  59. currentCtrlLedRgb[1] = g;
  60. currentCtrlLedRgb[2] = b;
  61. strip.setPixelColor(0, strip.Color(r, g, b));
  62. strip.show();
  63. }
  64. //Set the current LED light color by given RGB values
  65. void setLightColor(int r, int g, int b) {
  66. for (int i = 1; i < NUM_LEDS; i++) {
  67. strip.setPixelColor(i, strip.Color(r, g, b));
  68. }
  69. strip.show();
  70. }
  71. void setup() {
  72. Serial.begin(115200);
  73. //Set the buttons to input pin
  74. pinMode(BUTTON_MODE, INPUT);
  75. pinMode(BUTTON_ADD, INPUT);
  76. pinMode(BUTTON_COLOR, INPUT);
  77. pinMode(BUTTON_MINUS, INPUT);
  78. strip.begin();
  79. // Initialize all pixels to natural warm white light
  80. loadWhiteModeDefault();
  81. }
  82. void loop() {
  83. handleButtonLogic();
  84. }