lcd.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. //lcd.h
  2. #ifndef _LCD_H
  3. #define _LCD_H
  4. #include <inttypes.h>
  5. #define LCD_UPDATE_INTERVAL 100
  6. #define LCD_TIMEOUT_TO_STATUS 30000
  7. typedef void (*lcd_longpress_func_t)(void);
  8. typedef void (*lcd_charsetup_func_t)(void);
  9. typedef void (*lcd_lcdupdate_func_t)(void);
  10. //Set to none-zero when the LCD needs to draw, decreased after every draw. Set to 2 in LCD routines so the LCD gets at least 1 full redraw (first redraw is partial)
  11. extern uint8_t lcd_draw_update;
  12. extern int32_t lcd_encoder;
  13. extern uint8_t lcd_encoder_bits;
  14. // lcd_encoder_diff is updated from interrupt context and added to lcd_encoder every LCD update
  15. extern int8_t lcd_encoder_diff;
  16. //the last checked lcd_buttons in a bit array.
  17. extern uint8_t lcd_buttons;
  18. extern uint8_t lcd_button_pressed;
  19. extern uint8_t lcd_update_enabled;
  20. extern uint32_t lcd_timeoutToStatus;
  21. extern uint32_t lcd_next_update_millis;
  22. extern uint8_t lcd_status_update_delay;
  23. extern uint8_t lcd_long_press_active;
  24. extern lcd_longpress_func_t lcd_longpress_func;
  25. extern lcd_charsetup_func_t lcd_charsetup_func;
  26. extern lcd_lcdupdate_func_t lcd_lcdupdate_func;
  27. extern uint8_t lcd_clicked(void);
  28. extern void lcd_set_cursor(uint8_t c, uint8_t r);
  29. extern void lcd_beeper_quick_feedback(void);
  30. //Cause an LCD refresh, and give the user visual or audible feedback that something has happened
  31. extern void lcd_quick_feedback(void);
  32. extern int lcd_puts_P(const char* str);
  33. extern int lcd_putc(int c);
  34. extern int lcd_printf_P(const char* format, ...);
  35. extern void lcd_update(uint8_t lcdDrawUpdateOverride);
  36. extern void lcd_update_enable(uint8_t enabled);
  37. extern void lcd_buttons_update(void);
  38. #include "Configuration_prusa.h"
  39. #include "Marlin.h"
  40. /**
  41. * Implementation of the LCD display routines for a Hitachi HD44780 display. These are common LCD character displays.
  42. * When selecting the Russian language, a slightly different LCD implementation is used to handle UTF8 characters.
  43. **/
  44. ////////////////////////////////////
  45. // Setup button and encode mappings for each panel (into 'lcd_buttons' variable
  46. //
  47. // This is just to map common functions (across different panels) onto the same
  48. // macro name. The mapping is independent of whether the button is directly connected or
  49. // via a shift/i2c register.
  50. #define BLEN_B 1
  51. #define BLEN_A 0
  52. #define EN_B (1<<BLEN_B) // The two encoder pins are connected through BTN_EN1 and BTN_EN2
  53. #define EN_A (1<<BLEN_A)
  54. #define BLEN_C 2
  55. #define EN_C (1<<BLEN_C)
  56. #define LCD_CLICKED (lcd_buttons&EN_C)
  57. ////////////////////////
  58. // Setup Rotary Encoder Bit Values (for two pin encoders to indicate movement)
  59. // These values are independent of which pins are used for EN_A and EN_B indications
  60. // The rotary encoder part is also independent to the chipset used for the LCD
  61. #define encrot0 0
  62. #define encrot1 2
  63. #define encrot2 3
  64. #define encrot3 1
  65. ////////////////////////////////////
  66. // Create LCD class instance and chipset-specific information
  67. #include "LiquidCrystal_Prusa.h"
  68. #define LCD_CLASS LiquidCrystal_Prusa
  69. extern LCD_CLASS lcd;
  70. //Custom characters defined in the first 8 characters of the LCD
  71. #define LCD_STR_BEDTEMP "\x00"
  72. #define LCD_STR_DEGREE "\x01"
  73. #define LCD_STR_THERMOMETER "\x02"
  74. #define LCD_STR_UPLEVEL "\x03"
  75. #define LCD_STR_REFRESH "\x04"
  76. #define LCD_STR_FOLDER "\x05"
  77. #define LCD_STR_FEEDRATE "\x06"
  78. #define LCD_STR_CLOCK "\x07"
  79. #define LCD_STR_ARROW_UP "\x0B"
  80. #define LCD_STR_ARROW_DOWN "\x01"
  81. #define LCD_STR_ARROW_RIGHT "\x7E" //from the default character set
  82. extern void lcd_set_custom_characters(void);
  83. extern void lcd_set_custom_characters_arrows(void);
  84. extern void lcd_set_custom_characters_progress(void);
  85. extern void lcd_set_custom_characters_nextpage(void);
  86. extern void lcd_set_custom_characters_degree(void);
  87. extern void lcd_implementation_init(void);
  88. extern void lcd_implementation_init_noclear(void);
  89. extern void lcd_implementation_clear(void);
  90. // Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own
  91. extern void lcd_printPGM(const char* str);
  92. extern void lcd_print_at_PGM(uint8_t x, uint8_t y, const char* str);
  93. extern void lcd_print(int8_t i);
  94. extern void lcd_print_at(uint8_t x, uint8_t y, int8_t i);
  95. extern void lcd_print(int i);
  96. extern void lcd_print_at(uint8_t x, uint8_t y, int i);
  97. extern void lcd_print(float f);
  98. extern void lcd_print(const char *str);
  99. extern void lcd_print_at(uint8_t x, uint8_t y, const char *str);
  100. extern void lcd_drawedit(const char* pstr, char* value);
  101. extern void lcd_drawedit_2(const char* pstr, char* value);
  102. #endif //_LCD_H