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_tune.cpp 7.5KB

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 <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. //
  23. // Tune Menu
  24. //
  25. #include "../../inc/MarlinConfigPre.h"
  26. #if HAS_LCD_MENU
  27. #include "menu.h"
  28. #include "../../module/motion.h"
  29. #include "../../module/planner.h"
  30. #include "../../module/temperature.h"
  31. #include "../../MarlinCore.h"
  32. #if HAS_LEVELING
  33. #include "../../feature/bedlevel/bedlevel.h"
  34. #endif
  35. #if ENABLED(SINGLENOZZLE)
  36. #include "../../module/tool_change.h"
  37. #endif
  38. #if ENABLED(BABYSTEPPING)
  39. #include "../../feature/babystep.h"
  40. #include "../lcdprint.h"
  41. #if HAS_GRAPHICAL_LCD
  42. #include "../dogm/ultralcd_DOGM.h"
  43. #endif
  44. void _lcd_babystep(const AxisEnum axis, PGM_P const msg) {
  45. if (ui.use_click()) return ui.goto_previous_screen_no_defer();
  46. if (ui.encoderPosition) {
  47. const int16_t steps = int16_t(ui.encoderPosition) * (
  48. #if ENABLED(BABYSTEP_XY)
  49. axis != Z_AXIS ? BABYSTEP_MULTIPLICATOR_XY :
  50. #endif
  51. BABYSTEP_MULTIPLICATOR_Z
  52. );
  53. ui.encoderPosition = 0;
  54. ui.refresh(LCDVIEW_REDRAW_NOW);
  55. babystep.add_steps(axis, steps);
  56. }
  57. if (ui.should_draw()) {
  58. const float spm = planner.steps_to_mm[axis];
  59. MenuEditItemBase::draw_edit_screen(msg, LCD_Z_OFFSET_FUNC(spm * babystep.accum));
  60. #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
  61. const bool in_view = (true
  62. #if HAS_GRAPHICAL_LCD
  63. && PAGE_CONTAINS(LCD_PIXEL_HEIGHT - MENU_FONT_HEIGHT, LCD_PIXEL_HEIGHT - 1)
  64. #endif
  65. );
  66. if (in_view) {
  67. #if HAS_GRAPHICAL_LCD
  68. ui.set_font(FONT_MENU);
  69. lcd_moveto(0, LCD_PIXEL_HEIGHT - MENU_FONT_DESCENT);
  70. #else
  71. lcd_moveto(0, LCD_HEIGHT - 1);
  72. #endif
  73. lcd_put_u8str_P(GET_TEXT(MSG_BABYSTEP_TOTAL));
  74. lcd_put_wchar(':');
  75. lcd_put_u8str(LCD_Z_OFFSET_FUNC(spm * babystep.axis_total[BS_TOTAL_IND(axis)]));
  76. }
  77. #endif
  78. }
  79. }
  80. inline void _lcd_babystep_go(const screenFunc_t screen) {
  81. ui.goto_screen(screen);
  82. ui.defer_status_screen();
  83. babystep.accum = 0;
  84. }
  85. #if ENABLED(BABYSTEP_XY)
  86. void _lcd_babystep_x() { _lcd_babystep(X_AXIS, GET_TEXT(MSG_BABYSTEP_X)); }
  87. void _lcd_babystep_y() { _lcd_babystep(Y_AXIS, GET_TEXT(MSG_BABYSTEP_Y)); }
  88. #endif
  89. #if DISABLED(BABYSTEP_ZPROBE_OFFSET)
  90. void _lcd_babystep_z() { _lcd_babystep(Z_AXIS, GET_TEXT(MSG_BABYSTEP_Z)); }
  91. void lcd_babystep_z() { _lcd_babystep_go(_lcd_babystep_z); }
  92. #endif
  93. #endif // BABYSTEPPING
  94. void menu_tune() {
  95. START_MENU();
  96. BACK_ITEM(MSG_MAIN);
  97. //
  98. // Speed:
  99. //
  100. EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999);
  101. //
  102. // Manual bed leveling, Bed Z:
  103. //
  104. #if BOTH(MESH_BED_LEVELING, LCD_BED_LEVELING)
  105. EDIT_ITEM(float43, MSG_BED_Z, &mbl.z_offset, -1, 1);
  106. #endif
  107. //
  108. // Nozzle:
  109. // Nozzle [1-4]:
  110. //
  111. #if HOTENDS == 1
  112. EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, HEATER_0_MAXTEMP - 15, []{ thermalManager.start_watching_hotend(0); });
  113. #elif HOTENDS > 1
  114. HOTEND_LOOP()
  115. EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, heater_maxtemp[e] - 15, []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); });
  116. #endif
  117. #if ENABLED(SINGLENOZZLE)
  118. EDIT_ITEM_FAST(uint16_3, MSG_NOZZLE_STANDBY, &singlenozzle_temp[active_extruder ? 0 : 1], 0, HEATER_0_MAXTEMP - 15);
  119. #endif
  120. //
  121. // Bed:
  122. //
  123. #if HAS_HEATED_BED
  124. EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAXTEMP - 10, thermalManager.start_watching_bed);
  125. #endif
  126. //
  127. // Fan Speed:
  128. //
  129. #if FAN_COUNT > 0
  130. auto on_fan_update = []{
  131. thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8);
  132. };
  133. #if HAS_FAN1 || HAS_FAN2 || HAS_FAN3 || HAS_FAN4 || HAS_FAN5 || HAS_FAN6 || HAS_FAN7
  134. auto fan_edit_items = [&](const uint8_t f) {
  135. editable.uint8 = thermalManager.fan_speed[f];
  136. EDIT_ITEM_FAST_N(percent, f, MSG_FAN_SPEED_N, &editable.uint8, 0, 255, on_fan_update);
  137. #if ENABLED(EXTRA_FAN_SPEED)
  138. EDIT_ITEM_FAST_N(percent, f, MSG_EXTRA_FAN_SPEED_N, &thermalManager.new_fan_speed[f], 3, 255);
  139. #endif
  140. };
  141. #endif
  142. #define SNFAN(N) (ENABLED(SINGLENOZZLE) && !HAS_FAN##N && EXTRUDERS > N)
  143. #if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7)
  144. auto singlenozzle_item = [&](const uint8_t f) {
  145. editable.uint8 = thermalManager.fan_speed[f];
  146. EDIT_ITEM_FAST_N(percent, f, MSG_STORED_FAN_N, &editable.uint8, 0, 255, on_fan_update);
  147. };
  148. #endif
  149. #if HAS_FAN0
  150. editable.uint8 = thermalManager.fan_speed[0];
  151. EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_FAN_SPEED, &editable.uint8, 0, 255, on_fan_update);
  152. #if ENABLED(EXTRA_FAN_SPEED)
  153. EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_EXTRA_FAN_SPEED, &thermalManager.new_fan_speed[0], 3, 255);
  154. #endif
  155. #endif
  156. #if HAS_FAN1
  157. fan_edit_items(1);
  158. #elif SNFAN(1)
  159. singlenozzle_item(1);
  160. #endif
  161. #if HAS_FAN2
  162. fan_edit_items(2);
  163. #elif SNFAN(2)
  164. singlenozzle_item(1);
  165. #endif
  166. #if HAS_FAN3
  167. fan_edit_items(3);
  168. #elif SNFAN(3)
  169. singlenozzle_item(1);
  170. #endif
  171. #if HAS_FAN4
  172. fan_edit_items(4);
  173. #elif SNFAN(4)
  174. singlenozzle_item(1);
  175. #endif
  176. #if HAS_FAN5
  177. fan_edit_items(5);
  178. #elif SNFAN(5)
  179. singlenozzle_item(1);
  180. #endif
  181. #if HAS_FAN6
  182. fan_edit_items(6);
  183. #elif SNFAN(6)
  184. singlenozzle_item(1);
  185. #endif
  186. #if HAS_FAN7
  187. fan_edit_items(7);
  188. #elif SNFAN(7)
  189. singlenozzle_item(1);
  190. #endif
  191. #endif // FAN_COUNT > 0
  192. //
  193. // Flow:
  194. //
  195. #if EXTRUDERS
  196. EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, []{ planner.refresh_e_factor(active_extruder); });
  197. // Flow En:
  198. #if EXTRUDERS > 1
  199. LOOP_L_N(n, EXTRUDERS)
  200. EDIT_ITEM_N(int3, n, MSG_FLOW_N, &planner.flow_percentage[n], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); });
  201. #endif
  202. #endif
  203. //
  204. // Advance K:
  205. //
  206. #if ENABLED(LIN_ADVANCE) && DISABLED(SLIM_LCD_MENUS)
  207. #if EXTRUDERS == 1
  208. EDIT_ITEM(float52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
  209. #elif EXTRUDERS > 1
  210. LOOP_L_N(n, EXTRUDERS)
  211. EDIT_ITEM_N(float52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
  212. #endif
  213. #endif
  214. //
  215. // Babystep X:
  216. // Babystep Y:
  217. // Babystep Z:
  218. //
  219. #if ENABLED(BABYSTEPPING)
  220. #if ENABLED(BABYSTEP_XY)
  221. SUBMENU(MSG_BABYSTEP_X, []{ _lcd_babystep_go(_lcd_babystep_x); });
  222. SUBMENU(MSG_BABYSTEP_Y, []{ _lcd_babystep_go(_lcd_babystep_y); });
  223. #endif
  224. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  225. SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
  226. #else
  227. SUBMENU(MSG_BABYSTEP_Z, lcd_babystep_z);
  228. #endif
  229. #endif
  230. END_MENU();
  231. }
  232. #endif // HAS_LCD_MENU