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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2019 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 "../../Marlin.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) * (BABYSTEP_MULTIPLICATOR);
  48. ui.encoderPosition = 0;
  49. ui.refresh(LCDVIEW_REDRAW_NOW);
  50. babystep.add_steps(axis, steps);
  51. }
  52. if (ui.should_draw()) {
  53. const float spm = planner.steps_to_mm[axis];
  54. draw_edit_screen(msg, ftostr54sign(spm * babystep.accum));
  55. #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
  56. const bool in_view = (true
  57. #if HAS_GRAPHICAL_LCD
  58. && PAGE_CONTAINS(LCD_PIXEL_HEIGHT - MENU_FONT_HEIGHT, LCD_PIXEL_HEIGHT - 1)
  59. #endif
  60. );
  61. if (in_view) {
  62. #if HAS_GRAPHICAL_LCD
  63. ui.set_font(FONT_MENU);
  64. lcd_moveto(0, LCD_PIXEL_HEIGHT - MENU_FONT_DESCENT);
  65. #else
  66. lcd_moveto(0, LCD_HEIGHT - 1);
  67. #endif
  68. lcd_put_u8str_P(GET_TEXT(MSG_BABYSTEP_TOTAL));
  69. lcd_put_wchar(':');
  70. lcd_put_u8str(ftostr54sign(spm * babystep.axis_total[BS_TOTAL_AXIS(axis)]));
  71. }
  72. #endif
  73. }
  74. }
  75. inline void _lcd_babystep_go(const screenFunc_t screen) {
  76. ui.goto_screen(screen);
  77. ui.defer_status_screen();
  78. babystep.accum = 0;
  79. }
  80. #if ENABLED(BABYSTEP_XY)
  81. void _lcd_babystep_x() { _lcd_babystep(X_AXIS, GET_TEXT(MSG_BABYSTEP_X)); }
  82. void _lcd_babystep_y() { _lcd_babystep(Y_AXIS, GET_TEXT(MSG_BABYSTEP_Y)); }
  83. #endif
  84. #if DISABLED(BABYSTEP_ZPROBE_OFFSET)
  85. void _lcd_babystep_z() { _lcd_babystep(Z_AXIS, GET_TEXT(MSG_BABYSTEP_Z)); }
  86. void lcd_babystep_z() { _lcd_babystep_go(_lcd_babystep_z); }
  87. #endif
  88. #endif // BABYSTEPPING
  89. void menu_tune() {
  90. START_MENU();
  91. BACK_ITEM(MSG_MAIN);
  92. //
  93. // Speed:
  94. //
  95. EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999);
  96. //
  97. // Manual bed leveling, Bed Z:
  98. //
  99. #if BOTH(MESH_BED_LEVELING, LCD_BED_LEVELING)
  100. EDIT_ITEM(float43, MSG_BED_Z, &mbl.z_offset, -1, 1);
  101. #endif
  102. //
  103. // Nozzle:
  104. // Nozzle [1-4]:
  105. //
  106. #if HOTENDS == 1
  107. EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, HEATER_0_MAXTEMP - 15, [](){ thermalManager.start_watching_hotend(0); });
  108. #elif HOTENDS > 1
  109. #define EDIT_NOZZLE(N) EDIT_ITEM_FAST(int3, MSG_NOZZLE_##N, &thermalManager.temp_hotend[N].target, 0, HEATER_##N##_MAXTEMP - 15, [](){ thermalManager.start_watching_hotend(N); })
  110. EDIT_NOZZLE(0);
  111. EDIT_NOZZLE(1);
  112. #if HOTENDS > 2
  113. EDIT_NOZZLE(2);
  114. #if HOTENDS > 3
  115. EDIT_NOZZLE(3);
  116. #if HOTENDS > 4
  117. EDIT_NOZZLE(4);
  118. #if HOTENDS > 5
  119. EDIT_NOZZLE(5);
  120. #endif // HOTENDS > 5
  121. #endif // HOTENDS > 4
  122. #endif // HOTENDS > 3
  123. #endif // HOTENDS > 2
  124. #endif // HOTENDS > 1
  125. #if ENABLED(SINGLENOZZLE)
  126. EDIT_ITEM_FAST(uint16_3, MSG_NOZZLE_STANDBY, &singlenozzle_temp[active_extruder ? 0 : 1], 0, HEATER_0_MAXTEMP - 15);
  127. #endif
  128. //
  129. // Bed:
  130. //
  131. #if HAS_HEATED_BED
  132. EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAXTEMP - 10, thermalManager.start_watching_bed);
  133. #endif
  134. //
  135. // Fan Speed:
  136. //
  137. #if FAN_COUNT > 0
  138. #if HAS_FAN0
  139. #if FAN_COUNT == 1
  140. #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED
  141. #define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED
  142. #else
  143. #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_1
  144. #define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED_1
  145. #endif
  146. editable.uint8 = thermalManager.fan_speed[0];
  147. EDIT_ITEM_FAST(percent, MSG_FIRST_FAN_SPEED, &editable.uint8, 0, 255, [](){ thermalManager.set_fan_speed(0, editable.uint8); });
  148. #if ENABLED(EXTRA_FAN_SPEED)
  149. EDIT_ITEM_FAST(percent, MSG_FIRST_EXTRA_FAN_SPEED, &thermalManager.new_fan_speed[0], 3, 255);
  150. #endif
  151. #endif
  152. #if HAS_FAN1 || (ENABLED(SINGLENOZZLE) && EXTRUDERS > 1)
  153. editable.uint8 = thermalManager.fan_speed[1];
  154. EDIT_ITEM_FAST(percent, MSG_FAN_SPEED_2, &editable.uint8, 0, 255, [](){ thermalManager.set_fan_speed(1, editable.uint8); });
  155. #if ENABLED(EXTRA_FAN_SPEED)
  156. EDIT_ITEM_FAST(percent, MSG_EXTRA_FAN_SPEED_2, &thermalManager.new_fan_speed[1], 3, 255);
  157. #endif
  158. #endif
  159. #if HAS_FAN2 || (ENABLED(SINGLENOZZLE) && EXTRUDERS > 2)
  160. editable.uint8 = thermalManager.fan_speed[2];
  161. EDIT_ITEM_FAST(percent, MSG_FAN_SPEED_3, &editable.uint8, 0, 255, [](){ thermalManager.set_fan_speed(2, editable.uint8); });
  162. #if ENABLED(EXTRA_FAN_SPEED)
  163. EDIT_ITEM_FAST(percent, MSG_EXTRA_FAN_SPEED_3, &thermalManager.new_fan_speed[2], 3, 255);
  164. #endif
  165. #endif
  166. #endif // FAN_COUNT > 0
  167. //
  168. // Flow:
  169. // Flow [1-5]:
  170. //
  171. #if EXTRUDERS == 1
  172. EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[0], 10, 999, [](){ planner.refresh_e_factor(0); });
  173. #elif EXTRUDERS
  174. EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, [](){ planner.refresh_e_factor(active_extruder); });
  175. #define EDIT_FLOW(N) EDIT_ITEM(int3, MSG_FLOW_##N, &planner.flow_percentage[N], 10, 999, [](){ planner.refresh_e_factor(N); })
  176. EDIT_FLOW(0);
  177. EDIT_FLOW(1);
  178. #if EXTRUDERS > 2
  179. EDIT_FLOW(2);
  180. #if EXTRUDERS > 3
  181. EDIT_FLOW(3);
  182. #if EXTRUDERS > 4
  183. EDIT_FLOW(4);
  184. #if EXTRUDERS > 5
  185. EDIT_FLOW(5);
  186. #endif // EXTRUDERS > 5
  187. #endif // EXTRUDERS > 4
  188. #endif // EXTRUDERS > 3
  189. #endif // EXTRUDERS > 2
  190. #endif // EXTRUDERS
  191. //
  192. // Babystep X:
  193. // Babystep Y:
  194. // Babystep Z:
  195. //
  196. #if ENABLED(BABYSTEPPING)
  197. #if ENABLED(BABYSTEP_XY)
  198. SUBMENU(MSG_BABYSTEP_X, [](){ _lcd_babystep_go(_lcd_babystep_x); });
  199. SUBMENU(MSG_BABYSTEP_Y, [](){ _lcd_babystep_go(_lcd_babystep_y); });
  200. #endif
  201. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  202. SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
  203. #else
  204. SUBMENU(MSG_BABYSTEP_Z, lcd_babystep_z);
  205. #endif
  206. #endif
  207. END_MENU();
  208. }
  209. #endif // HAS_LCD_MENU