mode_rgb.ino 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //Load the default runtime for RGB Mode
  2. void loadRGBModeDefault() {
  3. values[0] = MAX_BRIGHTNESS; //R
  4. values[1] = MAX_BRIGHTNESS; //G
  5. values[2] = MAX_BRIGHTNESS; //B
  6. adjustingCatergory = 0;
  7. //Set current controlling to red
  8. setControlLEDColor(MAX_CTRLBRIGHTNESS, 0, 0);
  9. //Set LED color to white
  10. setLightColor(values[0], values[1], values[2]);
  11. }
  12. //Handlers for add / minus button
  13. void handleRGBModeAdd() {
  14. switch (adjustingCatergory) {
  15. case 0:
  16. //Red
  17. values[0] += 2;
  18. if (values[0] > 255) {
  19. values[0] = 255;
  20. blinkUpperLimit();
  21. }
  22. break;
  23. case 1:
  24. //Green
  25. values[1] += 2;
  26. if (values[1] > 255) {
  27. values[1] = 255;
  28. blinkUpperLimit();
  29. }
  30. break;
  31. case 2:
  32. //Blue
  33. values[2] += 2;
  34. if (values[2] > 255) {
  35. values[2] = 255;
  36. blinkUpperLimit();
  37. }
  38. break;
  39. }
  40. //Update the LED color
  41. setLightColor(values[0], values[1], values[2]);
  42. Serial.print("Updating RGB value to {");
  43. Serial.print(values[0]);
  44. Serial.print(", ");
  45. Serial.print(values[1]);
  46. Serial.print(", ");
  47. Serial.print(values[2]);
  48. Serial.println("}");
  49. }
  50. void handleRGBModeMinus() {
  51. switch (adjustingCatergory) {
  52. case 0:
  53. //Red
  54. values[0] -= 2;
  55. if (values[0] <= 0) {
  56. values[0] = 0;
  57. blinkLowerLimit();
  58. }
  59. break;
  60. case 1:
  61. //Green
  62. values[1] -= 2;
  63. if (values[1] <= 0) {
  64. values[1] = 0;
  65. blinkLowerLimit();
  66. }
  67. break;
  68. case 2:
  69. //Blue
  70. values[2] -= 2;
  71. if (values[2] <= 0) {
  72. values[2] = 0;
  73. blinkLowerLimit();
  74. }
  75. break;
  76. }
  77. //Update the LED color
  78. setLightColor(values[0], values[1], values[2]);
  79. Serial.print("Updating RGB value to {");
  80. Serial.print(values[0]);
  81. Serial.print(", ");
  82. Serial.print(values[1]);
  83. Serial.print(", ");
  84. Serial.print(values[2]);
  85. Serial.println("}");
  86. }