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_temperature.cpp 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. // Temperature Menu
  24. //
  25. #include "../../inc/MarlinConfig.h"
  26. #if HAS_LCD_MENU && HAS_TEMPERATURE
  27. #include "menu_item.h"
  28. #include "../../module/temperature.h"
  29. #if HAS_FAN || ENABLED(SINGLENOZZLE)
  30. #include "../../module/motion.h"
  31. #endif
  32. #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
  33. #include "../../module/tool_change.h"
  34. #endif
  35. //
  36. // "Temperature" submenu items
  37. //
  38. void Temperature::lcd_preheat(const int16_t e, const int8_t indh, const int8_t indb) {
  39. UNUSED(e); UNUSED(indh); UNUSED(indb);
  40. #if HAS_HOTEND
  41. if (indh >= 0 && ui.material_preset[indh].hotend_temp > 0)
  42. setTargetHotend(_MIN(thermalManager.heater_maxtemp[e] - HOTEND_OVERSHOOT, ui.material_preset[indh].hotend_temp), e);
  43. #endif
  44. #if HAS_HEATED_BED
  45. if (indb >= 0 && ui.material_preset[indb].bed_temp > 0) setTargetBed(ui.material_preset[indb].bed_temp);
  46. #endif
  47. #if HAS_FAN
  48. if (indh >= 0)
  49. set_fan_speed(active_extruder < (FAN_COUNT) ? active_extruder : 0, ui.material_preset[indh].fan_speed);
  50. #endif
  51. ui.return_to_status();
  52. }
  53. #if PREHEAT_COUNT
  54. #if HAS_TEMP_HOTEND
  55. inline void _preheat_end(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, -1); }
  56. void do_preheat_end_m() { _preheat_end(editable.int8, 0); }
  57. #endif
  58. #if HAS_HEATED_BED
  59. inline void _preheat_bed(const uint8_t m) { thermalManager.lcd_preheat(-1, -1, m); }
  60. #endif
  61. #if HAS_TEMP_HOTEND && HAS_HEATED_BED
  62. inline void _preheat_both(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, m); }
  63. // Indexed "Preheat ABC" and "Heat Bed" items
  64. #define PREHEAT_ITEMS(M,E) do{ \
  65. ACTION_ITEM_N_S(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_both(M, MenuItemBase::itemIndex); }); \
  66. ACTION_ITEM_N_S(E, ui.get_preheat_label(M), MSG_PREHEAT_M_END_E, []{ _preheat_end(M, MenuItemBase::itemIndex); }); \
  67. }while(0)
  68. #elif HAS_MULTI_HOTEND
  69. // No heated bed, so just indexed "Preheat ABC" items
  70. #define PREHEAT_ITEMS(M,E) ACTION_ITEM_N_S(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_end(M, MenuItemBase::itemIndex); })
  71. #endif
  72. #if HAS_MULTI_HOTEND || HAS_HEATED_BED
  73. // Set editable.int8 to the Material index before entering this menu
  74. // because MenuItemBase::itemIndex will be re-used by PREHEAT_ITEMS
  75. void menu_preheat_m() {
  76. const uint8_t m = editable.int8; // Don't re-use 'editable' in this menu
  77. START_MENU();
  78. BACK_ITEM(MSG_TEMPERATURE);
  79. #if HOTENDS == 1
  80. #if HAS_HEATED_BED
  81. ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, []{ _preheat_both(editable.int8, 0); });
  82. ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M_END, do_preheat_end_m);
  83. #else
  84. ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m);
  85. #endif
  86. #elif HAS_MULTI_HOTEND
  87. HOTEND_LOOP() PREHEAT_ITEMS(editable.int8, e);
  88. ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M_ALL, []() {
  89. HOTEND_LOOP() thermalManager.setTargetHotend(ui.material_preset[editable.int8].hotend_temp, e);
  90. TERN(HAS_HEATED_BED, _preheat_bed(editable.int8), ui.return_to_status());
  91. });
  92. #endif
  93. #if HAS_HEATED_BED
  94. ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M_BEDONLY, []{ _preheat_bed(editable.int8); });
  95. #endif
  96. END_MENU();
  97. }
  98. #endif // HAS_MULTI_HOTEND || HAS_HEATED_BED
  99. #endif // PREHEAT_COUNT
  100. #if HAS_TEMP_HOTEND || HAS_HEATED_BED
  101. void lcd_cooldown() {
  102. thermalManager.zero_fan_speeds();
  103. thermalManager.disable_all_heaters();
  104. ui.return_to_status();
  105. }
  106. #endif // HAS_TEMP_HOTEND || HAS_HEATED_BED
  107. void menu_temperature() {
  108. #if HAS_TEMP_HOTEND || HAS_HEATED_BED
  109. bool has_heat = false;
  110. #if HAS_TEMP_HOTEND
  111. HOTEND_LOOP() if (thermalManager.temp_hotend[HOTEND_INDEX].target) { has_heat = true; break; }
  112. #endif
  113. #endif
  114. START_MENU();
  115. BACK_ITEM(MSG_MAIN);
  116. //
  117. // Nozzle:
  118. // Nozzle [1-5]:
  119. //
  120. #if HOTENDS == 1
  121. EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, HEATER_0_MAXTEMP - (HOTEND_OVERSHOOT), []{ thermalManager.start_watching_hotend(0); });
  122. #elif HAS_MULTI_HOTEND
  123. HOTEND_LOOP()
  124. EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, thermalManager.heater_maxtemp[e] - (HOTEND_OVERSHOOT), []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); });
  125. #endif
  126. #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
  127. LOOP_S_L_N(e, 1, EXTRUDERS)
  128. EDIT_ITEM_FAST_N(uint16_3, e, MSG_NOZZLE_STANDBY, &thermalManager.singlenozzle_temp[e], 0, thermalManager.heater_maxtemp[0] - (HOTEND_OVERSHOOT));
  129. #endif
  130. //
  131. // Bed:
  132. //
  133. #if HAS_HEATED_BED
  134. EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAX_TARGET, thermalManager.start_watching_bed);
  135. #endif
  136. //
  137. // Chamber:
  138. //
  139. #if HAS_HEATED_CHAMBER
  140. EDIT_ITEM_FAST(int3, MSG_CHAMBER, &thermalManager.temp_chamber.target, 0, CHAMBER_MAXTEMP - 10, thermalManager.start_watching_chamber);
  141. #endif
  142. //
  143. // Fan Speed:
  144. //
  145. #if HAS_FAN
  146. DEFINE_SINGLENOZZLE_ITEM();
  147. #if HAS_FAN0
  148. _FAN_EDIT_ITEMS(0,FIRST_FAN_SPEED);
  149. #endif
  150. #if HAS_FAN1
  151. FAN_EDIT_ITEMS(1);
  152. #elif SNFAN(1)
  153. singlenozzle_item(1);
  154. #endif
  155. #if HAS_FAN2
  156. FAN_EDIT_ITEMS(2);
  157. #elif SNFAN(2)
  158. singlenozzle_item(2);
  159. #endif
  160. #if HAS_FAN3
  161. FAN_EDIT_ITEMS(3);
  162. #elif SNFAN(3)
  163. singlenozzle_item(3);
  164. #endif
  165. #if HAS_FAN4
  166. FAN_EDIT_ITEMS(4);
  167. #elif SNFAN(4)
  168. singlenozzle_item(4);
  169. #endif
  170. #if HAS_FAN5
  171. FAN_EDIT_ITEMS(5);
  172. #elif SNFAN(5)
  173. singlenozzle_item(5);
  174. #endif
  175. #if HAS_FAN6
  176. FAN_EDIT_ITEMS(6);
  177. #elif SNFAN(6)
  178. singlenozzle_item(6);
  179. #endif
  180. #if HAS_FAN7
  181. FAN_EDIT_ITEMS(7);
  182. #elif SNFAN(7)
  183. singlenozzle_item(7);
  184. #endif
  185. #endif // HAS_FAN
  186. #if PREHEAT_COUNT
  187. //
  188. // Preheat for all Materials
  189. //
  190. LOOP_L_N(m, PREHEAT_COUNT) {
  191. editable.int8 = m;
  192. #if HOTENDS > 1 || HAS_HEATED_BED
  193. SUBMENU_S(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m);
  194. #else
  195. ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m);
  196. #endif
  197. }
  198. #endif
  199. #if HAS_TEMP_HOTEND || HAS_HEATED_BED
  200. //
  201. // Cooldown
  202. //
  203. if (TERN0(HAS_HEATED_BED, thermalManager.temp_bed.target)) has_heat = true;
  204. if (has_heat) ACTION_ITEM(MSG_COOLDOWN, lcd_cooldown);
  205. #endif
  206. END_MENU();
  207. }
  208. #if ENABLED(PREHEAT_SHORTCUT_MENU_ITEM)
  209. void menu_preheat_only() {
  210. START_MENU();
  211. BACK_ITEM(MSG_MAIN);
  212. LOOP_L_N(m, PREHEAT_COUNT) {
  213. editable.int8 = m;
  214. #if HOTENDS > 1 || HAS_HEATED_BED
  215. SUBMENU_S(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m);
  216. #else
  217. ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m);
  218. #endif
  219. }
  220. END_MENU();
  221. }
  222. #endif
  223. #endif // HAS_LCD_MENU && HAS_TEMPERATURE