My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

menu_led.cpp 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. //
  23. // LED Menu
  24. //
  25. #include "../../inc/MarlinConfigPre.h"
  26. #if HAS_MARLINUI_MENU && EITHER(LED_CONTROL_MENU, CASE_LIGHT_MENU)
  27. #include "menu_item.h"
  28. #if ENABLED(PSU_CONTROL)
  29. #include "../../feature/power.h"
  30. #endif
  31. #if ENABLED(LED_CONTROL_MENU)
  32. #include "../../feature/leds/leds.h"
  33. #if ENABLED(LED_COLOR_PRESETS)
  34. void menu_led_presets() {
  35. START_MENU();
  36. #if LCD_HEIGHT > 2
  37. STATIC_ITEM(MSG_LED_PRESETS, SS_DEFAULT|SS_INVERT);
  38. #endif
  39. BACK_ITEM(MSG_LED_CONTROL);
  40. ACTION_ITEM(MSG_SET_LEDS_WHITE, leds.set_white);
  41. ACTION_ITEM(MSG_SET_LEDS_RED, leds.set_red);
  42. ACTION_ITEM(MSG_SET_LEDS_ORANGE, leds.set_orange);
  43. ACTION_ITEM(MSG_SET_LEDS_YELLOW, leds.set_yellow);
  44. ACTION_ITEM(MSG_SET_LEDS_GREEN, leds.set_green);
  45. ACTION_ITEM(MSG_SET_LEDS_BLUE, leds.set_blue);
  46. ACTION_ITEM(MSG_SET_LEDS_INDIGO, leds.set_indigo);
  47. ACTION_ITEM(MSG_SET_LEDS_VIOLET, leds.set_violet);
  48. END_MENU();
  49. }
  50. #endif
  51. #if ENABLED(NEO2_COLOR_PRESETS)
  52. void menu_leds2_presets() {
  53. START_MENU();
  54. #if LCD_HEIGHT > 2
  55. STATIC_ITEM(MSG_NEO2_PRESETS, SS_DEFAULT|SS_INVERT);
  56. #endif
  57. BACK_ITEM(MSG_LED_CONTROL);
  58. ACTION_ITEM(MSG_SET_LEDS_WHITE, leds2.set_white);
  59. ACTION_ITEM(MSG_SET_LEDS_RED, leds2.set_red);
  60. ACTION_ITEM(MSG_SET_LEDS_ORANGE, leds2.set_orange);
  61. ACTION_ITEM(MSG_SET_LEDS_YELLOW, leds2.set_yellow);
  62. ACTION_ITEM(MSG_SET_LEDS_GREEN, leds2.set_green);
  63. ACTION_ITEM(MSG_SET_LEDS_BLUE, leds2.set_blue);
  64. ACTION_ITEM(MSG_SET_LEDS_INDIGO, leds2.set_indigo);
  65. ACTION_ITEM(MSG_SET_LEDS_VIOLET, leds2.set_violet);
  66. END_MENU();
  67. }
  68. #endif
  69. void menu_led_custom() {
  70. START_MENU();
  71. BACK_ITEM(MSG_LED_CONTROL);
  72. #if ENABLED(NEOPIXEL2_SEPARATE)
  73. STATIC_ITEM_N(1, MSG_LED_CHANNEL_N, SS_DEFAULT|SS_INVERT);
  74. #endif
  75. EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true);
  76. EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true);
  77. EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds.color.b, 0, 255, leds.update, true);
  78. #if HAS_WHITE_LED
  79. EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds.color.w, 0, 255, leds.update, true);
  80. #endif
  81. #if ENABLED(NEOPIXEL_LED)
  82. EDIT_ITEM(uint8, MSG_LED_BRIGHTNESS, &leds.color.i, 0, 255, leds.update, true);
  83. #endif
  84. #if ENABLED(NEOPIXEL2_SEPARATE)
  85. STATIC_ITEM_N(2, MSG_LED_CHANNEL_N, SS_DEFAULT|SS_INVERT);
  86. EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds2.color.r, 0, 255, leds2.update, true);
  87. EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds2.color.g, 0, 255, leds2.update, true);
  88. EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds2.color.b, 0, 255, leds2.update, true);
  89. #if HAS_WHITE_LED2
  90. EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds2.color.w, 0, 255, leds2.update, true);
  91. #endif
  92. EDIT_ITEM(uint8, MSG_NEO2_BRIGHTNESS, &leds2.color.i, 0, 255, leds2.update, true);
  93. #endif
  94. END_MENU();
  95. }
  96. #endif
  97. #if ENABLED(CASE_LIGHT_MENU)
  98. #include "../../feature/caselight.h"
  99. #define CASELIGHT_TOGGLE_ITEM() EDIT_ITEM(bool, MSG_CASE_LIGHT, (bool*)&caselight.on, caselight.update_enabled)
  100. #if CASELIGHT_USES_BRIGHTNESS
  101. void menu_case_light() {
  102. START_MENU();
  103. BACK_ITEM(MSG_CONFIGURATION);
  104. EDIT_ITEM(percent, MSG_CASE_LIGHT_BRIGHTNESS, &caselight.brightness, 0, 255, caselight.update_brightness, true);
  105. CASELIGHT_TOGGLE_ITEM();
  106. END_MENU();
  107. }
  108. #endif
  109. #endif
  110. void menu_led() {
  111. START_MENU();
  112. BACK_ITEM(MSG_MAIN);
  113. #if ENABLED(LED_CONTROL_MENU)
  114. if (TERN1(PSU_CONTROL, powerManager.psu_on)) {
  115. editable.state = leds.lights_on;
  116. EDIT_ITEM(bool, MSG_LEDS, &editable.state, leds.toggle);
  117. }
  118. #if ENABLED(LED_COLOR_PRESETS)
  119. ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds.set_default);
  120. #endif
  121. #if ENABLED(NEOPIXEL2_SEPARATE)
  122. editable.state = leds2.lights_on;
  123. EDIT_ITEM(bool, MSG_LEDS2, &editable.state, leds2.toggle);
  124. #if ENABLED(NEO2_COLOR_PRESETS)
  125. ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds2.set_default);
  126. #endif
  127. #endif
  128. #if ENABLED(LED_COLOR_PRESETS)
  129. SUBMENU(MSG_LED_PRESETS, menu_led_presets);
  130. #endif
  131. #if ENABLED(NEO2_COLOR_PRESETS)
  132. SUBMENU(MSG_NEO2_PRESETS, menu_leds2_presets);
  133. #endif
  134. SUBMENU(MSG_CUSTOM_LEDS, menu_led_custom);
  135. #endif
  136. //
  137. // Set Case light on/off/brightness
  138. //
  139. #if ENABLED(CASE_LIGHT_MENU)
  140. #if CASELIGHT_USES_BRIGHTNESS
  141. if (caselight.has_brightness())
  142. SUBMENU(MSG_CASE_LIGHT, menu_case_light);
  143. else
  144. #endif
  145. CASELIGHT_TOGGLE_ITEM();
  146. #endif
  147. END_MENU();
  148. }
  149. #endif // HAS_MARLINUI_MENU && LED_CONTROL_MENU