ultralcd.h 10 KB

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