My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

menu_led.cpp 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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_LCD_MENU && EITHER(LED_CONTROL_MENU, CASE_LIGHT_MENU)
  27. #include "menu_item.h"
  28. #if ENABLED(LED_CONTROL_MENU)
  29. #include "../../feature/leds/leds.h"
  30. #if ENABLED(LED_COLOR_PRESETS)
  31. void menu_led_presets() {
  32. START_MENU();
  33. #if LCD_HEIGHT > 2
  34. STATIC_ITEM(MSG_LED_PRESETS, SS_DEFAULT|SS_INVERT);
  35. #endif
  36. BACK_ITEM(MSG_LED_CONTROL);
  37. ACTION_ITEM(MSG_SET_LEDS_WHITE, leds.set_white);
  38. ACTION_ITEM(MSG_SET_LEDS_RED, leds.set_red);
  39. ACTION_ITEM(MSG_SET_LEDS_ORANGE, leds.set_orange);
  40. ACTION_ITEM(MSG_SET_LEDS_YELLOW, leds.set_yellow);
  41. ACTION_ITEM(MSG_SET_LEDS_GREEN, leds.set_green);
  42. ACTION_ITEM(MSG_SET_LEDS_BLUE, leds.set_blue);
  43. ACTION_ITEM(MSG_SET_LEDS_INDIGO, leds.set_indigo);
  44. ACTION_ITEM(MSG_SET_LEDS_VIOLET, leds.set_violet);
  45. END_MENU();
  46. }
  47. #endif
  48. #if ENABLED(NEO2_COLOR_PRESETS)
  49. void menu_leds2_presets() {
  50. START_MENU();
  51. #if LCD_HEIGHT > 2
  52. STATIC_ITEM(MSG_NEO2_PRESETS, SS_DEFAULT|SS_INVERT);
  53. #endif
  54. BACK_ITEM(MSG_LED_CONTROL);
  55. ACTION_ITEM(MSG_SET_LEDS_WHITE, leds2.set_white);
  56. ACTION_ITEM(MSG_SET_LEDS_RED, leds2.set_red);
  57. ACTION_ITEM(MSG_SET_LEDS_ORANGE, leds2.set_orange);
  58. ACTION_ITEM(MSG_SET_LEDS_YELLOW, leds2.set_yellow);
  59. ACTION_ITEM(MSG_SET_LEDS_GREEN, leds2.set_green);
  60. ACTION_ITEM(MSG_SET_LEDS_BLUE, leds2.set_blue);
  61. ACTION_ITEM(MSG_SET_LEDS_INDIGO, leds2.set_indigo);
  62. ACTION_ITEM(MSG_SET_LEDS_VIOLET, leds2.set_violet);
  63. END_MENU();
  64. }
  65. #endif
  66. void menu_led_custom() {
  67. START_MENU();
  68. BACK_ITEM(MSG_LED_CONTROL);
  69. #if ENABLED(NEOPIXEL2_SEPARATE)
  70. STATIC_ITEM_N(MSG_LED_CHANNEL_N, 1, SS_DEFAULT|SS_INVERT);
  71. #endif
  72. EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true);
  73. EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true);
  74. EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds.color.b, 0, 255, leds.update, true);
  75. #if EITHER(RGBW_LED, NEOPIXEL_LED)
  76. EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds.color.w, 0, 255, leds.update, true);
  77. #if ENABLED(NEOPIXEL_LED)
  78. EDIT_ITEM(uint8, MSG_LED_BRIGHTNESS, &leds.color.i, 0, 255, leds.update, true);
  79. #endif
  80. #endif
  81. #if ENABLED(NEOPIXEL2_SEPARATE)
  82. STATIC_ITEM_N(MSG_LED_CHANNEL_N, 2, SS_DEFAULT|SS_INVERT);
  83. EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds2.color.r, 0, 255, leds2.update, true);
  84. EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds2.color.g, 0, 255, leds2.update, true);
  85. EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds2.color.b, 0, 255, leds2.update, true);
  86. EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds2.color.w, 0, 255, leds2.update, true);
  87. EDIT_ITEM(uint8, MSG_NEO2_BRIGHTNESS, &leds2.color.i, 0, 255, leds2.update, true);
  88. #endif
  89. END_MENU();
  90. }
  91. #endif
  92. #if ENABLED(CASE_LIGHT_MENU)
  93. #include "../../feature/caselight.h"
  94. #if CASELIGHT_USES_BRIGHTNESS
  95. void menu_case_light() {
  96. START_MENU();
  97. BACK_ITEM(MSG_CONFIGURATION);
  98. EDIT_ITEM(percent, MSG_CASE_LIGHT_BRIGHTNESS, &caselight.brightness, 0, 255, caselight.update_brightness, true);
  99. EDIT_ITEM(bool, MSG_CASE_LIGHT, (bool*)&caselight.on, caselight.update_enabled);
  100. END_MENU();
  101. }
  102. #endif
  103. #endif
  104. void menu_led() {
  105. START_MENU();
  106. BACK_ITEM(MSG_MAIN);
  107. #if ENABLED(LED_CONTROL_MENU)
  108. editable.state = leds.lights_on;
  109. EDIT_ITEM(bool, MSG_LEDS, &editable.state, leds.toggle);
  110. ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds.set_default);
  111. #if ENABLED(NEOPIXEL2_SEPARATE)
  112. editable.state = leds2.lights_on;
  113. EDIT_ITEM(bool, MSG_LEDS2, &editable.state, leds2.toggle);
  114. ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds2.set_default);
  115. #endif
  116. #if ENABLED(LED_COLOR_PRESETS)
  117. SUBMENU(MSG_LED_PRESETS, menu_led_presets);
  118. #endif
  119. #if ENABLED(NEO2_COLOR_PRESETS)
  120. SUBMENU(MSG_NEO2_PRESETS, menu_leds2_presets);
  121. #endif
  122. SUBMENU(MSG_CUSTOM_LEDS, menu_led_custom);
  123. #endif
  124. //
  125. // Set Case light on/off/brightness
  126. //
  127. #if ENABLED(CASE_LIGHT_MENU)
  128. #if DISABLED(CASE_LIGHT_NO_BRIGHTNESS)
  129. if (TERN1(CASE_LIGHT_USE_NEOPIXEL, PWM_PIN(CASE_LIGHT_PIN)))
  130. SUBMENU(MSG_CASE_LIGHT, menu_case_light);
  131. else
  132. #endif
  133. EDIT_ITEM(bool, MSG_CASE_LIGHT, (bool*)&caselight.on, caselight.update_enabled);
  134. #endif
  135. END_MENU();
  136. }
  137. #endif // HAS_LCD_MENU && LED_CONTROL_MENU