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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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 HAS_TEMP_HOTEND
  61. inline void _preheat_end(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, -1); }
  62. #if HAS_HEATED_BED
  63. inline void _preheat_both(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, m); }
  64. #endif
  65. #endif
  66. #if HAS_HEATED_BED
  67. inline void _preheat_bed(const uint8_t m) { thermalManager.lcd_preheat(-1, -1, m); }
  68. #endif
  69. #if HAS_TEMP_HOTEND || HAS_HEATED_BED
  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_P(E, msg_preheat_h[M], []{ _preheat_both(M, MenuItemBase::itemIndex); }); \
  74. ACTION_ITEM_N_P(E, msg_preheat_end_e[M], []{ _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_P(E, msg_preheat_h[M], []{ _preheat_end(M, MenuItemBase::itemIndex); })
  79. #endif
  80. void menu_preheat_m(const uint8_t m) {
  81. #if HOTENDS == 1
  82. PGM_P msg_preheat[] = ARRAY_N(PREHEAT_COUNT, GET_TEXT(MSG_PREHEAT_1), GET_TEXT(MSG_PREHEAT_2), GET_TEXT(MSG_PREHEAT_3), GET_TEXT(MSG_PREHEAT_4), GET_TEXT(MSG_PREHEAT_5));
  83. PGM_P msg_preheat_end[] = ARRAY_N(PREHEAT_COUNT, GET_TEXT(MSG_PREHEAT_1_END), GET_TEXT(MSG_PREHEAT_2_END), GET_TEXT(MSG_PREHEAT_3_END), GET_TEXT(MSG_PREHEAT_4_END), GET_TEXT(MSG_PREHEAT_5_END));
  84. #elif HAS_MULTI_HOTEND
  85. PGM_P msg_preheat_all[] = ARRAY_N(PREHEAT_COUNT, GET_TEXT(MSG_PREHEAT_1_ALL), GET_TEXT(MSG_PREHEAT_2_ALL), GET_TEXT(MSG_PREHEAT_3_ALL), GET_TEXT(MSG_PREHEAT_4_ALL), GET_TEXT(MSG_PREHEAT_5_ALL));
  86. #endif
  87. #if HAS_TEMP_HOTEND && HAS_HEATED_BED && HAS_MULTI_HOTEND
  88. PGM_P msg_preheat_end_e[] = ARRAY_N(PREHEAT_COUNT, GET_TEXT(MSG_PREHEAT_1_END_E), GET_TEXT(MSG_PREHEAT_2_END_E), GET_TEXT(MSG_PREHEAT_3_END_E), GET_TEXT(MSG_PREHEAT_4_END_E), GET_TEXT(MSG_PREHEAT_5_END_E));
  89. #endif
  90. #if HAS_MULTI_HOTEND
  91. PGM_P msg_preheat_h[] = ARRAY_N(PREHEAT_COUNT, GET_TEXT(MSG_PREHEAT_1_H), GET_TEXT(MSG_PREHEAT_2_H), GET_TEXT(MSG_PREHEAT_3_H), GET_TEXT(MSG_PREHEAT_4_H), GET_TEXT(MSG_PREHEAT_5_H));
  92. #endif
  93. MenuItemBase::itemIndex = m;
  94. START_MENU();
  95. BACK_ITEM(MSG_TEMPERATURE);
  96. #if HOTENDS == 1
  97. #if HAS_HEATED_BED
  98. ACTION_ITEM_P(msg_preheat[m], []{ _preheat_both(MenuItemBase::itemIndex, 0); });
  99. ACTION_ITEM_P(msg_preheat_end[m], []{ _preheat_end(MenuItemBase::itemIndex, 0); });
  100. #else
  101. ACTION_ITEM_P(msg_preheat[m], []{ _preheat_end(MenuItemBase::itemIndex, 0); });
  102. #endif
  103. #elif HAS_MULTI_HOTEND
  104. LOOP_S_L_N(n, 0, HOTENDS) PREHEAT_ITEMS(MenuItemBase::itemIndex, n);
  105. ACTION_ITEM_P(msg_preheat_all[m], []() {
  106. TERN_(HAS_HEATED_BED, _preheat_bed(MenuItemBase::itemIndex));
  107. HOTEND_LOOP() thermalManager.setTargetHotend(ui.material_preset[MenuItemBase::itemIndex].hotend_temp, e);
  108. });
  109. #endif
  110. #if HAS_HEATED_BED
  111. PGM_P msg_preheat_bed[] = ARRAY_N(PREHEAT_COUNT, GET_TEXT(MSG_PREHEAT_1_BEDONLY), GET_TEXT(MSG_PREHEAT_2_BEDONLY), GET_TEXT(MSG_PREHEAT_3_BEDONLY), GET_TEXT(MSG_PREHEAT_4_BEDONLY), GET_TEXT(MSG_PREHEAT_5_BEDONLY));
  112. ACTION_ITEM_P(msg_preheat_bed[m], []{ _preheat_bed(MenuItemBase::itemIndex); });
  113. #endif
  114. END_MENU();
  115. }
  116. void menu_preheat_m1() { menu_preheat_m(0); }
  117. void menu_preheat_m2() { menu_preheat_m(1); }
  118. #if PREHEAT_COUNT >= 3
  119. void menu_preheat_m3() { menu_preheat_m(2); }
  120. #if PREHEAT_COUNT >= 4
  121. void menu_preheat_m4() { menu_preheat_m(3); }
  122. #if PREHEAT_COUNT >= 5
  123. void menu_preheat_m5() { menu_preheat_m(4); }
  124. #endif
  125. #endif
  126. #endif
  127. void lcd_cooldown() {
  128. thermalManager.zero_fan_speeds();
  129. thermalManager.disable_all_heaters();
  130. ui.return_to_status();
  131. }
  132. #endif // HAS_TEMP_HOTEND || HAS_HEATED_BED
  133. void menu_temperature() {
  134. #if HAS_TEMP_HOTEND
  135. bool has_heat = false;
  136. HOTEND_LOOP() if (thermalManager.temp_hotend[HOTEND_INDEX].target) { has_heat = true; break; }
  137. #endif
  138. START_MENU();
  139. BACK_ITEM(MSG_MAIN);
  140. //
  141. // Nozzle:
  142. // Nozzle [1-5]:
  143. //
  144. #if HOTENDS == 1
  145. EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, HEATER_0_MAXTEMP - HOTEND_OVERSHOOT, []{ thermalManager.start_watching_hotend(0); });
  146. #elif HAS_MULTI_HOTEND
  147. HOTEND_LOOP()
  148. 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); });
  149. #endif
  150. #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
  151. LOOP_S_L_N(e, 1, EXTRUDERS)
  152. EDIT_ITEM_FAST_N(uint16_3, e, MSG_NOZZLE_STANDBY, &singlenozzle_temp[e], 0, thermalManager.heater_maxtemp[0] - HOTEND_OVERSHOOT);
  153. #endif
  154. //
  155. // Bed:
  156. //
  157. #if HAS_HEATED_BED
  158. EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAX_TARGET, thermalManager.start_watching_bed);
  159. #endif
  160. //
  161. // Chamber:
  162. //
  163. #if HAS_HEATED_CHAMBER
  164. EDIT_ITEM_FAST(int3, MSG_CHAMBER, &thermalManager.temp_chamber.target, 0, CHAMBER_MAXTEMP - 10, thermalManager.start_watching_chamber);
  165. #endif
  166. //
  167. // Fan Speed:
  168. //
  169. #if HAS_FAN
  170. auto on_fan_update = []{
  171. thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8);
  172. };
  173. #if HAS_FAN1 || HAS_FAN2 || HAS_FAN3 || HAS_FAN4 || HAS_FAN5 || HAS_FAN6 || HAS_FAN7
  174. auto fan_edit_items = [&](const uint8_t f) {
  175. editable.uint8 = thermalManager.fan_speed[f];
  176. EDIT_ITEM_FAST_N(percent, f, MSG_FAN_SPEED_N, &editable.uint8, 0, 255, on_fan_update);
  177. #if ENABLED(EXTRA_FAN_SPEED)
  178. EDIT_ITEM_FAST_N(percent, f, MSG_EXTRA_FAN_SPEED_N, &thermalManager.new_fan_speed[f], 3, 255);
  179. #endif
  180. };
  181. #endif
  182. #define SNFAN(N) (ENABLED(SINGLENOZZLE_STANDBY_FAN) && !HAS_FAN##N && EXTRUDERS > N)
  183. #if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7)
  184. auto singlenozzle_item = [&](const uint8_t f) {
  185. editable.uint8 = singlenozzle_fan_speed[f];
  186. EDIT_ITEM_FAST_N(percent, f, MSG_STORED_FAN_N, &editable.uint8, 0, 255, on_fan_update);
  187. };
  188. #endif
  189. #if HAS_FAN0
  190. editable.uint8 = thermalManager.fan_speed[0];
  191. EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_FAN_SPEED, &editable.uint8, 0, 255, on_fan_update);
  192. #if ENABLED(EXTRA_FAN_SPEED)
  193. EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_EXTRA_FAN_SPEED, &thermalManager.new_fan_speed[0], 3, 255);
  194. #endif
  195. #endif
  196. #if HAS_FAN1
  197. fan_edit_items(1);
  198. #elif SNFAN(1)
  199. singlenozzle_item(1);
  200. #endif
  201. #if HAS_FAN2
  202. fan_edit_items(2);
  203. #elif SNFAN(2)
  204. singlenozzle_item(1);
  205. #endif
  206. #if HAS_FAN3
  207. fan_edit_items(3);
  208. #elif SNFAN(3)
  209. singlenozzle_item(1);
  210. #endif
  211. #if HAS_FAN4
  212. fan_edit_items(4);
  213. #elif SNFAN(4)
  214. singlenozzle_item(1);
  215. #endif
  216. #if HAS_FAN5
  217. fan_edit_items(5);
  218. #elif SNFAN(5)
  219. singlenozzle_item(1);
  220. #endif
  221. #if HAS_FAN6
  222. fan_edit_items(6);
  223. #elif SNFAN(6)
  224. singlenozzle_item(1);
  225. #endif
  226. #if HAS_FAN7
  227. fan_edit_items(7);
  228. #elif SNFAN(7)
  229. singlenozzle_item(1);
  230. #endif
  231. #endif // HAS_FAN
  232. #if HAS_TEMP_HOTEND
  233. //
  234. // Preheat for Material 1 and 2
  235. //
  236. #if HOTENDS > 1 || HAS_HEATED_BED
  237. SUBMENU(MSG_PREHEAT_1, menu_preheat_m1);
  238. SUBMENU(MSG_PREHEAT_2, menu_preheat_m2);
  239. #if PREHEAT_COUNT >= 3
  240. SUBMENU(MSG_PREHEAT_3, menu_preheat_m3);
  241. #if PREHEAT_COUNT >= 4
  242. SUBMENU(MSG_PREHEAT_4, menu_preheat_m4);
  243. #if PREHEAT_COUNT >= 5
  244. SUBMENU(MSG_PREHEAT_5, menu_preheat_m5);
  245. #endif
  246. #endif
  247. #endif
  248. #else
  249. ACTION_ITEM(MSG_PREHEAT_1, []{ _preheat_end(0, 0); });
  250. ACTION_ITEM(MSG_PREHEAT_2, []{ _preheat_end(1, 0); });
  251. #if PREHEAT_COUNT >= 3
  252. ACTION_ITEM(MSG_PREHEAT_3, []{ _preheat_end(2, 0); });
  253. #if PREHEAT_COUNT >= 3
  254. ACTION_ITEM(MSG_PREHEAT_4, []{ _preheat_end(3, 0); });
  255. #if PREHEAT_COUNT >= 3
  256. ACTION_ITEM(MSG_PREHEAT_5, []{ _preheat_end(4, 0); });
  257. #endif
  258. #endif
  259. #endif
  260. #endif
  261. //
  262. // Cooldown
  263. //
  264. if (TERN0(HAS_HEATED_BED, thermalManager.temp_bed.target)) has_heat = true;
  265. if (has_heat) ACTION_ITEM(MSG_COOLDOWN, lcd_cooldown);
  266. #endif // HAS_TEMP_HOTEND
  267. END_MENU();
  268. }
  269. #endif // HAS_LCD_MENU && HAS_TEMPERATURE