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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  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. #pragma once
  23. #include "../inc/MarlinConfig.h"
  24. #if HAS_BUZZER
  25. #include "../libs/buzzer.h"
  26. #endif
  27. #if EITHER(HAS_LCD_MENU, ULTIPANEL_FEEDMULTIPLY)
  28. #define HAS_ENCODER_ACTION 1
  29. #endif
  30. #if (!HAS_ADC_BUTTONS && ENABLED(NEWPANEL)) || BUTTONS_EXIST(EN1, EN2)
  31. #define HAS_ENCODER_WHEEL 1
  32. #endif
  33. #if HAS_ENCODER_WHEEL || ANY_BUTTON(ENC, BACK, UP, DWN, LFT, RT)
  34. #define HAS_DIGITAL_BUTTONS 1
  35. #endif
  36. #if !HAS_ADC_BUTTONS && (ENABLED(REPRAPWORLD_KEYPAD) || (HAS_SPI_LCD && DISABLED(NEWPANEL)))
  37. #define HAS_SHIFT_ENCODER 1
  38. #endif
  39. // I2C buttons must be read in the main thread
  40. #if EITHER(LCD_I2C_VIKI, LCD_I2C_PANELOLU2)
  41. #define HAS_SLOW_BUTTONS 1
  42. #endif
  43. #if HAS_SPI_LCD
  44. #include "../MarlinCore.h"
  45. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  46. #include "../feature/pause.h"
  47. #include "../module/motion.h" // for active_extruder
  48. #endif
  49. enum LCDViewAction : uint8_t {
  50. LCDVIEW_NONE,
  51. LCDVIEW_REDRAW_NOW,
  52. LCDVIEW_CALL_REDRAW_NEXT,
  53. LCDVIEW_CLEAR_CALL_REDRAW,
  54. LCDVIEW_CALL_NO_REDRAW
  55. };
  56. #if HAS_ADC_BUTTONS
  57. uint8_t get_ADC_keyValue();
  58. #endif
  59. #define LCD_UPDATE_INTERVAL TERN(TOUCH_BUTTONS, 50, 100)
  60. #if HAS_LCD_MENU
  61. #if HAS_GRAPHICAL_LCD
  62. #define SETCURSOR(col, row) lcd_moveto(col * (MENU_FONT_WIDTH), (row + 1) * (MENU_FONT_HEIGHT))
  63. #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH), (row + 1) * (MENU_FONT_HEIGHT))
  64. #else
  65. #define SETCURSOR(col, row) lcd_moveto(col, row)
  66. #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_WIDTH - (len), row)
  67. #endif
  68. #include "lcdprint.h"
  69. void _wrap_string(uint8_t &col, uint8_t &row, const char * const string, read_byte_cb_t cb_read_byte, const bool wordwrap=false);
  70. inline void wrap_string_P(uint8_t &col, uint8_t &row, PGM_P const pstr, const bool wordwrap=false) { _wrap_string(col, row, pstr, read_byte_rom, wordwrap); }
  71. inline void wrap_string(uint8_t &col, uint8_t &row, const char * const string, const bool wordwrap=false) { _wrap_string(col, row, string, read_byte_ram, wordwrap); }
  72. #if ENABLED(SDSUPPORT)
  73. #include "../sd/cardreader.h"
  74. #endif
  75. typedef void (*screenFunc_t)();
  76. typedef void (*menuAction_t)();
  77. // Manual Movement
  78. extern float move_menu_scale;
  79. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  80. void lcd_pause_show_message(const PauseMessage message,
  81. const PauseMode mode=PAUSE_MODE_SAME,
  82. const uint8_t extruder=active_extruder);
  83. #endif
  84. #if ENABLED(AUTO_BED_LEVELING_UBL)
  85. void lcd_mesh_edit_setup(const float &initial);
  86. float lcd_mesh_edit();
  87. #endif
  88. #endif // HAS_LCD_MENU
  89. #endif
  90. // REPRAPWORLD_KEYPAD (and ADC_KEYPAD)
  91. #if ENABLED(REPRAPWORLD_KEYPAD)
  92. #define BTN_OFFSET 0 // Bit offset into buttons for shift register values
  93. #define BLEN_KEYPAD_F3 0
  94. #define BLEN_KEYPAD_F2 1
  95. #define BLEN_KEYPAD_F1 2
  96. #define BLEN_KEYPAD_DOWN 3
  97. #define BLEN_KEYPAD_RIGHT 4
  98. #define BLEN_KEYPAD_MIDDLE 5
  99. #define BLEN_KEYPAD_UP 6
  100. #define BLEN_KEYPAD_LEFT 7
  101. #define EN_KEYPAD_F1 _BV(BTN_OFFSET + BLEN_KEYPAD_F1)
  102. #define EN_KEYPAD_F2 _BV(BTN_OFFSET + BLEN_KEYPAD_F2)
  103. #define EN_KEYPAD_F3 _BV(BTN_OFFSET + BLEN_KEYPAD_F3)
  104. #define EN_KEYPAD_DOWN _BV(BTN_OFFSET + BLEN_KEYPAD_DOWN)
  105. #define EN_KEYPAD_RIGHT _BV(BTN_OFFSET + BLEN_KEYPAD_RIGHT)
  106. #define EN_KEYPAD_MIDDLE _BV(BTN_OFFSET + BLEN_KEYPAD_MIDDLE)
  107. #define EN_KEYPAD_UP _BV(BTN_OFFSET + BLEN_KEYPAD_UP)
  108. #define EN_KEYPAD_LEFT _BV(BTN_OFFSET + BLEN_KEYPAD_LEFT)
  109. #define RRK(B) (keypad_buttons & (B))
  110. #ifdef EN_C
  111. #define BUTTON_CLICK() ((buttons & EN_C) || RRK(EN_KEYPAD_MIDDLE))
  112. #else
  113. #define BUTTON_CLICK() RRK(EN_KEYPAD_MIDDLE)
  114. #endif
  115. #endif
  116. #if HAS_DIGITAL_BUTTONS
  117. // Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes)
  118. #define BLEN_A 0
  119. #define BLEN_B 1
  120. #define EN_A _BV(BLEN_A)
  121. #define EN_B _BV(BLEN_B)
  122. #define BUTTON_PRESSED(BN) !READ(BTN_## BN)
  123. #if BUTTON_EXISTS(ENC) || ENABLED(TOUCH_BUTTONS)
  124. #define BLEN_C 2
  125. #define EN_C _BV(BLEN_C)
  126. #endif
  127. #if ENABLED(LCD_I2C_VIKI)
  128. #include <LiquidTWI2.h>
  129. #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
  130. // button and encoder bit positions within 'buttons'
  131. #define B_LE (BUTTON_LEFT << B_I2C_BTN_OFFSET) // The remaining normalized buttons are all read via I2C
  132. #define B_UP (BUTTON_UP << B_I2C_BTN_OFFSET)
  133. #define B_MI (BUTTON_SELECT << B_I2C_BTN_OFFSET)
  134. #define B_DW (BUTTON_DOWN << B_I2C_BTN_OFFSET)
  135. #define B_RI (BUTTON_RIGHT << B_I2C_BTN_OFFSET)
  136. #if BUTTON_EXISTS(ENC) // The pause/stop/restart button is connected to BTN_ENC when used
  137. #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name
  138. #define BUTTON_CLICK() (buttons & (B_MI|B_RI|B_ST)) // Pause/stop also acts as click until a proper pause/stop is implemented.
  139. #else
  140. #define BUTTON_CLICK() (buttons & (B_MI|B_RI))
  141. #endif
  142. // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
  143. #elif ENABLED(LCD_I2C_PANELOLU2)
  144. #if !BUTTON_EXISTS(ENC) // Use I2C if not directly connected to a pin
  145. #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
  146. #define B_MI (PANELOLU2_ENCODER_C << B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
  147. #define BUTTON_CLICK() (buttons & B_MI)
  148. #endif
  149. #endif
  150. #else
  151. #undef BUTTON_EXISTS
  152. #define BUTTON_EXISTS(...) false
  153. // Shift register bits correspond to buttons:
  154. #define BL_LE 7 // Left
  155. #define BL_UP 6 // Up
  156. #define BL_MI 5 // Middle
  157. #define BL_DW 4 // Down
  158. #define BL_RI 3 // Right
  159. #define BL_ST 2 // Red Button
  160. #define B_LE _BV(BL_LE)
  161. #define B_UP _BV(BL_UP)
  162. #define B_MI _BV(BL_MI)
  163. #define B_DW _BV(BL_DW)
  164. #define B_RI _BV(BL_RI)
  165. #define B_ST _BV(BL_ST)
  166. #ifndef BUTTON_CLICK
  167. #define BUTTON_CLICK() (buttons & (B_MI|B_ST))
  168. #endif
  169. #endif
  170. #if BUTTON_EXISTS(BACK) || ENABLED(TOUCH_BUTTONS)
  171. #define BLEN_D 3
  172. #define EN_D _BV(BLEN_D)
  173. #define LCD_BACK_CLICKED() (buttons & EN_D)
  174. #else
  175. #define LCD_BACK_CLICKED() false
  176. #endif
  177. #ifndef BUTTON_CLICK
  178. #ifdef EN_C
  179. #define BUTTON_CLICK() (buttons & EN_C)
  180. #else
  181. #define BUTTON_CLICK() false
  182. #endif
  183. #endif
  184. #if HAS_GRAPHICAL_LCD
  185. enum MarlinFont : uint8_t {
  186. FONT_STATUSMENU = 1,
  187. FONT_EDIT,
  188. FONT_MENU
  189. };
  190. #else
  191. enum HD44780CharSet : uint8_t {
  192. CHARSET_MENU,
  193. CHARSET_INFO,
  194. CHARSET_BOOT
  195. };
  196. #endif
  197. ////////////////////////////////////////////
  198. //////////// MarlinUI Singleton ////////////
  199. ////////////////////////////////////////////
  200. class MarlinUI {
  201. public:
  202. MarlinUI() {
  203. TERN_(HAS_LCD_MENU, currentScreen = status_screen);
  204. }
  205. #if HAS_BUZZER
  206. static void buzz(const long duration, const uint16_t freq);
  207. #endif
  208. #if ENABLED(LCD_HAS_STATUS_INDICATORS)
  209. static void update_indicators();
  210. #endif
  211. // LCD implementations
  212. static void clear_lcd();
  213. #if ENABLED(SDSUPPORT)
  214. static void media_changed(const uint8_t old_stat, const uint8_t stat);
  215. #endif
  216. #if HAS_SPI_LCD
  217. static bool detected();
  218. static void init_lcd();
  219. FORCE_INLINE static void refresh() { refresh(LCDVIEW_CLEAR_CALL_REDRAW); }
  220. #else
  221. static inline bool detected() { return true; }
  222. static inline void init_lcd() {}
  223. static inline void refresh() {}
  224. #endif
  225. #if HAS_DISPLAY
  226. static void init();
  227. static void update();
  228. static void set_alert_status_P(PGM_P const message);
  229. static char status_message[];
  230. static bool has_status();
  231. static uint8_t alert_level; // Higher levels block lower levels
  232. static inline void reset_alert_level() { alert_level = 0; }
  233. #if ENABLED(STATUS_MESSAGE_SCROLLING)
  234. static uint8_t status_scroll_offset;
  235. static void advance_status_scroll();
  236. static char* status_and_len(uint8_t &len);
  237. #endif
  238. static void abort_print();
  239. static void pause_print();
  240. static void resume_print();
  241. #if HAS_PRINT_PROGRESS
  242. #if HAS_PRINT_PROGRESS_PERMYRIAD
  243. typedef uint16_t progress_t;
  244. #define PROGRESS_SCALE 100U
  245. #define PROGRESS_MASK 0x7FFF
  246. #else
  247. typedef uint8_t progress_t;
  248. #define PROGRESS_SCALE 1U
  249. #define PROGRESS_MASK 0x7F
  250. #endif
  251. #if ENABLED(LCD_SET_PROGRESS_MANUALLY)
  252. static progress_t progress_override;
  253. static void set_progress(const progress_t p) { progress_override = _MIN(p, 100U * (PROGRESS_SCALE)); }
  254. static void set_progress_done() { progress_override = (PROGRESS_MASK + 1U) + 100U * (PROGRESS_SCALE); }
  255. static void progress_reset() { if (progress_override & (PROGRESS_MASK + 1U)) set_progress(0); }
  256. #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
  257. static uint32_t remaining_time;
  258. FORCE_INLINE static void set_remaining_time(const uint32_t r) { remaining_time = r; }
  259. FORCE_INLINE static uint32_t get_remaining_time() { return remaining_time; }
  260. FORCE_INLINE static void reset_remaining_time() { set_remaining_time(0); }
  261. #endif
  262. #endif
  263. static progress_t _get_progress();
  264. #if HAS_PRINT_PROGRESS_PERMYRIAD
  265. FORCE_INLINE static uint16_t get_progress_permyriad() { return _get_progress(); }
  266. #endif
  267. static uint8_t get_progress_percent() { return uint8_t(_get_progress() / (PROGRESS_SCALE)); }
  268. #else
  269. static constexpr uint8_t get_progress_percent() { return 0; }
  270. #endif
  271. #if HAS_SPI_LCD
  272. static millis_t next_button_update_ms;
  273. static LCDViewAction lcdDrawUpdate;
  274. FORCE_INLINE static bool should_draw() { return bool(lcdDrawUpdate); }
  275. FORCE_INLINE static void refresh(const LCDViewAction type) { lcdDrawUpdate = type; }
  276. #if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
  277. static void draw_custom_bootscreen(const uint8_t frame=0);
  278. static void show_custom_bootscreen();
  279. #endif
  280. #if ENABLED(SHOW_BOOTSCREEN)
  281. #ifndef BOOTSCREEN_TIMEOUT
  282. #define BOOTSCREEN_TIMEOUT 2500
  283. #endif
  284. static void draw_marlin_bootscreen(const bool line2=false);
  285. static void show_marlin_bootscreen();
  286. static void show_bootscreen();
  287. #endif
  288. #if HAS_GRAPHICAL_LCD
  289. static bool drawing_screen, first_page;
  290. static void set_font(const MarlinFont font_nr);
  291. #else
  292. static constexpr bool drawing_screen = false, first_page = true;
  293. static void set_custom_characters(const HD44780CharSet screen_charset=CHARSET_INFO);
  294. #if ENABLED(LCD_PROGRESS_BAR)
  295. static millis_t progress_bar_ms; // Start time for the current progress bar cycle
  296. static void draw_progress_bar(const uint8_t percent);
  297. #if PROGRESS_MSG_EXPIRE > 0
  298. static millis_t expire_status_ms; // = 0
  299. FORCE_INLINE static void reset_progress_bar_timeout() { expire_status_ms = 0; }
  300. #endif
  301. #endif
  302. #endif
  303. static uint8_t lcd_status_update_delay;
  304. #if HAS_LCD_CONTRAST
  305. static int16_t contrast;
  306. static void set_contrast(const int16_t value);
  307. FORCE_INLINE static void refresh_contrast() { set_contrast(contrast); }
  308. #endif
  309. #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
  310. static millis_t next_filament_display;
  311. #endif
  312. static void quick_feedback(const bool clear_buttons=true);
  313. #if HAS_BUZZER
  314. static void completion_feedback(const bool good=true);
  315. #else
  316. static inline void completion_feedback(const bool=true) {}
  317. #endif
  318. #if DISABLED(LIGHTWEIGHT_UI)
  319. static void draw_status_message(const bool blink);
  320. #endif
  321. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  322. static void draw_hotend_status(const uint8_t row, const uint8_t extruder);
  323. #endif
  324. static void status_screen();
  325. #endif
  326. static bool get_blink();
  327. static void kill_screen(PGM_P const lcd_error, PGM_P const lcd_component);
  328. static void draw_kill_screen();
  329. static void set_status(const char* const message, const bool persist=false);
  330. static void set_status_P(PGM_P const message, const int8_t level=0);
  331. static void status_printf_P(const uint8_t level, PGM_P const fmt, ...);
  332. static void reset_status(const bool no_welcome=false);
  333. #else // No LCD
  334. // Send status to host as a notification
  335. static void set_status(const char* message, const bool=false);
  336. static void set_status_P(PGM_P message, const int8_t=0);
  337. static void status_printf_P(const uint8_t, PGM_P message, ...);
  338. static inline void init() {}
  339. static inline void update() {}
  340. static inline void return_to_status() {}
  341. static inline void set_alert_status_P(PGM_P const) {}
  342. static inline void reset_status(const bool=false) {}
  343. static inline void reset_alert_level() {}
  344. static constexpr bool has_status() { return false; }
  345. #endif
  346. #if HAS_LCD_MENU
  347. #if ENABLED(TOUCH_BUTTONS)
  348. static uint8_t touch_buttons;
  349. static uint8_t repeat_delay;
  350. #endif
  351. #if ENABLED(ENCODER_RATE_MULTIPLIER)
  352. static bool encoderRateMultiplierEnabled;
  353. static millis_t lastEncoderMovementMillis;
  354. static void enable_encoder_multiplier(const bool onoff);
  355. #endif
  356. #if ENABLED(SDSUPPORT)
  357. #if ENABLED(SCROLL_LONG_FILENAMES)
  358. static uint8_t filename_scroll_pos, filename_scroll_max;
  359. #endif
  360. static const char * scrolled_filename(CardReader &theCard, const uint8_t maxlen, uint8_t hash, const bool doScroll);
  361. #endif
  362. #if IS_KINEMATIC
  363. static bool processing_manual_move;
  364. #else
  365. static constexpr bool processing_manual_move = false;
  366. #endif
  367. #if E_MANUAL > 1
  368. static int8_t manual_move_e_index;
  369. #else
  370. static constexpr int8_t manual_move_e_index = 0;
  371. #endif
  372. static int16_t preheat_hotend_temp[2], preheat_bed_temp[2];
  373. static uint8_t preheat_fan_speed[2];
  374. // Select Screen (modal NO/YES style dialog)
  375. static bool selection;
  376. static void set_selection(const bool sel) { selection = sel; }
  377. static bool update_selection();
  378. static void manage_manual_move();
  379. static bool lcd_clicked;
  380. static bool use_click();
  381. static void synchronize(PGM_P const msg=nullptr);
  382. static screenFunc_t currentScreen;
  383. static bool screen_changed;
  384. static void goto_screen(const screenFunc_t screen, const uint16_t encoder=0, const uint8_t top=0, const uint8_t items=0);
  385. static void save_previous_screen();
  386. // goto_previous_screen and go_back may also be used as menu item callbacks
  387. #if ENABLED(TURBO_BACK_MENU_ITEM)
  388. static void _goto_previous_screen(const bool is_back);
  389. static inline void goto_previous_screen() { _goto_previous_screen(false); }
  390. static inline void go_back() { _goto_previous_screen(true); }
  391. #else
  392. static void _goto_previous_screen();
  393. FORCE_INLINE static void goto_previous_screen() { _goto_previous_screen(); }
  394. FORCE_INLINE static void go_back() { _goto_previous_screen(); }
  395. #endif
  396. static void return_to_status();
  397. static inline bool on_status_screen() { return currentScreen == status_screen; }
  398. FORCE_INLINE static void run_current_screen() { (*currentScreen)(); }
  399. #if ENABLED(LIGHTWEIGHT_UI)
  400. static void lcd_in_status(const bool inStatus);
  401. #endif
  402. FORCE_INLINE static void defer_status_screen(const bool defer=true) {
  403. #if LCD_TIMEOUT_TO_STATUS
  404. defer_return_to_status = defer;
  405. #else
  406. UNUSED(defer);
  407. #endif
  408. }
  409. static inline void goto_previous_screen_no_defer() {
  410. defer_status_screen(false);
  411. goto_previous_screen();
  412. }
  413. #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
  414. static void reselect_last_file();
  415. #endif
  416. #if ENABLED(G26_MESH_VALIDATION)
  417. FORCE_INLINE static void chirp() {
  418. TERN_(HAS_BUZZER, buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ));
  419. }
  420. #endif
  421. #if ENABLED(AUTO_BED_LEVELING_UBL)
  422. static void ubl_plot(const uint8_t x_plot, const uint8_t y_plot);
  423. #endif
  424. static void draw_select_screen_prompt(PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr);
  425. #elif HAS_SPI_LCD
  426. static constexpr bool lcd_clicked = false;
  427. static constexpr bool on_status_screen() { return true; }
  428. FORCE_INLINE static void run_current_screen() { status_screen(); }
  429. #endif
  430. #define LCD_HAS_WAIT_FOR_MOVE EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION) || (ENABLED(LCD_BED_LEVELING) && EITHER(PROBE_MANUALLY, MESH_BED_LEVELING))
  431. #if LCD_HAS_WAIT_FOR_MOVE
  432. static bool wait_for_move;
  433. #else
  434. static constexpr bool wait_for_move = false;
  435. #endif
  436. #if HAS_LCD_MENU && EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION)
  437. static bool external_control;
  438. FORCE_INLINE static void capture() { external_control = true; }
  439. FORCE_INLINE static void release() { external_control = false; }
  440. #else
  441. static constexpr bool external_control = false;
  442. #endif
  443. #if HAS_ENCODER_ACTION
  444. static volatile uint8_t buttons;
  445. #if ENABLED(REPRAPWORLD_KEYPAD)
  446. static volatile uint8_t keypad_buttons;
  447. static bool handle_keypad();
  448. #endif
  449. #if HAS_SLOW_BUTTONS
  450. static volatile uint8_t slow_buttons;
  451. static uint8_t read_slow_buttons();
  452. #endif
  453. static void update_buttons();
  454. static inline bool button_pressed() { return BUTTON_CLICK(); }
  455. #if EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION)
  456. static void wait_for_release();
  457. #endif
  458. static uint32_t encoderPosition;
  459. #if ENABLED(REVERSE_ENCODER_DIRECTION)
  460. #define ENCODERBASE -1
  461. #else
  462. #define ENCODERBASE +1
  463. #endif
  464. #if EITHER(REVERSE_MENU_DIRECTION, REVERSE_SELECT_DIRECTION)
  465. static int8_t encoderDirection;
  466. #else
  467. static constexpr int8_t encoderDirection = ENCODERBASE;
  468. #endif
  469. FORCE_INLINE static void encoder_direction_normal() {
  470. #if EITHER(REVERSE_MENU_DIRECTION, REVERSE_SELECT_DIRECTION)
  471. encoderDirection = ENCODERBASE;
  472. #endif
  473. }
  474. FORCE_INLINE static void encoder_direction_menus() {
  475. TERN_(REVERSE_MENU_DIRECTION, encoderDirection = -(ENCODERBASE));
  476. }
  477. FORCE_INLINE static void encoder_direction_select() {
  478. TERN_(REVERSE_SELECT_DIRECTION, encoderDirection = -(ENCODERBASE));
  479. }
  480. #else
  481. static inline void update_buttons() {}
  482. #endif
  483. private:
  484. #if HAS_DISPLAY
  485. static void finish_status(const bool persist);
  486. #endif
  487. #if HAS_SPI_LCD
  488. #if HAS_LCD_MENU
  489. #if LCD_TIMEOUT_TO_STATUS
  490. static bool defer_return_to_status;
  491. #else
  492. static constexpr bool defer_return_to_status = false;
  493. #endif
  494. #endif
  495. static void draw_status_screen();
  496. #endif
  497. };
  498. extern MarlinUI ui;
  499. #define LCD_MESSAGEPGM_P(x) ui.set_status_P(x)
  500. #define LCD_ALERTMESSAGEPGM_P(x) ui.set_alert_status_P(x)
  501. #define LCD_MESSAGEPGM(x) LCD_MESSAGEPGM_P(GET_TEXT(x))
  502. #define LCD_ALERTMESSAGEPGM(x) LCD_ALERTMESSAGEPGM_P(GET_TEXT(x))