rgbfill.ino 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 D4
  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 500 //Delay before auto increments
  18. #define BUTTON_HOLD_DELAY 50 //Auto-increment delays
  19. #define MAX_BRIGHTNESS 128 //Make sure the battery you using can output the current required by LEDs
  20. #define MAX_CTRLBRIGHTNESS 32 //Max brightness for signaling LED (the one above the button)
  21. //Runtimes
  22. /*
  23. Current Mode
  24. 0 = White Mode (+/- Change the K value of the light)
  25. 1 = RGB Mode (+/C/- Change the RGB values of the light)
  26. 2 = Pure Color Mode (C Change the default color palletes, +- change brightness offset)
  27. 3 = Presets Mode (+/- Change the preset profile currently using)
  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. */
  40. int adjustingCatergory = 0;
  41. /*
  42. Color Values
  43. [White Mode]
  44. TEMP, Brightness, (un-used)
  45. [RGB Mode]
  46. R, G, B
  47. */
  48. int values[] = {0, 0, 0};
  49. int currentCtrlLedRgb[] = {0,0,0};
  50. Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
  51. //Set the current control LED color
  52. void setControlLEDColor(int r, int g, int b){
  53. currentCtrlLedRgb[0] = r;
  54. currentCtrlLedRgb[1] = g;
  55. currentCtrlLedRgb[2] = b;
  56. strip.setPixelColor(0, strip.Color(r, g, b));
  57. strip.show();
  58. }
  59. //Set the current LED light color by given RGB values
  60. void setLightColor(int r, int g, int b) {
  61. for (int i = 1; i < NUM_LEDS; i++) {
  62. strip.setPixelColor(i, strip.Color(r, g, b));
  63. }
  64. strip.show();
  65. }
  66. void setup() {
  67. Serial.begin(115200);
  68. //Set the buttons to input pin
  69. pinMode(BUTTON_MODE, INPUT);
  70. pinMode(BUTTON_ADD, INPUT);
  71. pinMode(BUTTON_COLOR, INPUT);
  72. pinMode(BUTTON_MINUS, INPUT);
  73. strip.begin();
  74. // Initialize all pixels to natural warm white light
  75. loadWhiteModeDefault();
  76. }
  77. void loop() {
  78. handleButtonLogic();
  79. }