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.

ultralcd.h 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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. #ifndef ULTRALCD_H
  23. #define ULTRALCD_H
  24. #include "../inc/MarlinConfig.h"
  25. #if ENABLED(ULTRA_LCD) || ENABLED(MALYAN_LCD)
  26. void lcd_init();
  27. bool lcd_detected();
  28. void lcd_update();
  29. void lcd_setalertstatusPGM(const char* message);
  30. #else
  31. inline void lcd_init() {}
  32. inline bool lcd_detected() { return true; }
  33. inline void lcd_update() {}
  34. inline void lcd_setalertstatusPGM(const char* message) { UNUSED(message); }
  35. #endif
  36. #if ENABLED(ULTRA_LCD)
  37. #include "../Marlin.h"
  38. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  39. #include "../feature/pause.h"
  40. #include "../module/motion.h" // for active_extruder
  41. #endif
  42. bool lcd_hasstatus();
  43. void lcd_setstatus(const char* message, const bool persist=false);
  44. void lcd_setstatusPGM(const char* message, const int8_t level=0);
  45. void lcd_setalertstatusPGM(const char* message);
  46. void lcd_reset_alert_level();
  47. void lcd_reset_status();
  48. void lcd_status_printf_P(const uint8_t level, const char * const fmt, ...);
  49. void lcd_kill_screen();
  50. void kill_screen(const char* lcd_msg);
  51. extern uint8_t lcdDrawUpdate;
  52. inline void lcd_refresh() { lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; }
  53. #if HAS_BUZZER
  54. void lcd_buzz(const long duration, const uint16_t freq);
  55. #endif
  56. void lcd_quick_feedback(const bool clear_buttons); // Audible feedback for a button click - could also be visual
  57. #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
  58. void dontExpireStatus();
  59. #endif
  60. #if ENABLED(LCD_SET_PROGRESS_MANUALLY)
  61. extern uint8_t progress_bar_percent;
  62. #endif
  63. #if ENABLED(ADC_KEYPAD)
  64. uint8_t get_ADC_keyValue();
  65. #endif
  66. #if ENABLED(DOGLCD)
  67. extern int16_t lcd_contrast;
  68. void set_lcd_contrast(const int16_t value);
  69. #endif
  70. #if ENABLED(SHOW_BOOTSCREEN)
  71. void lcd_bootscreen();
  72. #endif
  73. #define LCD_UPDATE_INTERVAL 100
  74. #define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
  75. #define BUTTON_PRESSED(BN) !READ(BTN_## BN)
  76. #if ENABLED(ULTIPANEL) // LCD with a click-wheel input
  77. extern bool defer_return_to_status;
  78. // Function pointer to menu functions.
  79. typedef void (*screenFunc_t)();
  80. typedef void (*menuAction_t)();
  81. extern int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
  82. #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
  83. extern bool lcd_external_control;
  84. #else
  85. constexpr bool lcd_external_control = false;
  86. #endif
  87. #if ENABLED(LCD_BED_LEVELING)
  88. extern bool lcd_wait_for_move;
  89. #else
  90. constexpr bool lcd_wait_for_move = false;
  91. #endif
  92. void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder=0);
  93. void lcd_completion_feedback(const bool good=true);
  94. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  95. void lcd_advanced_pause_show_message(const AdvancedPauseMessage message,
  96. const AdvancedPauseMode mode=ADVANCED_PAUSE_MODE_PAUSE_PRINT,
  97. const uint8_t extruder=active_extruder);
  98. #endif
  99. #if ENABLED(G26_MESH_VALIDATION)
  100. void lcd_chirp();
  101. #endif
  102. #if ENABLED(AUTO_BED_LEVELING_UBL)
  103. void lcd_mesh_edit_setup(const float &initial);
  104. float lcd_mesh_edit();
  105. void lcd_z_offset_edit_setup(const float &initial);
  106. float lcd_z_offset_edit();
  107. #endif
  108. #endif
  109. #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
  110. extern millis_t previous_lcd_status_ms;
  111. #endif
  112. bool lcd_blink();
  113. #if ENABLED(REPRAPWORLD_KEYPAD) // is also ULTIPANEL and NEWPANEL
  114. #define REPRAPWORLD_BTN_OFFSET 0 // bit offset into buttons for shift register values
  115. #define BLEN_REPRAPWORLD_KEYPAD_F3 0
  116. #define BLEN_REPRAPWORLD_KEYPAD_F2 1
  117. #define BLEN_REPRAPWORLD_KEYPAD_F1 2
  118. #define BLEN_REPRAPWORLD_KEYPAD_DOWN 3
  119. #define BLEN_REPRAPWORLD_KEYPAD_RIGHT 4
  120. #define BLEN_REPRAPWORLD_KEYPAD_MIDDLE 5
  121. #define BLEN_REPRAPWORLD_KEYPAD_UP 6
  122. #define BLEN_REPRAPWORLD_KEYPAD_LEFT 7
  123. #define EN_REPRAPWORLD_KEYPAD_F3 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F3))
  124. #define EN_REPRAPWORLD_KEYPAD_F2 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F2))
  125. #define EN_REPRAPWORLD_KEYPAD_F1 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F1))
  126. #define EN_REPRAPWORLD_KEYPAD_DOWN (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_DOWN))
  127. #define EN_REPRAPWORLD_KEYPAD_RIGHT (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_RIGHT))
  128. #define EN_REPRAPWORLD_KEYPAD_MIDDLE (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_MIDDLE))
  129. #define EN_REPRAPWORLD_KEYPAD_UP (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_UP))
  130. #define EN_REPRAPWORLD_KEYPAD_LEFT (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_LEFT))
  131. #define REPRAPWORLD_KEYPAD_MOVE_Z_DOWN (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_F3)
  132. #define REPRAPWORLD_KEYPAD_MOVE_Z_UP (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_F2)
  133. #define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN)
  134. #define REPRAPWORLD_KEYPAD_MOVE_X_RIGHT (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT)
  135. #define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP)
  136. #define REPRAPWORLD_KEYPAD_MOVE_X_LEFT (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_LEFT)
  137. #if ENABLED(ADC_KEYPAD)
  138. #define KEYPAD_HOME EN_REPRAPWORLD_KEYPAD_F1
  139. #define KEYPAD_EN_C EN_REPRAPWORLD_KEYPAD_MIDDLE
  140. #else
  141. #define KEYPAD_HOME EN_REPRAPWORLD_KEYPAD_MIDDLE
  142. #define KEYPAD_EN_C EN_REPRAPWORLD_KEYPAD_F1
  143. #endif
  144. #define REPRAPWORLD_KEYPAD_MOVE_HOME (buttons_reprapworld_keypad & KEYPAD_HOME)
  145. #define REPRAPWORLD_KEYPAD_MOVE_MENU (buttons_reprapworld_keypad & KEYPAD_EN_C)
  146. #define REPRAPWORLD_KEYPAD_PRESSED (buttons_reprapworld_keypad & ( \
  147. EN_REPRAPWORLD_KEYPAD_F3 | \
  148. EN_REPRAPWORLD_KEYPAD_F2 | \
  149. EN_REPRAPWORLD_KEYPAD_F1 | \
  150. EN_REPRAPWORLD_KEYPAD_DOWN | \
  151. EN_REPRAPWORLD_KEYPAD_RIGHT | \
  152. EN_REPRAPWORLD_KEYPAD_MIDDLE | \
  153. EN_REPRAPWORLD_KEYPAD_UP | \
  154. EN_REPRAPWORLD_KEYPAD_LEFT) \
  155. )
  156. #endif
  157. #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
  158. bool is_lcd_clicked();
  159. void wait_for_release();
  160. #endif
  161. #else // MALYAN_LCD or no LCD
  162. constexpr bool lcd_wait_for_move = false;
  163. inline void lcd_refresh() {}
  164. inline bool lcd_hasstatus() { return false; }
  165. inline void lcd_setstatus(const char* const message, const bool persist=false) { UNUSED(message); UNUSED(persist); }
  166. inline void lcd_setstatusPGM(const char* const message, const int8_t level=0) { UNUSED(message); UNUSED(level); }
  167. inline void lcd_status_printf_P(const uint8_t level, const char * const fmt, ...) { UNUSED(level); UNUSED(fmt); }
  168. inline void lcd_reset_alert_level() {}
  169. inline void lcd_reset_status() {}
  170. #endif // ULTRA_LCD
  171. #if ENABLED(ULTIPANEL)
  172. #if ENABLED(NEWPANEL) // Uses digital switches, not a shift register
  173. // Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes)
  174. #define BLEN_A 0
  175. #define BLEN_B 1
  176. #define EN_A _BV(BLEN_A)
  177. #define EN_B _BV(BLEN_B)
  178. #if BUTTON_EXISTS(ENC)
  179. #define BLEN_C 2
  180. #define EN_C _BV(BLEN_C)
  181. #endif
  182. #if BUTTON_EXISTS(BACK)
  183. #define BLEN_D 3
  184. #define EN_D _BV(BLEN_D)
  185. #define LCD_BACK_CLICKED (buttons & EN_D)
  186. #endif
  187. #endif // NEWPANEL
  188. extern volatile uint8_t buttons; // The last-checked buttons in a bit array.
  189. void lcd_buttons_update();
  190. #else
  191. inline void lcd_buttons_update() {}
  192. #endif
  193. #if ENABLED(REPRAPWORLD_KEYPAD)
  194. #ifdef EN_C
  195. #define LCD_CLICKED ((buttons & EN_C) || REPRAPWORLD_KEYPAD_MOVE_MENU)
  196. #else
  197. #define LCD_CLICKED REPRAPWORLD_KEYPAD_MOVE_MENU
  198. #endif
  199. #elif defined(EN_C)
  200. #define LCD_CLICKED (buttons & EN_C)
  201. #else
  202. #define LCD_CLICKED false
  203. #endif
  204. #define LCD_MESSAGEPGM(x) lcd_setstatusPGM(PSTR(x))
  205. #define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatusPGM(PSTR(x))
  206. // For i2c define BUZZ to use lcd_buzz
  207. #if ENABLED(LCD_USE_I2C_BUZZER)
  208. #define BUZZ(d,f) lcd_buzz(d, f)
  209. #endif
  210. #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
  211. void lcd_reselect_last_file();
  212. #endif
  213. #if ENABLED(ULTIPANEL) && ENABLED(SDSUPPORT)
  214. extern bool abort_sd_printing;
  215. #else
  216. constexpr bool abort_sd_printing = false;
  217. #endif
  218. #endif // ULTRALCD_H