ultralcd.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. #ifndef ULTRALCD_H
  2. #define ULTRALCD_H
  3. #include "Marlin.h"
  4. #include "mesh_bed_calibration.h"
  5. #include "Timer.h"
  6. extern int lcd_puts_P(const char* str);
  7. extern int lcd_printf_P(const char* format, ...);
  8. #ifdef ULTRA_LCD
  9. static void lcd_language_menu();
  10. void lcd_update(uint8_t lcdDrawUpdateOverride = 0);
  11. // Call with a false parameter to suppress the LCD update from various places like the planner or the temp control.
  12. void lcd_update_enable(bool enable);
  13. void lcd_init();
  14. void lcd_setstatus(const char* message);
  15. void lcd_setstatuspgm(const char* message);
  16. void lcd_setalertstatuspgm(const char* message);
  17. void lcd_reset_alert_level();
  18. uint8_t get_message_level();
  19. void lcd_adjust_z();
  20. void lcd_pick_babystep();
  21. void lcd_alright();
  22. void EEPROM_save_B(int pos, int* value);
  23. void EEPROM_read_B(int pos, int* value);
  24. void lcd_wait_interact();
  25. void lcd_change_filament();
  26. void lcd_loading_filament();
  27. void lcd_change_success();
  28. void lcd_loading_color();
  29. void lcd_sdcard_stop();
  30. void lcd_sdcard_pause();
  31. void lcd_print_stop();
  32. void prusa_statistics(int _message, uint8_t _col_nr = 0);
  33. void lcd_confirm_print();
  34. unsigned char lcd_choose_color();
  35. //void lcd_mylang();
  36. bool lcd_detected(void);
  37. static void lcd_selftest_v();
  38. extern bool lcd_selftest();
  39. static bool lcd_selfcheck_endstops();
  40. #ifdef TMC2130
  41. static void reset_crash_det(char axis);
  42. static bool lcd_selfcheck_axis_sg(char axis);
  43. static bool lcd_selfcheck_axis(int _axis, int _travel);
  44. #else
  45. static bool lcd_selfcheck_endstops();
  46. static bool lcd_selfcheck_axis(int _axis, int _travel);
  47. static bool lcd_selfcheck_pulleys(int axis);
  48. #endif //TMC2130
  49. static bool lcd_selfcheck_check_heater(bool _isbed);
  50. static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bool _clear, int _delay);
  51. static void lcd_selftest_screen_step(int _row, int _col, int _state, const char *_name, const char *_indicator);
  52. static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite);
  53. static bool lcd_selftest_fan_dialog(int _fan);
  54. static bool lcd_selftest_fsensor();
  55. static void lcd_selftest_error(int _error_no, const char *_error_1, const char *_error_2);
  56. void lcd_menu_statistics();
  57. extern const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines);
  58. inline const char* lcd_display_message_fullscreen_P(const char *msg)
  59. { uint8_t nlines; return lcd_display_message_fullscreen_P(msg, nlines); }
  60. extern void lcd_wait_for_click();
  61. extern void lcd_show_fullscreen_message_and_wait_P(const char *msg);
  62. // 0: no, 1: yes, -1: timeouted
  63. extern int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, bool default_yes = false);
  64. extern int8_t lcd_show_multiscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, bool default_yes = false);
  65. // Ask the user to move the Z axis up to the end stoppers and let
  66. // the user confirm that it has been done.
  67. #ifndef TMC2130
  68. extern bool lcd_calibrate_z_end_stop_manual(bool only_z);
  69. #endif
  70. // Show the result of the calibration process on the LCD screen.
  71. extern void lcd_bed_calibration_show_result(BedSkewOffsetDetectionResultType result, uint8_t point_too_far_mask);
  72. extern void lcd_diag_show_end_stops();
  73. #ifdef DOGLCD
  74. extern int lcd_contrast;
  75. void lcd_setcontrast(uint8_t value);
  76. #endif
  77. static unsigned char blink = 0; // Variable for visualization of fan rotation in GLCD
  78. #define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x))
  79. #define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatuspgm(PSTR(x))
  80. #define LCD_MESSAGERPGM(x) lcd_setstatuspgm((x))
  81. #define LCD_ALERTMESSAGERPGM(x) lcd_setalertstatuspgm((x))
  82. #define LCD_UPDATE_INTERVAL 100
  83. #define LCD_TIMEOUT_TO_STATUS 30000ul //!< Generic timeout to status screen in ms, when no user action.
  84. #define LCD_TIMEOUT_TO_STATUS_BABYSTEP_Z 90000ul //!< Specific timeout for lcd_babystep_z screen in ms.
  85. #ifdef ULTIPANEL
  86. void lcd_buttons_update();
  87. extern volatile uint8_t buttons; //the last checked buttons in a bit array.
  88. #ifdef REPRAPWORLD_KEYPAD
  89. extern volatile uint8_t buttons_reprapworld_keypad; // to store the keypad shift register values
  90. #endif
  91. #else
  92. FORCE_INLINE void lcd_buttons_update() {}
  93. #endif
  94. // To be used in lcd_commands_type.
  95. #define LCD_COMMAND_IDLE 0
  96. #define LCD_COMMAND_LOAD_FILAMENT 1
  97. #define LCD_COMMAND_STOP_PRINT 2
  98. #define LCD_COMMAND_FARM_MODE_CONFIRM 4
  99. #define LCD_COMMAND_LONG_PAUSE 5
  100. #define LCD_COMMAND_LONG_PAUSE_RESUME 6
  101. #define LCD_COMMAND_PID_EXTRUDER 7
  102. #define LCD_COMMAND_V2_CAL 8
  103. extern LongTimer lcd_timeoutToStatus;
  104. extern int lcd_commands_type;
  105. extern uint8_t farm_mode;
  106. extern int farm_no;
  107. extern int farm_timer;
  108. extern int farm_status;
  109. #ifdef TMC2130
  110. #define SILENT_MODE_NORMAL 0
  111. #define SILENT_MODE_STEALTH 1
  112. #define SILENT_MODE_OFF SILENT_MODE_NORMAL
  113. #else
  114. #define SILENT_MODE_POWER 0
  115. #define SILENT_MODE_SILENT 1
  116. #define SILENT_MODE_AUTO 2
  117. #define SILENT_MODE_OFF SILENT_MODE_POWER
  118. #endif
  119. extern int8_t SilentModeMenu;
  120. #ifdef SNMM
  121. extern uint8_t snmm_extruder;
  122. #endif // SNMM
  123. extern bool cancel_heatup;
  124. extern bool isPrintPaused;
  125. #ifdef FILAMENT_LCD_DISPLAY
  126. extern unsigned long message_millis;
  127. #endif
  128. void lcd_buzz(long duration,uint16_t freq);
  129. bool lcd_clicked();
  130. void lcd_ignore_click(bool b=true);
  131. void lcd_commands();
  132. #ifdef NEWPANEL
  133. #define EN_C (1<<BLEN_C)
  134. #define EN_B (1<<BLEN_B)
  135. #define EN_A (1<<BLEN_A)
  136. #define LCD_CLICKED (buttons&EN_C)
  137. #ifdef REPRAPWORLD_KEYPAD
  138. #define EN_REPRAPWORLD_KEYPAD_F3 (1<<BLEN_REPRAPWORLD_KEYPAD_F3)
  139. #define EN_REPRAPWORLD_KEYPAD_F2 (1<<BLEN_REPRAPWORLD_KEYPAD_F2)
  140. #define EN_REPRAPWORLD_KEYPAD_F1 (1<<BLEN_REPRAPWORLD_KEYPAD_F1)
  141. #define EN_REPRAPWORLD_KEYPAD_UP (1<<BLEN_REPRAPWORLD_KEYPAD_UP)
  142. #define EN_REPRAPWORLD_KEYPAD_RIGHT (1<<BLEN_REPRAPWORLD_KEYPAD_RIGHT)
  143. #define EN_REPRAPWORLD_KEYPAD_MIDDLE (1<<BLEN_REPRAPWORLD_KEYPAD_MIDDLE)
  144. #define EN_REPRAPWORLD_KEYPAD_DOWN (1<<BLEN_REPRAPWORLD_KEYPAD_DOWN)
  145. #define EN_REPRAPWORLD_KEYPAD_LEFT (1<<BLEN_REPRAPWORLD_KEYPAD_LEFT)
  146. #define LCD_CLICKED ((buttons&EN_C) || (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F1))
  147. #define REPRAPWORLD_KEYPAD_MOVE_Z_UP (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F2)
  148. #define REPRAPWORLD_KEYPAD_MOVE_Z_DOWN (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F3)
  149. #define REPRAPWORLD_KEYPAD_MOVE_X_LEFT (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_LEFT)
  150. #define REPRAPWORLD_KEYPAD_MOVE_X_RIGHT (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_RIGHT)
  151. #define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_DOWN)
  152. #define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_UP)
  153. #define REPRAPWORLD_KEYPAD_MOVE_HOME (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_MIDDLE)
  154. #endif //REPRAPWORLD_KEYPAD
  155. #else
  156. //atomic, do not change
  157. #define B_LE (1<<BL_LE)
  158. #define B_UP (1<<BL_UP)
  159. #define B_MI (1<<BL_MI)
  160. #define B_DW (1<<BL_DW)
  161. #define B_RI (1<<BL_RI)
  162. #define B_ST (1<<BL_ST)
  163. #define EN_B (1<<BLEN_B)
  164. #define EN_A (1<<BLEN_A)
  165. #define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
  166. #endif//NEWPANEL
  167. #else //no LCD
  168. FORCE_INLINE void
  169. {}
  170. FORCE_INLINE void lcd_init() {}
  171. FORCE_INLINE void lcd_setstatus(const char* message) {}
  172. FORCE_INLINE void lcd_buttons_update() {}
  173. FORCE_INLINE void lcd_reset_alert_level() {}
  174. FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {}
  175. FORCE_INLINE bool lcd_detected(void) { return true; }
  176. #define LCD_MESSAGEPGM(x)
  177. #define LCD_ALERTMESSAGEPGM(x)
  178. #endif //ULTRA_LCD
  179. char *itostr2(const uint8_t &x);
  180. char *itostr31(const int &xx);
  181. char *itostr3(const int &xx);
  182. char *itostr3left(const int &xx);
  183. char *itostr4(const int &xx);
  184. char *ftostr3(const float &x);
  185. char *ftostr31ns(const float &x); // float to string without sign character
  186. char *ftostr31(const float &x);
  187. char *ftostr32(const float &x);
  188. char *ftostr32ns(const float &x);
  189. char *ftostr43(const float &x, uint8_t offset = 0);
  190. char *ftostr12ns(const float &x);
  191. char *ftostr13ns(const float &x);
  192. char *ftostr32sp(const float &x); // remove zero-padding from ftostr32
  193. char *ftostr5(const float &x);
  194. char *ftostr51(const float &x);
  195. char *ftostr52(const float &x);
  196. extern void lcd_implementation_clear();
  197. extern void lcd_printPGM(const char* str);
  198. extern void lcd_print_at_PGM(uint8_t x, uint8_t y, const char* str);
  199. extern void lcd_implementation_write(char c);
  200. extern void lcd_implementation_print(const char *str);
  201. extern void lcd_implementation_print(int8_t i);
  202. extern void lcd_implementation_print_at(uint8_t x, uint8_t y, int8_t i);
  203. extern void lcd_implementation_print(int i);
  204. extern void lcd_implementation_print_at(uint8_t x, uint8_t y, int i);
  205. extern void lcd_implementation_print(float f);
  206. extern void lcd_implementation_print_at(uint8_t x, uint8_t y, const char *str);
  207. void change_extr(int extr);
  208. static void lcd_colorprint_change();
  209. static int get_ext_nr();
  210. void extr_adj(int extruder);
  211. static void extr_adj_0();
  212. static void extr_adj_1();
  213. static void extr_adj_2();
  214. static void extr_adj_3();
  215. static void fil_load_menu();
  216. static void fil_unload_menu();
  217. static void extr_unload_0();
  218. static void extr_unload_1();
  219. static void extr_unload_2();
  220. static void extr_unload_3();
  221. static void lcd_disable_farm_mode();
  222. static void lcd_set_fan_check();
  223. void extr_unload_all();
  224. void extr_unload_used();
  225. void extr_unload();
  226. static char snmm_stop_print_menu();
  227. #ifdef SDCARD_SORT_ALPHA
  228. static void lcd_sort_type_set();
  229. #endif
  230. static float count_e(float layer_heigth, float extrusion_width, float extrusion_length);
  231. static void lcd_babystep_z();
  232. void stack_error();
  233. void lcd_printer_connected();
  234. void lcd_ping();
  235. void lcd_calibrate_extruder();
  236. void lcd_farm_sdcard_menu();
  237. //void getFileDescription(char *name, char *description);
  238. void lcd_farm_sdcard_menu_w();
  239. //void get_description();
  240. void lcd_wait_for_heater();
  241. void lcd_wait_for_cool_down();
  242. void adjust_bed_reset();
  243. void lcd_extr_cal_reset();
  244. void lcd_temp_cal_show_result(bool result);
  245. bool lcd_wait_for_pinda(float temp);
  246. union MenuData;
  247. void bowden_menu();
  248. char reset_menu();
  249. char choose_extruder_menu();
  250. void lcd_pinda_calibration_menu();
  251. void lcd_calibrate_pinda();
  252. void lcd_temp_calibration_set();
  253. void display_loading();
  254. #if !SDSORT_USES_RAM
  255. void lcd_set_degree();
  256. void lcd_set_progress();
  257. #endif
  258. void lcd_language();
  259. void lcd_wizard();
  260. void lcd_wizard(int state);
  261. static void lcd_send_status();
  262. static void lcd_connect_printer();
  263. #endif //ULTRALCD_H