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

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