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.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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 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. DEFINE_SINGLENOZZLE_ITEM();
  156. #if HAS_FAN0
  157. _FAN_EDIT_ITEMS(0,FIRST_FAN_SPEED);
  158. #endif
  159. #if HAS_FAN1
  160. FAN_EDIT_ITEMS(1);
  161. #elif SNFAN(1)
  162. singlenozzle_item(1);
  163. #endif
  164. #if HAS_FAN2
  165. FAN_EDIT_ITEMS(2);
  166. #elif SNFAN(2)
  167. singlenozzle_item(2);
  168. #endif
  169. #if HAS_FAN3
  170. FAN_EDIT_ITEMS(3);
  171. #elif SNFAN(3)
  172. singlenozzle_item(3);
  173. #endif
  174. #if HAS_FAN4
  175. FAN_EDIT_ITEMS(4);
  176. #elif SNFAN(4)
  177. singlenozzle_item(4);
  178. #endif
  179. #if HAS_FAN5
  180. FAN_EDIT_ITEMS(5);
  181. #elif SNFAN(5)
  182. singlenozzle_item(5);
  183. #endif
  184. #if HAS_FAN6
  185. FAN_EDIT_ITEMS(6);
  186. #elif SNFAN(6)
  187. singlenozzle_item(6);
  188. #endif
  189. #if HAS_FAN7
  190. FAN_EDIT_ITEMS(7);
  191. #elif SNFAN(7)
  192. singlenozzle_item(7);
  193. #endif
  194. #endif // HAS_FAN
  195. #if PREHEAT_COUNT
  196. //
  197. // Preheat for Materials 1 to 5
  198. //
  199. LOOP_L_N(m, PREHEAT_COUNT) {
  200. editable.int8 = m;
  201. #if HOTENDS > 1 || HAS_HEATED_BED
  202. SUBMENU_S(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m);
  203. #else
  204. ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m);
  205. #endif
  206. }
  207. #endif
  208. #if HAS_TEMP_HOTEND || HAS_HEATED_BED
  209. //
  210. // Cooldown
  211. //
  212. if (TERN0(HAS_HEATED_BED, thermalManager.temp_bed.target)) has_heat = true;
  213. if (has_heat) ACTION_ITEM(MSG_COOLDOWN, lcd_cooldown);
  214. #endif
  215. END_MENU();
  216. }
  217. #endif // HAS_LCD_MENU && HAS_TEMPERATURE