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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. // Tune Menu
  24. //
  25. #include "../../inc/MarlinConfigPre.h"
  26. #if HAS_MARLINUI_MENU
  27. #include "menu_item.h"
  28. #include "../../module/motion.h"
  29. #include "../../module/planner.h"
  30. #include "../../module/temperature.h"
  31. #include "../../MarlinCore.h"
  32. #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
  33. #include "../../module/tool_change.h"
  34. #endif
  35. #if HAS_LEVELING
  36. #include "../../feature/bedlevel/bedlevel.h"
  37. #endif
  38. #if ENABLED(BABYSTEPPING)
  39. #include "../../feature/babystep.h"
  40. #include "../lcdprint.h"
  41. #if HAS_MARLINUI_U8GLIB
  42. #include "../dogm/marlinui_DOGM.h"
  43. #endif
  44. // TODO: Replace fmsg with MSG_BABYSTEP_N and index substitution
  45. void _lcd_babystep(const AxisEnum axis, FSTR_P const fmsg) {
  46. if (ui.use_click()) return ui.goto_previous_screen_no_defer();
  47. if (ui.encoderPosition) {
  48. const int16_t steps = int16_t(ui.encoderPosition) * (
  49. #if ENABLED(BABYSTEP_XY)
  50. axis == X_AXIS ? BABYSTEP_SIZE_X :
  51. axis == Y_AXIS ? BABYSTEP_SIZE_Y :
  52. #endif
  53. BABYSTEP_SIZE_Z
  54. );
  55. ui.encoderPosition = 0;
  56. ui.refresh(LCDVIEW_REDRAW_NOW);
  57. babystep.add_steps(axis, steps);
  58. }
  59. if (ui.should_draw()) {
  60. const float mps = planner.mm_per_step[axis];
  61. MenuEditItemBase::draw_edit_screen(fmsg, BABYSTEP_TO_STR(mps * babystep.accum));
  62. #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
  63. const bool in_view = TERN1(HAS_MARLINUI_U8GLIB, PAGE_CONTAINS(LCD_PIXEL_HEIGHT - MENU_FONT_HEIGHT, LCD_PIXEL_HEIGHT - 1));
  64. if (in_view) {
  65. TERN_(HAS_MARLINUI_U8GLIB, ui.set_font(FONT_MENU));
  66. #if ENABLED(TFT_COLOR_UI)
  67. lcd_moveto(4, 3);
  68. lcd_put_u8str(GET_TEXT_F(MSG_BABYSTEP_TOTAL));
  69. lcd_put_wchar(':');
  70. lcd_moveto(10, 3);
  71. #else
  72. lcd_moveto(0, TERN(HAS_MARLINUI_U8GLIB, LCD_PIXEL_HEIGHT - MENU_FONT_DESCENT, LCD_HEIGHT - 1));
  73. lcd_put_u8str(GET_TEXT_F(MSG_BABYSTEP_TOTAL));
  74. lcd_put_wchar(':');
  75. #endif
  76. lcd_put_u8str(BABYSTEP_TO_STR(mps * babystep.axis_total[BS_TOTAL_IND(axis)]));
  77. }
  78. #endif
  79. }
  80. }
  81. inline void _lcd_babystep_go(const screenFunc_t screen) {
  82. ui.goto_screen(screen);
  83. ui.defer_status_screen();
  84. babystep.accum = 0;
  85. }
  86. #if ENABLED(BABYSTEP_XY)
  87. void _lcd_babystep_x() { _lcd_babystep(X_AXIS, GET_TEXT_F(MSG_BABYSTEP_X)); }
  88. void _lcd_babystep_y() { _lcd_babystep(Y_AXIS, GET_TEXT_F(MSG_BABYSTEP_Y)); }
  89. #endif
  90. #if DISABLED(BABYSTEP_ZPROBE_OFFSET)
  91. void _lcd_babystep_z() { _lcd_babystep(Z_AXIS, GET_TEXT_F(MSG_BABYSTEP_Z)); }
  92. void lcd_babystep_z() { _lcd_babystep_go(_lcd_babystep_z); }
  93. #endif
  94. #endif // BABYSTEPPING
  95. void menu_tune() {
  96. START_MENU();
  97. BACK_ITEM(MSG_MAIN);
  98. //
  99. // Speed:
  100. //
  101. EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999);
  102. //
  103. // Manual bed leveling, Bed Z:
  104. //
  105. #if BOTH(MESH_BED_LEVELING, LCD_BED_LEVELING)
  106. EDIT_ITEM(float43, MSG_BED_Z, &bedlevel.z_offset, -1, 1);
  107. #endif
  108. //
  109. // Nozzle:
  110. // Nozzle [1-4]:
  111. //
  112. #if HOTENDS == 1
  113. EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, thermalManager.hotend_max_target(0), []{ thermalManager.start_watching_hotend(0); });
  114. #elif HAS_MULTI_HOTEND
  115. HOTEND_LOOP()
  116. EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, thermalManager.hotend_max_target(e), []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); });
  117. #endif
  118. #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
  119. LOOP_S_L_N(e, 1, EXTRUDERS)
  120. EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_STANDBY, &thermalManager.singlenozzle_temp[e], 0, thermalManager.hotend_max_target(0));
  121. #endif
  122. //
  123. // Bed:
  124. //
  125. #if HAS_HEATED_BED
  126. EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAX_TARGET, thermalManager.start_watching_bed);
  127. #endif
  128. //
  129. // Fan Speed:
  130. //
  131. #if HAS_FAN
  132. DEFINE_SINGLENOZZLE_ITEM();
  133. #if HAS_FAN0
  134. _FAN_EDIT_ITEMS(0,FIRST_FAN_SPEED);
  135. #endif
  136. #if HAS_FAN1
  137. FAN_EDIT_ITEMS(1);
  138. #elif SNFAN(1)
  139. singlenozzle_item(1);
  140. #endif
  141. #if HAS_FAN2
  142. FAN_EDIT_ITEMS(2);
  143. #elif SNFAN(2)
  144. singlenozzle_item(2);
  145. #endif
  146. #if HAS_FAN3
  147. FAN_EDIT_ITEMS(3);
  148. #elif SNFAN(3)
  149. singlenozzle_item(3);
  150. #endif
  151. #if HAS_FAN4
  152. FAN_EDIT_ITEMS(4);
  153. #elif SNFAN(4)
  154. singlenozzle_item(4);
  155. #endif
  156. #if HAS_FAN5
  157. FAN_EDIT_ITEMS(5);
  158. #elif SNFAN(5)
  159. singlenozzle_item(5);
  160. #endif
  161. #if HAS_FAN6
  162. FAN_EDIT_ITEMS(6);
  163. #elif SNFAN(6)
  164. singlenozzle_item(6);
  165. #endif
  166. #if HAS_FAN7
  167. FAN_EDIT_ITEMS(7);
  168. #elif SNFAN(7)
  169. singlenozzle_item(7);
  170. #endif
  171. #endif // HAS_FAN
  172. //
  173. // Flow:
  174. //
  175. #if HAS_EXTRUDERS
  176. EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, []{ planner.refresh_e_factor(active_extruder); });
  177. // Flow En:
  178. #if HAS_MULTI_EXTRUDER
  179. EXTRUDER_LOOP()
  180. EDIT_ITEM_N(int3, e, MSG_FLOW_N, &planner.flow_percentage[e], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); });
  181. #endif
  182. #endif
  183. //
  184. // Advance K:
  185. //
  186. #if ENABLED(LIN_ADVANCE) && DISABLED(SLIM_LCD_MENUS)
  187. #if EXTRUDERS == 1
  188. EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10);
  189. #elif HAS_MULTI_EXTRUDER
  190. EXTRUDER_LOOP()
  191. EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10);
  192. #endif
  193. #endif
  194. //
  195. // Babystep X:
  196. // Babystep Y:
  197. // Babystep Z:
  198. //
  199. #if ENABLED(BABYSTEPPING)
  200. #if ENABLED(BABYSTEP_XY)
  201. SUBMENU_N(X_AXIS, MSG_BABYSTEP_N, []{ _lcd_babystep_go(_lcd_babystep_x); });
  202. SUBMENU_N(Y_AXIS, MSG_BABYSTEP_N, []{ _lcd_babystep_go(_lcd_babystep_y); });
  203. #endif
  204. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  205. SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
  206. #else
  207. SUBMENU_N(Z_AXIS, MSG_BABYSTEP_N, lcd_babystep_z);
  208. #endif
  209. #endif
  210. END_MENU();
  211. }
  212. #endif // HAS_MARLINUI_MENU