lcd.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. //lcd.h
  2. #ifndef _LCD_H
  3. #define _LCD_H
  4. #include <inttypes.h>
  5. #include <stdio.h>
  6. ////////////////////////////////////
  7. // Create LCD class instance and chipset-specific information
  8. //#include "LiquidCrystal_Prusa.h"
  9. //extern LiquidCrystal_Prusa lcd;
  10. extern FILE _lcdout;
  11. #define lcdout (&_lcdout)
  12. extern int lcd_putchar(char c, FILE *stream);
  13. extern void lcd_init(void);
  14. extern void lcd_refresh(void);
  15. extern void lcd_refresh_noclear(void);
  16. extern void lcd_clear(void);
  17. extern void lcd_home(void);
  18. /*extern void lcd_no_display(void);
  19. extern void lcd_display(void);
  20. extern void lcd_no_blink(void);
  21. extern void lcd_blink(void);
  22. extern void lcd_no_cursor(void);
  23. extern void lcd_cursor(void);
  24. extern void lcd_scrollDisplayLeft(void);
  25. extern void lcd_scrollDisplayRight(void);
  26. extern void lcd_leftToRight(void);
  27. extern void lcd_rightToLeft(void);
  28. extern void lcd_autoscroll(void);
  29. extern void lcd_no_autoscroll(void);*/
  30. extern void lcd_set_cursor(uint8_t col, uint8_t row);
  31. extern void lcd_createChar_P(uint8_t, const uint8_t*);
  32. extern int lcd_putc(int c);
  33. extern int lcd_puts_P(const char* str);
  34. extern int lcd_puts_at_P(uint8_t c, uint8_t r, const char* str);
  35. extern int lcd_printf_P(const char* format, ...);
  36. extern void lcd_printNumber(unsigned long n, uint8_t base);
  37. extern void lcd_printFloat(double number, uint8_t digits);
  38. extern void lcd_print(const char*);
  39. extern void lcd_print(char, int = 0);
  40. extern void lcd_print(unsigned char, int = 0);
  41. extern void lcd_print(int, int = 10);
  42. extern void lcd_print(unsigned int, int = 10);
  43. extern void lcd_print(long, int = 10);
  44. extern void lcd_print(unsigned long, int = 10);
  45. extern void lcd_print(double, int = 2);
  46. #define ESC_2J "\x1b[2J"
  47. #define ESC_25h "\x1b[?25h"
  48. #define ESC_25l "\x1b[?25l"
  49. #define ESC_H(c,r) "\x1b["#r";"#c"H"
  50. #define LCD_UPDATE_INTERVAL 100
  51. #define LCD_TIMEOUT_TO_STATUS 30000
  52. typedef void (*lcd_longpress_func_t)(void);
  53. typedef void (*lcd_charsetup_func_t)(void);
  54. typedef void (*lcd_lcdupdate_func_t)(void);
  55. //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)
  56. extern uint8_t lcd_draw_update;
  57. extern int32_t lcd_encoder;
  58. extern uint8_t lcd_encoder_bits;
  59. // lcd_encoder_diff is updated from interrupt context and added to lcd_encoder every LCD update
  60. extern int8_t lcd_encoder_diff;
  61. //the last checked lcd_buttons in a bit array.
  62. extern uint8_t lcd_buttons;
  63. extern uint8_t lcd_button_pressed;
  64. extern uint8_t lcd_update_enabled;
  65. extern uint32_t lcd_timeoutToStatus;
  66. extern uint32_t lcd_next_update_millis;
  67. extern uint8_t lcd_status_update_delay;
  68. extern uint8_t lcd_long_press_active;
  69. extern lcd_longpress_func_t lcd_longpress_func;
  70. extern lcd_charsetup_func_t lcd_charsetup_func;
  71. extern lcd_lcdupdate_func_t lcd_lcdupdate_func;
  72. extern uint8_t lcd_clicked(void);
  73. extern void lcd_beeper_quick_feedback(void);
  74. //Cause an LCD refresh, and give the user visual or audible feedback that something has happened
  75. extern void lcd_quick_feedback(void);
  76. extern void lcd_update(uint8_t lcdDrawUpdateOverride);
  77. extern void lcd_update_enable(uint8_t enabled);
  78. extern void lcd_buttons_update(void);
  79. /**
  80. * Implementation of the LCD display routines for a Hitachi HD44780 display. These are common LCD character displays.
  81. * When selecting the Russian language, a slightly different LCD implementation is used to handle UTF8 characters.
  82. **/
  83. ////////////////////////////////////
  84. // Setup button and encode mappings for each panel (into 'lcd_buttons' variable
  85. //
  86. // This is just to map common functions (across different panels) onto the same
  87. // macro name. The mapping is independent of whether the button is directly connected or
  88. // via a shift/i2c register.
  89. #define BLEN_B 1
  90. #define BLEN_A 0
  91. #define EN_B (1<<BLEN_B) // The two encoder pins are connected through BTN_EN1 and BTN_EN2
  92. #define EN_A (1<<BLEN_A)
  93. #define BLEN_C 2
  94. #define EN_C (1<<BLEN_C)
  95. #define LCD_CLICKED (lcd_buttons&EN_C)
  96. ////////////////////////
  97. // Setup Rotary Encoder Bit Values (for two pin encoders to indicate movement)
  98. // These values are independent of which pins are used for EN_A and EN_B indications
  99. // The rotary encoder part is also independent to the chipset used for the LCD
  100. #define encrot0 0
  101. #define encrot1 2
  102. #define encrot2 3
  103. #define encrot3 1
  104. //Custom characters defined in the first 8 characters of the LCD
  105. #define LCD_STR_BEDTEMP "\x00"
  106. #define LCD_STR_DEGREE "\x01"
  107. #define LCD_STR_THERMOMETER "\x02"
  108. #define LCD_STR_UPLEVEL "\x03"
  109. #define LCD_STR_REFRESH "\x04"
  110. #define LCD_STR_FOLDER "\x05"
  111. #define LCD_STR_FEEDRATE "\x06"
  112. #define LCD_STR_CLOCK "\x07"
  113. #define LCD_STR_ARROW_UP "\x0B"
  114. #define LCD_STR_ARROW_DOWN "\x01"
  115. #define LCD_STR_ARROW_RIGHT "\x7E" //from the default character set
  116. extern void lcd_set_custom_characters(void);
  117. extern void lcd_set_custom_characters_arrows(void);
  118. extern void lcd_set_custom_characters_progress(void);
  119. extern void lcd_set_custom_characters_nextpage(void);
  120. extern void lcd_set_custom_characters_degree(void);
  121. extern void lcd_drawedit(const char* pstr, char* value);
  122. extern void lcd_drawedit_2(const char* pstr, char* value);
  123. #endif //_LCD_H