My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

menu_temperature.cpp 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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/MarlinConfigPre.h"
  26. #if HAS_LCD_MENU
  27. #include "menu.h"
  28. #include "../../module/temperature.h"
  29. #if FAN_COUNT > 1
  30. #include "../../module/motion.h"
  31. #endif
  32. // Initialized by settings.load()
  33. int16_t MarlinUI::preheat_hotend_temp[2], MarlinUI::preheat_bed_temp[2];
  34. uint8_t MarlinUI::preheat_fan_speed[2];
  35. //
  36. // "Temperature" submenu items
  37. //
  38. void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb, const uint8_t fan) {
  39. if (temph > 0) thermalManager.setTargetHotend(MIN(heater_maxtemp[endnum], temph), endnum);
  40. #if HAS_HEATED_BED
  41. if (tempb >= 0) thermalManager.setTargetBed(tempb);
  42. #else
  43. UNUSED(tempb);
  44. #endif
  45. #if FAN_COUNT > 0
  46. #if FAN_COUNT > 1
  47. fan_speed[active_extruder < FAN_COUNT ? active_extruder : 0] = fan;
  48. #else
  49. fan_speed[0] = fan;
  50. #endif
  51. #else
  52. UNUSED(fan);
  53. #endif
  54. ui.return_to_status();
  55. }
  56. #if HOTENDS > 1
  57. void lcd_preheat_m1_e1_only() { _lcd_preheat(1, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
  58. void lcd_preheat_m2_e1_only() { _lcd_preheat(1, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
  59. #if HAS_HEATED_BED
  60. void lcd_preheat_m1_e1() { _lcd_preheat(1, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
  61. void lcd_preheat_m2_e1() { _lcd_preheat(1, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
  62. #endif
  63. #if HOTENDS > 2
  64. void lcd_preheat_m1_e2_only() { _lcd_preheat(2, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
  65. void lcd_preheat_m2_e2_only() { _lcd_preheat(2, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
  66. #if HAS_HEATED_BED
  67. void lcd_preheat_m1_e2() { _lcd_preheat(2, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
  68. void lcd_preheat_m2_e2() { _lcd_preheat(2, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
  69. #endif
  70. #if HOTENDS > 3
  71. void lcd_preheat_m1_e3_only() { _lcd_preheat(3, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
  72. void lcd_preheat_m2_e3_only() { _lcd_preheat(3, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
  73. #if HAS_HEATED_BED
  74. void lcd_preheat_m1_e3() { _lcd_preheat(3, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
  75. void lcd_preheat_m2_e3() { _lcd_preheat(3, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
  76. #endif
  77. #if HOTENDS > 4
  78. void lcd_preheat_m1_e4_only() { _lcd_preheat(4, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
  79. void lcd_preheat_m2_e4_only() { _lcd_preheat(4, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
  80. #if HAS_HEATED_BED
  81. void lcd_preheat_m1_e4() { _lcd_preheat(4, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
  82. void lcd_preheat_m2_e4() { _lcd_preheat(4, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
  83. #endif
  84. #if HOTENDS > 5
  85. void lcd_preheat_m1_e5_only() { _lcd_preheat(5, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
  86. void lcd_preheat_m2_e5_only() { _lcd_preheat(5, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
  87. #if HAS_HEATED_BED
  88. void lcd_preheat_m1_e5() { _lcd_preheat(5, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
  89. void lcd_preheat_m2_e5() { _lcd_preheat(5, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
  90. #endif
  91. #endif // HOTENDS > 5
  92. #endif // HOTENDS > 4
  93. #endif // HOTENDS > 3
  94. #endif // HOTENDS > 2
  95. #if HAS_HEATED_BED
  96. void lcd_preheat_m1_e0();
  97. void lcd_preheat_m2_e0();
  98. #else
  99. void lcd_preheat_m1_e0_only();
  100. void lcd_preheat_m2_e0_only();
  101. #endif
  102. void lcd_preheat_m1_all() {
  103. #if HOTENDS > 1
  104. thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 1);
  105. #if HOTENDS > 2
  106. thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 2);
  107. #if HOTENDS > 3
  108. thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 3);
  109. #if HOTENDS > 4
  110. thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 4);
  111. #if HOTENDS > 5
  112. thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 5);
  113. #endif // HOTENDS > 5
  114. #endif // HOTENDS > 4
  115. #endif // HOTENDS > 3
  116. #endif // HOTENDS > 2
  117. #endif // HOTENDS > 1
  118. #if HAS_HEATED_BED
  119. lcd_preheat_m1_e0();
  120. #else
  121. lcd_preheat_m1_e0_only();
  122. #endif
  123. }
  124. void lcd_preheat_m2_all() {
  125. #if HOTENDS > 1
  126. thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 1);
  127. #if HOTENDS > 2
  128. thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 2);
  129. #if HOTENDS > 3
  130. thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 3);
  131. #if HOTENDS > 4
  132. thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 4);
  133. #if HOTENDS > 5
  134. thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 5);
  135. #endif // HOTENDS > 5
  136. #endif // HOTENDS > 4
  137. #endif // HOTENDS > 3
  138. #endif // HOTENDS > 2
  139. #endif // HOTENDS > 1
  140. #if HAS_HEATED_BED
  141. lcd_preheat_m2_e0();
  142. #else
  143. lcd_preheat_m2_e0_only();
  144. #endif
  145. }
  146. #endif // HOTENDS > 1
  147. #if HAS_TEMP_HOTEND || HAS_HEATED_BED
  148. void lcd_preheat_m1_e0_only() { _lcd_preheat(0, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
  149. void lcd_preheat_m2_e0_only() { _lcd_preheat(0, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
  150. #if HAS_HEATED_BED
  151. void lcd_preheat_m1_e0() { _lcd_preheat(0, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
  152. void lcd_preheat_m2_e0() { _lcd_preheat(0, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
  153. void lcd_preheat_m1_bedonly() { _lcd_preheat(0, 0, ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
  154. void lcd_preheat_m2_bedonly() { _lcd_preheat(0, 0, ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
  155. #endif
  156. void menu_preheat_m1() {
  157. START_MENU();
  158. MENU_BACK(MSG_TEMPERATURE);
  159. #if HOTENDS == 1
  160. #if HAS_HEATED_BED
  161. MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_m1_e0);
  162. MENU_ITEM(function, MSG_PREHEAT_1_END, lcd_preheat_m1_e0_only);
  163. #else
  164. MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_m1_e0_only);
  165. #endif
  166. #elif HOTENDS > 1
  167. #if HAS_HEATED_BED
  168. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H1, lcd_preheat_m1_e0);
  169. MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E1, lcd_preheat_m1_e0_only);
  170. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H2, lcd_preheat_m1_e1);
  171. MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E2, lcd_preheat_m1_e1_only);
  172. #else
  173. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H1, lcd_preheat_m1_e0_only);
  174. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H2, lcd_preheat_m1_e1_only);
  175. #endif
  176. #if HOTENDS > 2
  177. #if HAS_HEATED_BED
  178. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H3, lcd_preheat_m1_e2);
  179. MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E3, lcd_preheat_m1_e2_only);
  180. #else
  181. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H3, lcd_preheat_m1_e2_only);
  182. #endif
  183. #if HOTENDS > 3
  184. #if HAS_HEATED_BED
  185. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H4, lcd_preheat_m1_e3);
  186. MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E4, lcd_preheat_m1_e3_only);
  187. #else
  188. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H4, lcd_preheat_m1_e3_only);
  189. #endif
  190. #if HOTENDS > 4
  191. #if HAS_HEATED_BED
  192. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H5, lcd_preheat_m1_e4);
  193. MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E5, lcd_preheat_m1_e4_only);
  194. #else
  195. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H5, lcd_preheat_m1_e4_only);
  196. #endif
  197. #if HOTENDS > 5
  198. #if HAS_HEATED_BED
  199. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H6, lcd_preheat_m1_e5);
  200. MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E6, lcd_preheat_m1_e5_only);
  201. #else
  202. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H6, lcd_preheat_m1_e5_only);
  203. #endif
  204. #endif // HOTENDS > 5
  205. #endif // HOTENDS > 4
  206. #endif // HOTENDS > 3
  207. #endif // HOTENDS > 2
  208. MENU_ITEM(function, MSG_PREHEAT_1_ALL, lcd_preheat_m1_all);
  209. #endif // HOTENDS > 1
  210. #if HAS_HEATED_BED
  211. MENU_ITEM(function, MSG_PREHEAT_1_BEDONLY, lcd_preheat_m1_bedonly);
  212. #endif
  213. END_MENU();
  214. }
  215. void menu_preheat_m2() {
  216. START_MENU();
  217. MENU_BACK(MSG_TEMPERATURE);
  218. #if HOTENDS == 1
  219. #if HAS_HEATED_BED
  220. MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0);
  221. MENU_ITEM(function, MSG_PREHEAT_2_END, lcd_preheat_m2_e0_only);
  222. #else
  223. MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0_only);
  224. #endif
  225. #elif HOTENDS > 1
  226. #if HAS_HEATED_BED
  227. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H1, lcd_preheat_m2_e0);
  228. MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E1, lcd_preheat_m2_e0_only);
  229. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H2, lcd_preheat_m2_e1);
  230. MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E2, lcd_preheat_m2_e1_only);
  231. #else
  232. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H1, lcd_preheat_m2_e0_only);
  233. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H2, lcd_preheat_m2_e1_only);
  234. #endif
  235. #if HOTENDS > 2
  236. #if HAS_HEATED_BED
  237. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H3, lcd_preheat_m2_e2);
  238. MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E3, lcd_preheat_m2_e2_only);
  239. #else
  240. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H3, lcd_preheat_m2_e2_only);
  241. #endif
  242. #if HOTENDS > 3
  243. #if HAS_HEATED_BED
  244. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H4, lcd_preheat_m2_e3);
  245. MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E4, lcd_preheat_m2_e3_only);
  246. #else
  247. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H4, lcd_preheat_m2_e3_only);
  248. #endif
  249. #if HOTENDS > 4
  250. #if HAS_HEATED_BED
  251. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H5, lcd_preheat_m2_e4);
  252. MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E5, lcd_preheat_m2_e4_only);
  253. #else
  254. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H5, lcd_preheat_m2_e4_only);
  255. #endif
  256. #if HOTENDS > 5
  257. #if HAS_HEATED_BED
  258. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H6, lcd_preheat_m2_e5);
  259. MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E6, lcd_preheat_m2_e5_only);
  260. #else
  261. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H6, lcd_preheat_m2_e5_only);
  262. #endif
  263. #endif // HOTENDS > 5
  264. #endif // HOTENDS > 4
  265. #endif // HOTENDS > 3
  266. #endif // HOTENDS > 2
  267. MENU_ITEM(function, MSG_PREHEAT_2_ALL, lcd_preheat_m2_all);
  268. #endif // HOTENDS > 1
  269. #if HAS_HEATED_BED
  270. MENU_ITEM(function, MSG_PREHEAT_2_BEDONLY, lcd_preheat_m2_bedonly);
  271. #endif
  272. END_MENU();
  273. }
  274. void lcd_cooldown() {
  275. zero_fan_speeds();
  276. thermalManager.disable_all_heaters();
  277. ui.return_to_status();
  278. }
  279. #endif // HAS_TEMP_HOTEND || HAS_HEATED_BED
  280. void menu_temperature() {
  281. START_MENU();
  282. MENU_BACK(MSG_MAIN);
  283. //
  284. // Nozzle:
  285. // Nozzle [1-5]:
  286. //
  287. #if HOTENDS == 1
  288. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE, &thermalManager.target_temperature[0], 0, HEATER_0_MAXTEMP - 15, watch_temp_callback_E0);
  289. #else // HOTENDS > 1
  290. #define EDIT_TARGET(N) MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE MSG_LCD_N##N, &thermalManager.target_temperature[N], 0, HEATER_##N##_MAXTEMP - 15, watch_temp_callback_E##N)
  291. EDIT_TARGET(0);
  292. EDIT_TARGET(1);
  293. #if HOTENDS > 2
  294. EDIT_TARGET(2);
  295. #if HOTENDS > 3
  296. EDIT_TARGET(3);
  297. #if HOTENDS > 4
  298. EDIT_TARGET(4);
  299. #if HOTENDS > 5
  300. EDIT_TARGET(5);
  301. #endif // HOTENDS > 5
  302. #endif // HOTENDS > 4
  303. #endif // HOTENDS > 3
  304. #endif // HOTENDS > 2
  305. #endif // HOTENDS > 1
  306. //
  307. // Bed:
  308. //
  309. #if HAS_HEATED_BED
  310. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_BED, &thermalManager.target_temperature_bed, 0, BED_MAXTEMP - 15, watch_temp_callback_bed);
  311. #endif
  312. //
  313. // Fan Speed:
  314. //
  315. #if FAN_COUNT > 0
  316. #if HAS_FAN0
  317. MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED FAN_SPEED_1_SUFFIX, &fan_speed[0], 0, 255);
  318. #if ENABLED(EXTRA_FAN_SPEED)
  319. MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED FAN_SPEED_1_SUFFIX, &new_fan_speed[0], 3, 255);
  320. #endif
  321. #endif
  322. #if HAS_FAN1
  323. MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED " 2", &fan_speed[1], 0, 255);
  324. #if ENABLED(EXTRA_FAN_SPEED)
  325. MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED " 2", &new_fan_speed[1], 3, 255);
  326. #endif
  327. #endif
  328. #if HAS_FAN2
  329. MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED " 3", &fan_speed[2], 0, 255);
  330. #if ENABLED(EXTRA_FAN_SPEED)
  331. MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED " 3", &new_fan_speed[2], 3, 255);
  332. #endif
  333. #endif
  334. #endif // FAN_COUNT > 0
  335. #if HAS_TEMP_HOTEND
  336. //
  337. // Cooldown
  338. //
  339. bool has_heat = false;
  340. HOTEND_LOOP() if (thermalManager.target_temperature[HOTEND_INDEX]) { has_heat = true; break; }
  341. #if HAS_TEMP_BED
  342. if (thermalManager.target_temperature_bed) has_heat = true;
  343. #endif
  344. if (has_heat) MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
  345. //
  346. // Preheat for Material 1 and 2
  347. //
  348. #if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_4 != 0 || HAS_HEATED_BED
  349. MENU_ITEM(submenu, MSG_PREHEAT_1, menu_preheat_m1);
  350. MENU_ITEM(submenu, MSG_PREHEAT_2, menu_preheat_m2);
  351. #else
  352. MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_m1_e0_only);
  353. MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0_only);
  354. #endif
  355. #endif // HAS_TEMP_HOTEND
  356. END_MENU();
  357. }
  358. #endif // HAS_LCD_MENU