ultralcd.h 9.4 KB

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