Firmware SDK
twr_ssd1306.h
1 #ifndef _TWR_SSD1306_H
2 #define _TWR_SSD1306_H
3 
4 #include <twr_gfx.h>
5 #include <twr_scheduler.h>
6 #include <twr_i2c.h>
7 
11 
12 #define TWR_SSD1306_ADDRESS_I2C_ADDRESS_DEFAULT 0x3C
13 #define TWR_SSD1306_ADDRESS_I2C_ADDRESS_ALTERNATE 0x3D
14 
15 #define TWR_SSD1306_FRAMEBUFFER(NAME, WIDTH, HEIGHT) \
16  uint8_t NAME##_buffer[WIDTH * HEIGHT / 8]; \
17  twr_ssd1306_framebuffer_t NAME = { \
18  .buffer = NAME##_buffer, \
19  .width = WIDTH, \
20  .height = HEIGHT, \
21  .length = sizeof(NAME##_buffer), \
22  .pages = HEIGHT / 8 \
23  };
24 
25 typedef struct
26 {
27  int width;
28  int height;
29  uint8_t *buffer;
30  size_t length;
31  int pages;
32 
34 
36 
37 typedef struct
38 {
39  twr_i2c_channel_t _i2c_channel;
40  uint8_t _i2c_address;
41  const twr_ssd1306_framebuffer_t *_framebuffer;
42  bool _initialized;
43 
45 
51 
52 bool twr_ssd1306_init(twr_ssd1306_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address, const twr_ssd1306_framebuffer_t *framebuffer);
53 
56 
58 
63 
65 
68 
70 
76 
77 void twr_ssd1306_draw_pixel(twr_ssd1306_t *self, int x, int y, uint32_t color);
78 
84 
85 uint32_t twr_ssd1306_get_pixel(twr_ssd1306_t *self, int x, int y);
86 
91 
93 
95 
97 
99 
100 #endif //_TWR_SSD1306_H
twr_i2c_channel_t
I2C channels.
Definition: twr_i2c.h:16
bool twr_ssd1306_init(twr_ssd1306_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address, const twr_ssd1306_framebuffer_t *framebuffer)
Initialize lcd driver.
Definition: twr_ssd1306.c:34
void twr_ssd1306_clear(twr_ssd1306_t *self)
Clear.
Definition: twr_ssd1306.c:68
bool twr_ssd1306_update(twr_ssd1306_t *self)
Lcd update, send data.
Definition: twr_ssd1306.c:103
const twr_gfx_driver_t * twr_ssd1306_get_driver(void)
Get Lcd driver.
Definition: twr_ssd1306.c:136
bool twr_ssd1306_is_ready(twr_ssd1306_t *self)
Check if lcd is ready for commands.
Definition: twr_ssd1306.c:58
uint32_t twr_ssd1306_get_pixel(twr_ssd1306_t *self, int x, int y)
Lcd get pixel.
Definition: twr_ssd1306.c:94
twr_gfx_caps_t twr_ssd1306_get_caps(twr_ssd1306_t *self)
Get capabilities.
Definition: twr_ssd1306.c:51
void twr_ssd1306_draw_pixel(twr_ssd1306_t *self, int x, int y, uint32_t color)
Lcd draw pixel.
Definition: twr_ssd1306.c:73
Display size.
Definition: twr_gfx.h:14
Display driver interface.
Definition: twr_gfx.h:23
Instance.
Definition: twr_ssd1306.h:38