ultralcd.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. #ifndef ULTRALCD_H
  2. #define ULTRALCD_H
  3. #include "Marlin.h"
  4. #include "lcd.h"
  5. #include "conv2str.h"
  6. #include "menu.h"
  7. #include "mesh_bed_calibration.h"
  8. #include "config.h"
  9. extern void menu_lcd_longpress_func(void);
  10. extern void menu_lcd_charsetup_func(void);
  11. extern void menu_lcd_lcdupdate_func(void);
  12. // Call with a false parameter to suppress the LCD update from various places like the planner or the temp control.
  13. void ultralcd_init();
  14. void lcd_setstatus(const char* message);
  15. void lcd_setstatuspgm(const char* message);
  16. //! return to the main status screen and display the alert message
  17. //! Beware - it has sideeffects:
  18. //! - always returns the display to the main status screen
  19. //! - always makes lcd_reset (which is slow and causes flicker)
  20. //! - does not update the message if there is already one (i.e. lcd_status_message_level > 0)
  21. void lcd_setalertstatuspgm(const char* message);
  22. //! only update the alert message on the main status screen
  23. //! has no sideeffects, may be called multiple times
  24. void lcd_updatestatuspgm(const char *message);
  25. void lcd_reset_alert_level();
  26. uint8_t get_message_level();
  27. void lcd_adjust_z();
  28. void lcd_pick_babystep();
  29. void lcd_alright();
  30. void show_preheat_nozzle_warning();
  31. void EEPROM_save_B(int pos, int* value);
  32. void EEPROM_read_B(int pos, int* value);
  33. void lcd_wait_interact();
  34. void lcd_loading_filament();
  35. void lcd_change_success();
  36. void lcd_loading_color();
  37. void lcd_sdcard_stop();
  38. void lcd_pause_print();
  39. void lcd_resume_print();
  40. void lcd_print_stop();
  41. void prusa_statistics(int _message, uint8_t _col_nr = 0);
  42. void lcd_confirm_print();
  43. unsigned char lcd_choose_color();
  44. void lcd_load_filament_color_check();
  45. //void lcd_mylang();
  46. extern bool lcd_selftest();
  47. void lcd_menu_statistics();
  48. void lcd_menu_extruder_info(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
  49. void lcd_menu_show_sensors_state(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
  50. #ifdef TMC2130
  51. bool lcd_crash_detect_enabled();
  52. void lcd_crash_detect_enable();
  53. void lcd_crash_detect_disable();
  54. #endif
  55. extern const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines);
  56. extern const char* lcd_display_message_fullscreen_P(const char *msg);
  57. extern void lcd_return_to_status();
  58. extern void lcd_wait_for_click();
  59. extern bool lcd_wait_for_click_delay(uint16_t nDelay);
  60. extern void lcd_show_fullscreen_message_and_wait_P(const char *msg);
  61. // 0: no, 1: yes, -1: timeouted
  62. extern int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, bool default_yes = false);
  63. extern int8_t lcd_show_multiscreen_message_two_choices_and_wait_P(const char *msg, bool allow_timeouting, bool default_yes,
  64. const char *first_choice, const char *second_choice);
  65. extern int8_t lcd_show_multiscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, bool default_yes = false);
  66. // Ask the user to move the Z axis up to the end stoppers and let
  67. // the user confirm that it has been done.
  68. #ifndef TMC2130
  69. extern bool lcd_calibrate_z_end_stop_manual(bool only_z);
  70. #endif
  71. // Show the result of the calibration process on the LCD screen.
  72. extern void lcd_bed_calibration_show_result(BedSkewOffsetDetectionResultType result, uint8_t point_too_far_mask);
  73. extern void lcd_diag_show_end_stops();
  74. #define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x))
  75. #define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatuspgm(PSTR(x))
  76. #define LCD_MESSAGERPGM(x) lcd_setstatuspgm((x))
  77. #define LCD_ALERTMESSAGERPGM(x) lcd_setalertstatuspgm((x))
  78. // To be used in lcd_commands_type.
  79. enum class LcdCommands : uint_least8_t
  80. {
  81. Idle,
  82. LoadFilament,
  83. StopPrint,
  84. FarmModeConfirm,
  85. LongPause,
  86. PidExtruder,
  87. Layer1Cal,
  88. };
  89. extern LcdCommands lcd_commands_type;
  90. extern int8_t FSensorStateMenu;
  91. enum class CustomMsg : uint_least8_t
  92. {
  93. Status, //!< status message from lcd_status_message variable
  94. MeshBedLeveling, //!< Mesh bed leveling in progress
  95. FilamentLoading, //!< Loading filament in progress
  96. PidCal, //!< PID tuning in progress
  97. TempCal, //!< PINDA temperature calibration
  98. TempCompPreheat, //!< Temperature compensation preheat
  99. };
  100. extern CustomMsg custom_message_type;
  101. extern unsigned int custom_message_state;
  102. extern uint8_t farm_mode;
  103. extern int farm_no;
  104. extern int farm_timer;
  105. extern uint8_t farm_status;
  106. #ifdef TMC2130
  107. #define SILENT_MODE_NORMAL 0
  108. #define SILENT_MODE_STEALTH 1
  109. #define SILENT_MODE_OFF SILENT_MODE_NORMAL
  110. #else
  111. #define SILENT_MODE_POWER 0
  112. #define SILENT_MODE_SILENT 1
  113. #define SILENT_MODE_AUTO 2
  114. #define SILENT_MODE_OFF SILENT_MODE_POWER
  115. #endif
  116. extern int8_t SilentModeMenu;
  117. extern uint8_t SilentModeMenu_MMU;
  118. extern bool cancel_heatup;
  119. extern bool isPrintPaused;
  120. void lcd_ignore_click(bool b=true);
  121. void lcd_commands();
  122. extern bool bSettings; // flag (i.e. 'fake parameter') for 'lcd_hw_setup_menu()' function
  123. void lcd_hw_setup_menu(void); // NOT static due to using inside "util" module ("nozzle_diameter_check()")
  124. void change_extr(int extr);
  125. #ifdef SNMM
  126. void extr_unload_all();
  127. void extr_unload_used();
  128. #endif //SNMM
  129. void extr_unload();
  130. enum class FilamentAction : uint_least8_t
  131. {
  132. None, //!< 'none' state is used as flag for (filament) autoLoad (i.e. opposite for 'autoLoad' state)
  133. Load,
  134. AutoLoad,
  135. UnLoad,
  136. MmuLoad,
  137. MmuUnLoad,
  138. MmuEject,
  139. MmuCut,
  140. Preheat,
  141. };
  142. extern FilamentAction eFilamentAction;
  143. extern bool bFilamentFirstRun;
  144. extern bool bFilamentPreheatState;
  145. extern bool bFilamentAction;
  146. void mFilamentItem(uint16_t nTemp,uint16_t nTempBed);
  147. void mFilamentItemForce();
  148. void mFilamentMenu();
  149. void unload_filament();
  150. void stack_error();
  151. void lcd_printer_connected();
  152. void lcd_ping();
  153. void lcd_calibrate_extruder();
  154. void lcd_farm_sdcard_menu();
  155. //void getFileDescription(char *name, char *description);
  156. void lcd_farm_sdcard_menu_w();
  157. //void get_description();
  158. void lcd_wait_for_heater();
  159. void lcd_wait_for_cool_down();
  160. void lcd_extr_cal_reset();
  161. void lcd_temp_cal_show_result(bool result);
  162. bool lcd_wait_for_pinda(float temp);
  163. void bowden_menu();
  164. char reset_menu();
  165. uint8_t choose_menu_P(const char *header, const char *item, const char *last_item = nullptr);
  166. void lcd_pinda_calibration_menu();
  167. void lcd_calibrate_pinda();
  168. void lcd_temp_calibration_set();
  169. void display_loading();
  170. #if !SDSORT_USES_RAM
  171. void lcd_set_degree();
  172. void lcd_set_progress();
  173. #endif
  174. void lcd_language();
  175. void lcd_wizard();
  176. bool lcd_autoDepleteEnabled();
  177. //! @brief Wizard state
  178. enum class WizState : uint8_t
  179. {
  180. Run, //!< run wizard? Entry point.
  181. Restore, //!< restore calibration status
  182. Selftest,
  183. Xyz, //!< xyz calibration
  184. Z, //!< z calibration
  185. IsFil, //!< Is filament loaded? Entry point for 1st layer calibration
  186. PreheatPla, //!< waiting for preheat nozzle for PLA
  187. Preheat, //!< Preheat for any material
  188. Unload, //!< Unload filament
  189. LoadFil, //!< Load filament
  190. IsPla, //!< Is PLA filament?
  191. Lay1Cal, //!< First layer calibration
  192. RepeatLay1Cal, //!< Repeat first layer calibration?
  193. Finish, //!< Deactivate wizard
  194. };
  195. void lcd_wizard(WizState state);
  196. #define VOLT_DIV_REF 5
  197. #if IR_SENSOR_ANALOG
  198. #define IRsensor_Hmin_TRESHOLD (3.0*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~3.0V (0.6*Vcc)
  199. #define IRsensor_Lmax_TRESHOLD (1.5*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~1.5V (0.3*Vcc)
  200. #define IRsensor_Hopen_TRESHOLD (4.6*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~4.6V (N.C. @ Ru~20-50k, Rd'=56k, Ru'=10k)
  201. #define IRsensor_Ldiode_TRESHOLD (0.3*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~0.3V
  202. #endif //IR_SENSOR_ANALOG
  203. #endif //ULTRALCD_H