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

menu_tune.cpp 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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 "../../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, ftostr54sign(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(ftostr54sign(spm * babystep.axis_total[BS_TOTAL_AXIS(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. #define EDIT_NOZZLE(N) EDIT_ITEM_FAST_N(int3, N, MSG_NOZZLE_N, &thermalManager.temp_hotend[N].target, 0, heater_maxtemp[N] - 15, []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); })
  115. HOTEND_LOOP() EDIT_NOZZLE(e);
  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. #if HAS_FAN0
  131. editable.uint8 = thermalManager.fan_speed[0];
  132. EDIT_ITEM_FAST_N(percent, 1, MSG_FIRST_FAN_SPEED, &editable.uint8, 0, 255, []{ thermalManager.set_fan_speed(0, editable.uint8); });
  133. #if ENABLED(EXTRA_FAN_SPEED)
  134. EDIT_ITEM_FAST_N(percent, 1, MSG_FIRST_EXTRA_FAN_SPEED, &thermalManager.new_fan_speed[0], 3, 255);
  135. #endif
  136. #endif
  137. #if HAS_FAN1
  138. editable.uint8 = thermalManager.fan_speed[1];
  139. EDIT_ITEM_FAST_N(percent, 2, MSG_FAN_SPEED_N, &editable.uint8, 0, 255, []{ thermalManager.set_fan_speed(1, editable.uint8); });
  140. #if ENABLED(EXTRA_FAN_SPEED)
  141. EDIT_ITEM_FAST_N(percent, 2, MSG_EXTRA_FAN_SPEED_N, &thermalManager.new_fan_speed[1], 3, 255);
  142. #endif
  143. #elif ENABLED(SINGLENOZZLE) && EXTRUDERS > 1
  144. editable.uint8 = thermalManager.fan_speed[1];
  145. EDIT_ITEM_FAST_N(percent, 2, MSG_STORED_FAN_N, &editable.uint8, 0, 255, []{ thermalManager.set_fan_speed(1, editable.uint8); });
  146. #endif
  147. #if HAS_FAN2
  148. editable.uint8 = thermalManager.fan_speed[2];
  149. EDIT_ITEM_FAST_N(percent, 3, MSG_FAN_SPEED_N, &editable.uint8, 0, 255, []{ thermalManager.set_fan_speed(2, editable.uint8); });
  150. #if ENABLED(EXTRA_FAN_SPEED)
  151. EDIT_ITEM_FAST_N(percent, 3, MSG_EXTRA_FAN_SPEED_N, &thermalManager.new_fan_speed[2], 3, 255);
  152. #endif
  153. #elif ENABLED(SINGLENOZZLE) && EXTRUDERS > 2
  154. editable.uint8 = thermalManager.fan_speed[2];
  155. EDIT_ITEM_FAST_N(percent, 3, MSG_STORED_FAN_N, &editable.uint8, 0, 255, []{ thermalManager.set_fan_speed(2, editable.uint8); });
  156. #endif
  157. #endif // FAN_COUNT > 0
  158. //
  159. // Flow:
  160. // Flow [1-5]:
  161. //
  162. #if EXTRUDERS == 1
  163. EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[0], 10, 999, []{ planner.refresh_e_factor(0); });
  164. #elif EXTRUDERS
  165. EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, []{ planner.refresh_e_factor(active_extruder); });
  166. #define EDIT_FLOW(N) EDIT_ITEM_N(int3, N, MSG_FLOW_N, &planner.flow_percentage[N], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); })
  167. for (uint8_t n = 0; n < EXTRUDERS; n++) EDIT_FLOW(n);
  168. #endif
  169. //
  170. // Babystep X:
  171. // Babystep Y:
  172. // Babystep Z:
  173. //
  174. #if ENABLED(BABYSTEPPING)
  175. #if ENABLED(BABYSTEP_XY)
  176. SUBMENU(MSG_BABYSTEP_X, []{ _lcd_babystep_go(_lcd_babystep_x); });
  177. SUBMENU(MSG_BABYSTEP_Y, []{ _lcd_babystep_go(_lcd_babystep_y); });
  178. #endif
  179. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  180. SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
  181. #else
  182. SUBMENU(MSG_BABYSTEP_Z, lcd_babystep_z);
  183. #endif
  184. #endif
  185. END_MENU();
  186. }
  187. #endif // HAS_LCD_MENU