Prusa3d Marlin fork
lcd.h
Go to the documentation of this file.
1 #ifndef _LCD_H
3 #define _LCD_H
4 
5 #include <inttypes.h>
6 #include <stdio.h>
7 #include "Timer.h"
8 
9 
10 
11 extern FILE _lcdout;
12 
13 #define lcdout (&_lcdout)
14 
15 extern void lcd_init(void);
16 
17 extern void lcd_refresh(void);
18 
19 extern void lcd_refresh_noclear(void);
20 
21 extern void lcd_clear(void);
22 
23 extern void lcd_home(void);
24 
25 /*extern void lcd_no_display(void);
26 extern void lcd_display(void);
27 extern void lcd_no_blink(void);
28 extern void lcd_blink(void);
29 extern void lcd_no_cursor(void);
30 extern void lcd_cursor(void);
31 extern void lcd_scrollDisplayLeft(void);
32 extern void lcd_scrollDisplayRight(void);
33 extern void lcd_leftToRight(void);
34 extern void lcd_rightToLeft(void);
35 extern void lcd_autoscroll(void);
36 extern void lcd_no_autoscroll(void);*/
37 
38 extern void lcd_set_cursor(uint8_t col, uint8_t row);
39 
42 void lcd_set_cursor_column(uint8_t col);
43 
44 extern void lcd_createChar_P(uint8_t, const uint8_t*);
45 
46 
47 // char c is non-standard, however it saves 1B on stack
48 extern int lcd_putc(char c);
49 extern int lcd_putc_at(uint8_t c, uint8_t r, char ch);
50 
51 extern int lcd_puts_P(const char* str);
52 extern int lcd_puts_at_P(uint8_t c, uint8_t r, const char* str);
53 extern int lcd_printf_P(const char* format, ...);
54 extern void lcd_space(uint8_t n);
55 
56 extern void lcd_printNumber(unsigned long n, uint8_t base);
57 
58 extern void lcd_print(const char*);
59 extern uint8_t lcd_print_pad(const char* s, uint8_t len);
60 
65 uint8_t lcd_print_pad_P(const char* s, uint8_t len);
66 extern void lcd_print(char, int = 0);
67 extern void lcd_print(unsigned char, int = 0);
68 extern void lcd_print(int, int = 10);
69 extern void lcd_print(unsigned int, int = 10);
70 extern void lcd_print(long, int = 10);
71 extern void lcd_print(unsigned long, int = 10);
72 
74 #define ESC_2J "\x1b[2J"
76 #define ESC_25h "\x1b[?25h"
78 #define ESC_25l "\x1b[?25l"
82 #define ESC_H(c,r) "\x1b["#r";"#c"H"
83 
84 
85 
86 #define LCD_UPDATE_INTERVAL 100
87 #define LCD_TIMEOUT_TO_STATUS 30000ul
88 #define LCD_TIMEOUT_TO_STATUS_BABYSTEP_Z 90000ul
89 
90 
91 
92 typedef void (*lcd_longpress_func_t)(void);
93 
94 typedef void (*lcd_charsetup_func_t)(void);
95 
96 typedef void (*lcd_lcdupdate_func_t)(void);
97 
98 //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)
99 extern uint8_t lcd_draw_update;
100 
101 extern int16_t lcd_encoder;
102 
103 extern uint8_t lcd_click_trigger;
104 
105 extern uint8_t lcd_update_enabled;
106 
107 extern LongTimer lcd_timeoutToStatus;
108 
109 extern uint32_t lcd_next_update_millis;
110 
111 extern lcd_longpress_func_t lcd_longpress_func;
112 extern bool lcd_longpress_trigger;
113 
114 extern lcd_lcdupdate_func_t lcd_lcdupdate_func;
115 
116 
117 
118 extern uint8_t lcd_clicked(void);
119 
120 extern void lcd_beeper_quick_feedback(void);
121 
122 //Cause an LCD refresh, and give the user visual or audible feedback that something has happened
123 extern void lcd_quick_feedback(void);
124 
127 extern void lcd_knob_update();
128 
129 extern void lcd_update(uint8_t lcdDrawUpdateOverride);
130 
131 extern void lcd_update_enable(uint8_t enabled);
132 
133 extern void lcd_buttons_update(void);
134 
143 {
144 public:
145  LcdUpdateDisabler(): m_updateEnabled(lcd_update_enabled)
146  {
147  lcd_update_enable(false);
148  }
150  {
151  lcd_update_enable(m_updateEnabled);
152  }
153 
154 private:
155  bool m_updateEnabled;
156 };
157 
159 
169 #define LCD_CLICKED (lcd_click_trigger)
170 
172 
173 //Custom characters defined in the first 8 characters of the LCD
174 #define LCD_STR_ARROW_RIGHT "\x7E" //from the default character set
175 #define LCD_STR_ARROW_LEFT "\x7F" //from the default character set
176 #define LCD_STR_BEDTEMP "\x80"
177 #define LCD_STR_DEGREE "\x81"
178 #define LCD_STR_THERMOMETER "\x82"
179 #define LCD_STR_UPLEVEL "\x83"
180 #define LCD_STR_REFRESH "\x84"
181 #define LCD_STR_FOLDER "\x85"
182 #define LCD_STR_FEEDRATE "\x86"
183 #define LCD_STR_CLOCK "\x87"
184 #define LCD_STR_ARROW_2_DOWN "\x88"
185 #define LCD_STR_CONFIRM "\x89"
186 #define LCD_STR_SOLID_BLOCK "\xFF" //from the default character set
187 
188 extern void lcd_frame_start();
189 
191 inline void lcd_consume_click()
192 {
193  lcd_click_trigger = 0;
194  lcd_longpress_trigger = 0;
195 }
196 
197 
198 #endif //_LCD_H
Helper class to temporarily disable LCD updates.
Definition: lcd.h:143
uint8_t lcd_print_pad_P(const char *s, uint8_t len)
print a string from PROGMEM with left-adjusted padding
Definition: lcd.cpp:636
uint8_t lcd_clicked(void)
Was button clicked?
Definition: lcd.cpp:739
void lcd_set_cursor_column(uint8_t col)
Change the cursor column position while preserving the current row position.
Definition: lcd.cpp:381
void lcd_consume_click()
Consume click and longpress event.
Definition: lcd.h:191
void lcd_knob_update()
Check whether knob is rotated or clicked and update relevant variables. Flags are set by lcd_buttons_...
Definition: lcd.cpp:759