Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_ssd1306.h
1 #ifndef _BC_SSD1306_H
2 #define _BC_SSD1306_H
3 
4 #include <bc_gfx.h>
5 #include <bc_scheduler.h>
6 #include <bc_i2c.h>
7 
11 
12 #define BC_SSD1306_ADDRESS_I2C_ADDRESS_DEFAULT 0x3C
13 #define BC_SSD1306_ADDRESS_I2C_ADDRESS_ALTERNATE 0x3D
14 
15 #define BC_SSD1306_FRAMEBUFFER(NAME, WIDTH, HEIGHT) \
16  uint8_t NAME##_buffer[WIDTH * HEIGHT / 8]; \
17  bc_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  bc_i2c_channel_t _i2c_channel;
40  uint8_t _i2c_address;
41  const bc_ssd1306_framebuffer_t *_framebuffer;
42  bool _initialized;
43 
44 } bc_ssd1306_t;
45 
51 
52 bool bc_ssd1306_init(bc_ssd1306_t *self, bc_i2c_channel_t i2c_channel, uint8_t i2c_address, const bc_ssd1306_framebuffer_t *framebuffer);
53 
56 
58 
63 
65 
68 
69 void bc_ssd1306_clear(bc_ssd1306_t *self);
70 
76 
77 void bc_ssd1306_draw_pixel(bc_ssd1306_t *self, int x, int y, uint32_t color);
78 
84 
85 uint32_t bc_ssd1306_get_pixel(bc_ssd1306_t *self, int x, int y);
86 
91 
93 
95 
97 
99 
100 #endif //_BC_SSD1306_H
bool bc_ssd1306_update(bc_ssd1306_t *self)
Lcd update, send data.
Definition: bc_ssd1306.c:103
uint32_t bc_ssd1306_get_pixel(bc_ssd1306_t *self, int x, int y)
Lcd get pixel.
Definition: bc_ssd1306.c:94
void bc_ssd1306_clear(bc_ssd1306_t *self)
Clear.
Definition: bc_ssd1306.c:68
Display size.
Definition: bc_gfx.h:13
Instance.
Definition: bc_ssd1306.h:37
Display driver interface.
Definition: bc_gfx.h:22
const bc_gfx_driver_t * bc_ssd1306_get_driver(void)
Get Lcd driver.
Definition: bc_ssd1306.c:136
bool bc_ssd1306_init(bc_ssd1306_t *self, bc_i2c_channel_t i2c_channel, uint8_t i2c_address, const bc_ssd1306_framebuffer_t *framebuffer)
Initialize lcd driver.
Definition: bc_ssd1306.c:34
bc_i2c_channel_t
I2C channels.
Definition: bc_i2c.h:15
bc_gfx_caps_t bc_ssd1306_get_caps(bc_ssd1306_t *self)
Get capabilities.
Definition: bc_ssd1306.c:51
void bc_ssd1306_draw_pixel(bc_ssd1306_t *self, int x, int y, uint32_t color)
Lcd draw pixel.
Definition: bc_ssd1306.c:73
bool bc_ssd1306_is_ready(bc_ssd1306_t *self)
Check if lcd is ready for commands.
Definition: bc_ssd1306.c:58