Firmware SDK
twr_module_lcd.h
1 #ifndef _TWR_MODULE_LCD
2 #define _TWR_MODULE_LCD
3 
4 
5 #include <twr_font_common.h>
6 #include <twr_image.h>
7 #include <twr_led.h>
8 #include <twr_button.h>
9 #include <twr_gfx.h>
10 
14 
16 
17 typedef enum
18 {
19  TWR_MODULE_LCD_EVENT_LEFT_PRESS = 0x10 | TWR_BUTTON_EVENT_PRESS,
20  TWR_MODULE_LCD_EVENT_LEFT_RELEASE = 0x10 | TWR_BUTTON_EVENT_RELEASE,
21  TWR_MODULE_LCD_EVENT_LEFT_CLICK = 0x10 | TWR_BUTTON_EVENT_CLICK,
22  TWR_MODULE_LCD_EVENT_LEFT_HOLD = 0x10 | TWR_BUTTON_EVENT_HOLD,
23 
24  TWR_MODULE_LCD_EVENT_RIGHT_PRESS = 0x20 | TWR_BUTTON_EVENT_PRESS,
25  TWR_MODULE_LCD_EVENT_RIGHT_RELEASE = 0x20 | TWR_BUTTON_EVENT_RELEASE,
26  TWR_MODULE_LCD_EVENT_RIGHT_CLICK = 0x20 | TWR_BUTTON_EVENT_CLICK,
27  TWR_MODULE_LCD_EVENT_RIGHT_HOLD = 0x20 | TWR_BUTTON_EVENT_HOLD,
28 
29  TWR_MODULE_LCD_EVENT_BOTH_HOLD = 0x30 | TWR_BUTTON_EVENT_HOLD,
30 
32 
33 
35 
36 typedef enum
37 {
40 
43 
46 
49 
51 
53 
54 typedef enum
55 {
58 
61 
64 
66 
68 
69 typedef enum
70 {
73 
76 
78 
79 
81 
82 void twr_module_lcd_init();
83 
85 
87 
91 
92 bool twr_module_lcd_on(void);
93 
97 
98 bool twr_module_lcd_off(void);
99 
101 
102 bool twr_module_lcd_is_present(void);
103 
107 
108 bool twr_module_lcd_is_ready(void);
109 
111 
112 void twr_module_lcd_clear(void);
113 
118 
119 void twr_module_lcd_draw_pixel(int left, int top, bool color);
120 
127 
128 int twr_module_lcd_draw_char(int left, int top, uint8_t ch, bool color);
129 
136 
137 int twr_module_lcd_draw_string(int left, int top, char *str, bool color);
138 
145 
146 void twr_module_lcd_draw_line(int x0, int y0, int x1, int y1, bool color);
147 
154 
155 void twr_module_lcd_draw_rectangle(int x0, int y0, int x1, int y1, bool color);
156 
162 
163 void twr_module_lcd_draw_circle(int x0, int y0, int radius, bool color);
164 
169 
170 void twr_module_lcd_draw_image(int left, int top, const twr_image_t *img);
171 
172 //void twr_module_lcd_draw(const uint8_t *frame, uint8_t width, uint8_t height); // In pixels
173 //void twr_module_lcd_printf(uint8_t line, /*uint8_t size, font, */const uint8_t *string/*, ...*/);
174 
178 
179 bool twr_module_lcd_update(void);
180 
183 
184 void twr_module_lcd_set_font(const twr_font_t *font);
185 
188 
190 
194 
195 void twr_module_lcd_set_event_handler(void (*event_handler)(twr_module_lcd_event_t, void *), void *event_param);
196 
199 
201 
204 
206 
209 
211 
214 
216 
219 
221 
224 
226 
229 
231 
233 
234 #endif // _TWR_MODULE_LCD
@ TWR_BUTTON_EVENT_HOLD
Event button hold (pressed for longer time)
Definition: twr_button.h:26
@ TWR_BUTTON_EVENT_PRESS
Event button pressed.
Definition: twr_button.h:17
@ TWR_BUTTON_EVENT_RELEASE
Event button released.
Definition: twr_button.h:20
@ TWR_BUTTON_EVENT_CLICK
Event button clicked (pressed and released within certain time)
Definition: twr_button.h:23
@ TWR_GFX_ROTATION_270
Rotation 270 degrees.
Definition: twr_gfx.h:58
@ TWR_GFX_ROTATION_180
Rotation 180 degrees.
Definition: twr_gfx.h:55
@ TWR_GFX_ROTATION_90
Rotation 90 degrees.
Definition: twr_gfx.h:52
@ TWR_GFX_ROTATION_0
Rotation 0 degrees.
Definition: twr_gfx.h:49
void twr_module_lcd_clear(void)
Lcd clear.
bool twr_module_lcd_update(void)
Lcd update, send data.
bool twr_module_lcd_on(void)
Lcd on.
void twr_module_lcd_draw_rectangle(int x0, int y0, int x1, int y1, bool color)
Lcd draw rectangle.
void twr_module_lcd_draw_line(int x0, int y0, int x1, int y1, bool color)
Lcd draw line.
int twr_module_lcd_draw_char(int left, int top, uint8_t ch, bool color)
Lcd draw char.
void twr_module_lcd_draw_image(int left, int top, const twr_image_t *img)
Lcd draw image.
void twr_module_lcd_draw_circle(int x0, int y0, int radius, bool color)
Lcd draw circle.
void twr_module_lcd_set_button_click_timeout(twr_tick_t click_timeout)
Set click timeout (maximum interval within which button has to be released to recognize click event)
twr_module_lcd_event_t
Callback events.
void twr_module_lcd_set_button_debounce_time(twr_tick_t debounce_time)
Set debounce time (minimum sampling interval during which input cannot change to toggle its state)
twr_module_lcd_rotation_t
Rotation.
const twr_led_driver_t * twr_module_lcd_get_led_driver(void)
Lcd get led driver.
twr_module_lcd_led_t
Virtual LED channels.
int twr_module_lcd_draw_string(int left, int top, char *str, bool color)
Lcd draw string.
twr_gfx_t * twr_module_lcd_get_gfx()
Get gfx instance.
void twr_module_lcd_set_event_handler(void(*event_handler)(twr_module_lcd_event_t, void *), void *event_param)
Lcd set event handler for buttons.
twr_module_lcd_rotation_t twr_module_lcd_get_rotation(void)
Lcd get rotation.
bool twr_module_lcd_is_ready(void)
Check if lcd is ready for commands.
bool twr_module_lcd_is_present(void)
Get LCD Module is pressent, can use without twr_module_lcd_init.
void twr_module_lcd_set_button_hold_time(twr_tick_t hold_time)
Set hold time (interval after which hold event is recognized when button is steadily pressed)
void twr_module_lcd_set_font(const twr_font_t *font)
Lcd set font.
void twr_module_lcd_set_rotation(twr_module_lcd_rotation_t rotation)
Lcd set rotation.
bool twr_module_lcd_off(void)
Lcd off.
void twr_module_lcd_set_button_scan_interval(twr_tick_t scan_interval)
Set scan interval (period of button input sampling)
twr_module_lcd_button_t
Virtual button channels.
const twr_button_driver_t * twr_module_lcd_get_button_driver(void)
Lcd get button driver.
void twr_module_lcd_draw_pixel(int left, int top, bool color)
Lcd draw pixel.
void twr_module_lcd_init()
Initialize lcd.
@ TWR_MODULE_LCD_ROTATION_0
LCD rotation 0 degrees.
@ TWR_MODULE_LCD_ROTATION_180
LCD rotation 180 degrees.
@ TWR_MODULE_LCD_ROTATION_270
LCD rotation 270 degrees.
@ TWR_MODULE_LCD_ROTATION_90
LCD rotation 90 degrees.
@ TWR_MODULE_LCD_LED_RED
LCD red LED channel.
@ TWR_MODULE_LCD_LED_BLUE
LCD blue LED channel.
@ TWR_MODULE_LCD_LED_GREEN
LCD green LED channel.
@ TWR_MODULE_LCD_BUTTON_RIGHT
LCD right button channel.
@ TWR_MODULE_LCD_BUTTON_LEFT
LCD left button channel.
uint64_t twr_tick_t
Timestamp data type.
Definition: twr_tick.h:16
Button driver interface.
Definition: twr_button.h:37
Instance.
Definition: twr_gfx.h:81
LED driver interface.
Definition: twr_led.h:57