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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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, BABYSTEP_TO_STR(spm * babystep.accum));
  60. #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
  61. const bool in_view = TERN1(HAS_GRAPHICAL_LCD, PAGE_CONTAINS(LCD_PIXEL_HEIGHT - MENU_FONT_HEIGHT, LCD_PIXEL_HEIGHT - 1));
  62. if (in_view) {
  63. TERN_(HAS_GRAPHICAL_LCD, ui.set_font(FONT_MENU));
  64. lcd_moveto(0, TERN(HAS_GRAPHICAL_LCD, LCD_PIXEL_HEIGHT - MENU_FONT_DESCENT, LCD_HEIGHT - 1));
  65. lcd_put_u8str_P(GET_TEXT(MSG_BABYSTEP_TOTAL));
  66. lcd_put_wchar(':');
  67. lcd_put_u8str(BABYSTEP_TO_STR(spm * babystep.axis_total[BS_TOTAL_IND(axis)]));
  68. }
  69. #endif
  70. }
  71. }
  72. inline void _lcd_babystep_go(const screenFunc_t screen) {
  73. ui.goto_screen(screen);
  74. ui.defer_status_screen();
  75. babystep.accum = 0;
  76. }
  77. #if ENABLED(BABYSTEP_XY)
  78. void _lcd_babystep_x() { _lcd_babystep(X_AXIS, GET_TEXT(MSG_BABYSTEP_X)); }
  79. void _lcd_babystep_y() { _lcd_babystep(Y_AXIS, GET_TEXT(MSG_BABYSTEP_Y)); }
  80. #endif
  81. #if DISABLED(BABYSTEP_ZPROBE_OFFSET)
  82. void _lcd_babystep_z() { _lcd_babystep(Z_AXIS, GET_TEXT(MSG_BABYSTEP_Z)); }
  83. void lcd_babystep_z() { _lcd_babystep_go(_lcd_babystep_z); }
  84. #endif
  85. #endif // BABYSTEPPING
  86. void menu_tune() {
  87. START_MENU();
  88. BACK_ITEM(MSG_MAIN);
  89. //
  90. // Speed:
  91. //
  92. EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999);
  93. //
  94. // Manual bed leveling, Bed Z:
  95. //
  96. #if BOTH(MESH_BED_LEVELING, LCD_BED_LEVELING)
  97. EDIT_ITEM(float43, MSG_BED_Z, &mbl.z_offset, -1, 1);
  98. #endif
  99. //
  100. // Nozzle:
  101. // Nozzle [1-4]:
  102. //
  103. #if HOTENDS == 1
  104. EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, HEATER_0_MAXTEMP - 15, []{ thermalManager.start_watching_hotend(0); });
  105. #elif HAS_MULTI_HOTEND
  106. HOTEND_LOOP()
  107. 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); });
  108. #endif
  109. #if ENABLED(SINGLENOZZLE)
  110. EDIT_ITEM_FAST(uint16_3, MSG_NOZZLE_STANDBY, &singlenozzle_temp[active_extruder ? 0 : 1], 0, HEATER_0_MAXTEMP - 15);
  111. #endif
  112. //
  113. // Bed:
  114. //
  115. #if HAS_HEATED_BED
  116. EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAX_TARGET, thermalManager.start_watching_bed);
  117. #endif
  118. //
  119. // Fan Speed:
  120. //
  121. #if HAS_FAN
  122. auto on_fan_update = []{
  123. thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8);
  124. };
  125. #if HAS_FAN1 || HAS_FAN2 || HAS_FAN3 || HAS_FAN4 || HAS_FAN5 || HAS_FAN6 || HAS_FAN7
  126. auto fan_edit_items = [&](const uint8_t f) {
  127. editable.uint8 = thermalManager.fan_speed[f];
  128. EDIT_ITEM_FAST_N(percent, f, MSG_FAN_SPEED_N, &editable.uint8, 0, 255, on_fan_update);
  129. #if ENABLED(EXTRA_FAN_SPEED)
  130. EDIT_ITEM_FAST_N(percent, f, MSG_EXTRA_FAN_SPEED_N, &thermalManager.new_fan_speed[f], 3, 255);
  131. #endif
  132. };
  133. #endif
  134. #define SNFAN(N) (ENABLED(SINGLENOZZLE) && !HAS_FAN##N && EXTRUDERS > N)
  135. #if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7)
  136. auto singlenozzle_item = [&](const uint8_t f) {
  137. editable.uint8 = thermalManager.fan_speed[f];
  138. EDIT_ITEM_FAST_N(percent, f, MSG_STORED_FAN_N, &editable.uint8, 0, 255, on_fan_update);
  139. };
  140. #endif
  141. #if HAS_FAN0
  142. editable.uint8 = thermalManager.fan_speed[0];
  143. EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_FAN_SPEED, &editable.uint8, 0, 255, on_fan_update);
  144. #if ENABLED(EXTRA_FAN_SPEED)
  145. EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_EXTRA_FAN_SPEED, &thermalManager.new_fan_speed[0], 3, 255);
  146. #endif
  147. #endif
  148. #if HAS_FAN1
  149. fan_edit_items(1);
  150. #elif SNFAN(1)
  151. singlenozzle_item(1);
  152. #endif
  153. #if HAS_FAN2
  154. fan_edit_items(2);
  155. #elif SNFAN(2)
  156. singlenozzle_item(1);
  157. #endif
  158. #if HAS_FAN3
  159. fan_edit_items(3);
  160. #elif SNFAN(3)
  161. singlenozzle_item(1);
  162. #endif
  163. #if HAS_FAN4
  164. fan_edit_items(4);
  165. #elif SNFAN(4)
  166. singlenozzle_item(1);
  167. #endif
  168. #if HAS_FAN5
  169. fan_edit_items(5);
  170. #elif SNFAN(5)
  171. singlenozzle_item(1);
  172. #endif
  173. #if HAS_FAN6
  174. fan_edit_items(6);
  175. #elif SNFAN(6)
  176. singlenozzle_item(1);
  177. #endif
  178. #if HAS_FAN7
  179. fan_edit_items(7);
  180. #elif SNFAN(7)
  181. singlenozzle_item(1);
  182. #endif
  183. #endif // HAS_FAN
  184. //
  185. // Flow:
  186. //
  187. #if EXTRUDERS
  188. EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, []{ planner.refresh_e_factor(active_extruder); });
  189. // Flow En:
  190. #if EXTRUDERS > 1
  191. LOOP_L_N(n, EXTRUDERS)
  192. EDIT_ITEM_N(int3, n, MSG_FLOW_N, &planner.flow_percentage[n], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); });
  193. #endif
  194. #endif
  195. //
  196. // Advance K:
  197. //
  198. #if ENABLED(LIN_ADVANCE) && DISABLED(SLIM_LCD_MENUS)
  199. #if EXTRUDERS == 1
  200. EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
  201. #elif EXTRUDERS > 1
  202. LOOP_L_N(n, EXTRUDERS)
  203. EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
  204. #endif
  205. #endif
  206. //
  207. // Babystep X:
  208. // Babystep Y:
  209. // Babystep Z:
  210. //
  211. #if ENABLED(BABYSTEPPING)
  212. #if ENABLED(BABYSTEP_XY)
  213. SUBMENU(MSG_BABYSTEP_X, []{ _lcd_babystep_go(_lcd_babystep_x); });
  214. SUBMENU(MSG_BABYSTEP_Y, []{ _lcd_babystep_go(_lcd_babystep_y); });
  215. #endif
  216. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  217. SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
  218. #else
  219. SUBMENU(MSG_BABYSTEP_Z, lcd_babystep_z);
  220. #endif
  221. #endif
  222. END_MENU();
  223. }
  224. #endif // HAS_LCD_MENU