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

menu_temperature.cpp 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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 EITHER(HAS_COOLER, LASER_COOLANT_FLOW_METER)
  33. #include "../../feature/cooler.h"
  34. #endif
  35. #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
  36. #include "../../module/tool_change.h"
  37. #endif
  38. //
  39. // "Temperature" submenu items
  40. //
  41. void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t indb) {
  42. UNUSED(e); UNUSED(indh); UNUSED(indb);
  43. #if HAS_HOTEND
  44. if (indh >= 0 && ui.material_preset[indh].hotend_temp > 0)
  45. setTargetHotend(_MIN(thermalManager.hotend_max_target(e), ui.material_preset[indh].hotend_temp), e);
  46. #endif
  47. #if HAS_HEATED_BED
  48. if (indb >= 0 && ui.material_preset[indb].bed_temp > 0) setTargetBed(ui.material_preset[indb].bed_temp);
  49. #endif
  50. #if HAS_FAN
  51. if (indh >= 0) {
  52. const uint8_t fan_index = active_extruder < (FAN_COUNT) ? active_extruder : 0;
  53. if (true
  54. #if REDUNDANT_PART_COOLING_FAN
  55. && fan_index != REDUNDANT_PART_COOLING_FAN
  56. #endif
  57. ) set_fan_speed(fan_index, ui.material_preset[indh].fan_speed);
  58. }
  59. #endif
  60. ui.return_to_status();
  61. }
  62. #if HAS_PREHEAT
  63. #if HAS_TEMP_HOTEND
  64. inline void _preheat_end(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, -1); }
  65. void do_preheat_end_m() { _preheat_end(editable.int8, 0); }
  66. #endif
  67. #if HAS_HEATED_BED
  68. inline void _preheat_bed(const uint8_t m) { thermalManager.lcd_preheat(0, -1, m); }
  69. #endif
  70. #if HAS_COOLER
  71. inline void _precool_laser(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, -1); }
  72. void do_precool_laser_m() { _precool_laser(editable.int8, thermalManager.temp_cooler.target); }
  73. #endif
  74. #if HAS_TEMP_HOTEND && HAS_HEATED_BED
  75. inline void _preheat_both(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, m); }
  76. // Indexed "Preheat ABC" and "Heat Bed" items
  77. #define PREHEAT_ITEMS(M,E) do{ \
  78. ACTION_ITEM_N_S(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_both(M, MenuItemBase::itemIndex); }); \
  79. ACTION_ITEM_N_S(E, ui.get_preheat_label(M), MSG_PREHEAT_M_END_E, []{ _preheat_end(M, MenuItemBase::itemIndex); }); \
  80. }while(0)
  81. #elif HAS_MULTI_HOTEND
  82. // No heated bed, so just indexed "Preheat ABC" items
  83. #define PREHEAT_ITEMS(M,E) ACTION_ITEM_N_S(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_end(M, MenuItemBase::itemIndex); })
  84. #endif
  85. #if HAS_MULTI_HOTEND || HAS_HEATED_BED
  86. // Set editable.int8 to the Material index before entering this menu
  87. // because MenuItemBase::itemIndex will be re-used by PREHEAT_ITEMS
  88. void menu_preheat_m() {
  89. const uint8_t m = editable.int8; // Don't re-use 'editable' in this menu
  90. START_MENU();
  91. BACK_ITEM(MSG_TEMPERATURE);
  92. #if HOTENDS == 1
  93. #if HAS_HEATED_BED
  94. ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, []{ _preheat_both(editable.int8, 0); });
  95. ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M_END, do_preheat_end_m);
  96. #else
  97. ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m);
  98. #endif
  99. #elif HAS_MULTI_HOTEND
  100. HOTEND_LOOP() PREHEAT_ITEMS(editable.int8, e);
  101. ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M_ALL, []() {
  102. const celsius_t t = ui.material_preset[editable.int8].hotend_temp;
  103. HOTEND_LOOP() thermalManager.setTargetHotend(t, e);
  104. TERN(HAS_HEATED_BED, _preheat_bed(editable.int8), ui.return_to_status());
  105. });
  106. #endif
  107. #if HAS_HEATED_BED
  108. ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M_BEDONLY, []{ _preheat_bed(editable.int8); });
  109. #endif
  110. END_MENU();
  111. }
  112. #endif // HAS_MULTI_HOTEND || HAS_HEATED_BED
  113. #endif // HAS_PREHEAT
  114. #if HAS_TEMP_HOTEND || HAS_HEATED_BED
  115. void lcd_cooldown() {
  116. thermalManager.zero_fan_speeds();
  117. thermalManager.disable_all_heaters();
  118. ui.return_to_status();
  119. }
  120. #endif // HAS_TEMP_HOTEND || HAS_HEATED_BED
  121. void menu_temperature() {
  122. #if HAS_TEMP_HOTEND || HAS_HEATED_BED
  123. bool has_heat = false;
  124. #if HAS_TEMP_HOTEND
  125. HOTEND_LOOP() if (thermalManager.degTargetHotend(HOTEND_INDEX)) { has_heat = true; break; }
  126. #endif
  127. #endif
  128. #if HAS_COOLER
  129. if (thermalManager.temp_cooler.target == 0) thermalManager.temp_cooler.target = COOLER_DEFAULT_TEMP;
  130. #endif
  131. START_MENU();
  132. BACK_ITEM(MSG_MAIN);
  133. //
  134. // Nozzle:
  135. // Nozzle [1-5]:
  136. //
  137. #if HOTENDS == 1
  138. editable.celsius = thermalManager.temp_hotend[0].target;
  139. EDIT_ITEM_FAST(int3, MSG_NOZZLE, &editable.celsius, 0, thermalManager.hotend_max_target(0), []{ thermalManager.setTargetHotend(editable.celsius, 0); });
  140. #elif HAS_MULTI_HOTEND
  141. HOTEND_LOOP() {
  142. editable.celsius = thermalManager.temp_hotend[e].target;
  143. EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &editable.celsius, 0, thermalManager.hotend_max_target(e), []{ thermalManager.setTargetHotend(editable.celsius, MenuItemBase::itemIndex); });
  144. }
  145. #endif
  146. #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
  147. LOOP_S_L_N(e, 1, EXTRUDERS)
  148. EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_STANDBY, &thermalManager.singlenozzle_temp[e], 0, thermalManager.hotend_max_target(0));
  149. #endif
  150. //
  151. // Bed:
  152. //
  153. #if HAS_HEATED_BED
  154. EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAX_TARGET, thermalManager.start_watching_bed);
  155. #endif
  156. //
  157. // Chamber:
  158. //
  159. #if HAS_HEATED_CHAMBER
  160. EDIT_ITEM_FAST(int3, MSG_CHAMBER, &thermalManager.temp_chamber.target, 0, CHAMBER_MAX_TARGET, thermalManager.start_watching_chamber);
  161. #endif
  162. //
  163. // Cooler:
  164. //
  165. #if HAS_COOLER
  166. bool cstate = cooler.enabled;
  167. EDIT_ITEM(bool, MSG_COOLER_TOGGLE, &cstate, cooler.toggle);
  168. EDIT_ITEM_FAST(int3, MSG_COOLER, &thermalManager.temp_cooler.target, COOLER_MIN_TARGET, COOLER_MAX_TARGET, thermalManager.start_watching_cooler);
  169. #endif
  170. //
  171. // Flow Meter Safety Shutdown:
  172. //
  173. #if ENABLED(FLOWMETER_SAFETY)
  174. bool fstate = cooler.flowsafety_enabled;
  175. EDIT_ITEM(bool, MSG_FLOWMETER_SAFETY, &fstate, cooler.flowsafety_toggle);
  176. #endif
  177. //
  178. // Fan Speed:
  179. //
  180. #if HAS_FAN
  181. DEFINE_SINGLENOZZLE_ITEM();
  182. #if HAS_FAN0
  183. _FAN_EDIT_ITEMS(0,FIRST_FAN_SPEED);
  184. #endif
  185. #if HAS_FAN1 && REDUNDANT_PART_COOLING_FAN != 1
  186. FAN_EDIT_ITEMS(1);
  187. #elif SNFAN(1)
  188. singlenozzle_item(1);
  189. #endif
  190. #if HAS_FAN2 && REDUNDANT_PART_COOLING_FAN != 2
  191. FAN_EDIT_ITEMS(2);
  192. #elif SNFAN(2)
  193. singlenozzle_item(2);
  194. #endif
  195. #if HAS_FAN3 && REDUNDANT_PART_COOLING_FAN != 3
  196. FAN_EDIT_ITEMS(3);
  197. #elif SNFAN(3)
  198. singlenozzle_item(3);
  199. #endif
  200. #if HAS_FAN4 && REDUNDANT_PART_COOLING_FAN != 4
  201. FAN_EDIT_ITEMS(4);
  202. #elif SNFAN(4)
  203. singlenozzle_item(4);
  204. #endif
  205. #if HAS_FAN5 && REDUNDANT_PART_COOLING_FAN != 5
  206. FAN_EDIT_ITEMS(5);
  207. #elif SNFAN(5)
  208. singlenozzle_item(5);
  209. #endif
  210. #if HAS_FAN6 && REDUNDANT_PART_COOLING_FAN != 6
  211. FAN_EDIT_ITEMS(6);
  212. #elif SNFAN(6)
  213. singlenozzle_item(6);
  214. #endif
  215. #if HAS_FAN7 && REDUNDANT_PART_COOLING_FAN != 7
  216. FAN_EDIT_ITEMS(7);
  217. #elif SNFAN(7)
  218. singlenozzle_item(7);
  219. #endif
  220. #endif // HAS_FAN
  221. #if HAS_PREHEAT
  222. //
  223. // Preheat for all Materials
  224. //
  225. LOOP_L_N(m, PREHEAT_COUNT) {
  226. editable.int8 = m;
  227. #if HAS_MULTI_HOTEND || HAS_HEATED_BED
  228. SUBMENU_S(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m);
  229. #elif HAS_HOTEND
  230. ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m);
  231. #endif
  232. }
  233. #endif
  234. #if HAS_TEMP_HOTEND || HAS_HEATED_BED
  235. //
  236. // Cooldown
  237. //
  238. if (TERN0(HAS_HEATED_BED, thermalManager.degTargetBed())) has_heat = true;
  239. if (has_heat) ACTION_ITEM(MSG_COOLDOWN, lcd_cooldown);
  240. #endif
  241. END_MENU();
  242. }
  243. #if ENABLED(PREHEAT_SHORTCUT_MENU_ITEM)
  244. void menu_preheat_only() {
  245. START_MENU();
  246. BACK_ITEM(MSG_MAIN);
  247. LOOP_L_N(m, PREHEAT_COUNT) {
  248. editable.int8 = m;
  249. #if HAS_MULTI_HOTEND || HAS_HEATED_BED
  250. SUBMENU_S(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m);
  251. #else
  252. ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m);
  253. #endif
  254. }
  255. END_MENU();
  256. }
  257. #endif
  258. #endif // HAS_LCD_MENU && HAS_TEMPERATURE