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 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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_MARLINUI_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_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_both(M, MenuItemBase::itemIndex); }); \
  79. ACTION_ITEM_N_f(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_f(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_f(ui.get_preheat_label(m), MSG_PREHEAT_M, []{ _preheat_both(editable.int8, 0); });
  95. ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M_END, do_preheat_end_m);
  96. #else
  97. ACTION_ITEM_f(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_f(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_f(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.cooldown();
  117. ui.return_to_status();
  118. }
  119. #endif // HAS_TEMP_HOTEND || HAS_HEATED_BED
  120. void menu_temperature() {
  121. #if HAS_TEMP_HOTEND || HAS_HEATED_BED
  122. bool has_heat = false;
  123. #if HAS_TEMP_HOTEND
  124. HOTEND_LOOP() if (thermalManager.degTargetHotend(HOTEND_INDEX)) { has_heat = true; break; }
  125. #endif
  126. #endif
  127. #if HAS_COOLER
  128. if (thermalManager.temp_cooler.target == 0) thermalManager.temp_cooler.target = COOLER_DEFAULT_TEMP;
  129. #endif
  130. START_MENU();
  131. BACK_ITEM(MSG_MAIN);
  132. //
  133. // Nozzle:
  134. // Nozzle [1-5]:
  135. //
  136. #if HOTENDS == 1
  137. editable.celsius = thermalManager.temp_hotend[0].target;
  138. EDIT_ITEM_FAST(int3, MSG_NOZZLE, &editable.celsius, 0, thermalManager.hotend_max_target(0), []{ thermalManager.setTargetHotend(editable.celsius, 0); });
  139. #elif HAS_MULTI_HOTEND
  140. HOTEND_LOOP() {
  141. editable.celsius = thermalManager.temp_hotend[e].target;
  142. EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &editable.celsius, 0, thermalManager.hotend_max_target(e), []{ thermalManager.setTargetHotend(editable.celsius, MenuItemBase::itemIndex); });
  143. }
  144. #endif
  145. #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
  146. LOOP_S_L_N(e, 1, EXTRUDERS)
  147. EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_STANDBY, &thermalManager.singlenozzle_temp[e], 0, thermalManager.hotend_max_target(0));
  148. #endif
  149. //
  150. // Bed:
  151. //
  152. #if HAS_HEATED_BED
  153. EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAX_TARGET, thermalManager.start_watching_bed);
  154. #endif
  155. //
  156. // Chamber:
  157. //
  158. #if HAS_HEATED_CHAMBER
  159. EDIT_ITEM_FAST(int3, MSG_CHAMBER, &thermalManager.temp_chamber.target, 0, CHAMBER_MAX_TARGET, thermalManager.start_watching_chamber);
  160. #endif
  161. //
  162. // Cooler:
  163. //
  164. #if HAS_COOLER
  165. bool cstate = cooler.enabled;
  166. EDIT_ITEM(bool, MSG_COOLER_TOGGLE, &cstate, cooler.toggle);
  167. EDIT_ITEM_FAST(int3, MSG_COOLER, &thermalManager.temp_cooler.target, COOLER_MIN_TARGET, COOLER_MAX_TARGET, thermalManager.start_watching_cooler);
  168. #endif
  169. //
  170. // Flow Meter Safety Shutdown:
  171. //
  172. #if ENABLED(FLOWMETER_SAFETY)
  173. bool fstate = cooler.flowsafety_enabled;
  174. EDIT_ITEM(bool, MSG_FLOWMETER_SAFETY, &fstate, cooler.flowsafety_toggle);
  175. #endif
  176. //
  177. // Fan Speed:
  178. //
  179. #if HAS_FAN
  180. DEFINE_SINGLENOZZLE_ITEM();
  181. #if HAS_FAN0
  182. _FAN_EDIT_ITEMS(0,FIRST_FAN_SPEED);
  183. #endif
  184. #if HAS_FAN1 && REDUNDANT_PART_COOLING_FAN != 1
  185. FAN_EDIT_ITEMS(1);
  186. #elif SNFAN(1)
  187. singlenozzle_item(1);
  188. #endif
  189. #if HAS_FAN2 && REDUNDANT_PART_COOLING_FAN != 2
  190. FAN_EDIT_ITEMS(2);
  191. #elif SNFAN(2)
  192. singlenozzle_item(2);
  193. #endif
  194. #if HAS_FAN3 && REDUNDANT_PART_COOLING_FAN != 3
  195. FAN_EDIT_ITEMS(3);
  196. #elif SNFAN(3)
  197. singlenozzle_item(3);
  198. #endif
  199. #if HAS_FAN4 && REDUNDANT_PART_COOLING_FAN != 4
  200. FAN_EDIT_ITEMS(4);
  201. #elif SNFAN(4)
  202. singlenozzle_item(4);
  203. #endif
  204. #if HAS_FAN5 && REDUNDANT_PART_COOLING_FAN != 5
  205. FAN_EDIT_ITEMS(5);
  206. #elif SNFAN(5)
  207. singlenozzle_item(5);
  208. #endif
  209. #if HAS_FAN6 && REDUNDANT_PART_COOLING_FAN != 6
  210. FAN_EDIT_ITEMS(6);
  211. #elif SNFAN(6)
  212. singlenozzle_item(6);
  213. #endif
  214. #if HAS_FAN7 && REDUNDANT_PART_COOLING_FAN != 7
  215. FAN_EDIT_ITEMS(7);
  216. #elif SNFAN(7)
  217. singlenozzle_item(7);
  218. #endif
  219. #endif // HAS_FAN
  220. #if HAS_PREHEAT
  221. //
  222. // Preheat for all Materials
  223. //
  224. LOOP_L_N(m, PREHEAT_COUNT) {
  225. editable.int8 = m;
  226. #if HAS_MULTI_HOTEND || HAS_HEATED_BED
  227. SUBMENU_f(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m);
  228. #elif HAS_HOTEND
  229. ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m);
  230. #endif
  231. }
  232. #endif
  233. #if HAS_TEMP_HOTEND || HAS_HEATED_BED
  234. //
  235. // Cooldown
  236. //
  237. if (TERN0(HAS_HEATED_BED, thermalManager.degTargetBed())) has_heat = true;
  238. if (has_heat) ACTION_ITEM(MSG_COOLDOWN, lcd_cooldown);
  239. #endif
  240. END_MENU();
  241. }
  242. #if ENABLED(PREHEAT_SHORTCUT_MENU_ITEM)
  243. void menu_preheat_only() {
  244. START_MENU();
  245. BACK_ITEM(MSG_MAIN);
  246. LOOP_L_N(m, PREHEAT_COUNT) {
  247. editable.int8 = m;
  248. #if HAS_MULTI_HOTEND || HAS_HEATED_BED
  249. SUBMENU_f(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m);
  250. #else
  251. ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m);
  252. #endif
  253. }
  254. END_MENU();
  255. }
  256. #endif
  257. #endif // HAS_MARLINUI_MENU && HAS_TEMPERATURE