LibDriver SSD1306
Loading...
Searching...
No Matches
driver_ssd1306.h
Go to the documentation of this file.
1
37
38#ifndef DRIVER_SSD1306_H
39#define DRIVER_SSD1306_H
40
41#include <stdint.h>
42#include <stdio.h>
43#include <string.h>
44
45#ifdef __cplusplus
46extern "C"{
47#endif
48
54
59
68
77
87
97
112
121
130
139
148
157
166
175
184
193
203
207typedef enum
208{
213
217typedef struct ssd1306_handle_s
218{
219 uint8_t (*iic_init)(void);
220 uint8_t (*iic_deinit)(void);
221 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
222 uint8_t (*spi_init)(void);
223 uint8_t (*spi_deinit)(void);
224 uint8_t (*spi_write_cmd)(uint8_t *buf, uint16_t len);
225 uint8_t (*spi_cmd_data_gpio_init)(void);
226 uint8_t (*spi_cmd_data_gpio_deinit)(void);
227 uint8_t (*spi_cmd_data_gpio_write)(uint8_t value);
228 uint8_t (*reset_gpio_init)(void);
229 uint8_t (*reset_gpio_deinit)(void);
230 uint8_t (*reset_gpio_write)(uint8_t value);
231 void (*debug_print)(const char *const fmt, ...);
232 void (*delay_ms)(uint32_t ms);
233 uint8_t inited;
234 uint8_t iic_addr;
235 uint8_t iic_spi;
236 uint8_t gram[128][8];
238
254
258
265
272#define DRIVER_SSD1306_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
273
280#define DRIVER_SSD1306_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
281
288#define DRIVER_SSD1306_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
289
296#define DRIVER_SSD1306_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
297
304#define DRIVER_SSD1306_LINK_SPI_INIT(HANDLE, FUC) (HANDLE)->spi_init = FUC
305
312#define DRIVER_SSD1306_LINK_SPI_DEINIT(HANDLE, FUC) (HANDLE)->spi_deinit = FUC
313
320#define DRIVER_SSD1306_LINK_SPI_WRITE_COMMAND(HANDLE, FUC) (HANDLE)->spi_write_cmd = FUC
321
328#define DRIVER_SSD1306_LINK_SPI_COMMAND_DATA_GPIO_INIT(HANDLE, FUC) (HANDLE)->spi_cmd_data_gpio_init = FUC
329
336#define DRIVER_SSD1306_LINK_SPI_COMMAND_DATA_GPIO_DEINIT(HANDLE, FUC) (HANDLE)->spi_cmd_data_gpio_deinit = FUC
337
344#define DRIVER_SSD1306_LINK_SPI_COMMAND_DATA_GPIO_WRITE(HANDLE, FUC) (HANDLE)->spi_cmd_data_gpio_write = FUC
345
352#define DRIVER_SSD1306_LINK_RESET_GPIO_INIT(HANDLE, FUC) (HANDLE)->reset_gpio_init = FUC
353
360#define DRIVER_SSD1306_LINK_RESET_GPIO_DEINIT(HANDLE, FUC) (HANDLE)->reset_gpio_deinit = FUC
361
368#define DRIVER_SSD1306_LINK_RESET_GPIO_WRITE(HANDLE, FUC) (HANDLE)->reset_gpio_write = FUC
369
376#define DRIVER_SSD1306_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
377
384#define DRIVER_SSD1306_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
385
389
396
405uint8_t ssd1306_info(ssd1306_info_t *info);
406
417
428
439
450
464uint8_t ssd1306_init(ssd1306_handle_t *handle);
465
480uint8_t ssd1306_deinit(ssd1306_handle_t *handle);
481
492uint8_t ssd1306_clear(ssd1306_handle_t *handle);
493
505
520uint8_t ssd1306_write_point(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t data);
521
536uint8_t ssd1306_read_point(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t *data);
537
552uint8_t ssd1306_gram_write_point(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t data);
553
568uint8_t ssd1306_gram_read_point(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t *data);
569
587uint8_t ssd1306_gram_write_string(ssd1306_handle_t *handle, uint8_t x, uint8_t y, char *str, uint16_t len, uint8_t color, ssd1306_font_t font);
588
607uint8_t ssd1306_gram_fill_rect(ssd1306_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t color);
608
627uint8_t ssd1306_gram_draw_picture(ssd1306_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img);
628
641uint8_t ssd1306_set_low_column_start_address(ssd1306_handle_t *handle, uint8_t addr);
642
655uint8_t ssd1306_set_high_column_start_address(ssd1306_handle_t *handle, uint8_t addr);
656
669
684uint8_t ssd1306_set_column_address_range(ssd1306_handle_t *handle, uint8_t start_addr, uint8_t end_addr);
685
700uint8_t ssd1306_set_page_address_range(ssd1306_handle_t *handle, uint8_t start_addr, uint8_t end_addr);
701
716
732uint8_t ssd1306_set_right_horizontal_scroll(ssd1306_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr,
734
750uint8_t ssd1306_set_left_horizontal_scroll(ssd1306_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr,
752
770uint8_t ssd1306_set_vertical_right_horizontal_scroll(ssd1306_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr,
771 uint8_t rows, ssd1306_scroll_frame_t frames);
772
790uint8_t ssd1306_set_vertical_left_horizontal_scroll(ssd1306_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr,
791 uint8_t rows, ssd1306_scroll_frame_t frames);
792
804
816
829uint8_t ssd1306_set_display_start_line(ssd1306_handle_t *handle, uint8_t l);
830
842uint8_t ssd1306_set_contrast(ssd1306_handle_t *handle, uint8_t contrast);
843
856
869
885uint8_t ssd1306_set_vertical_scroll_area(ssd1306_handle_t *handle, uint8_t start_row, uint8_t end_row);
886
899
912
926uint8_t ssd1306_set_multiplex_ratio(ssd1306_handle_t *handle, uint8_t multiplex);
927
940
953uint8_t ssd1306_set_page_address(ssd1306_handle_t *handle, uint8_t addr);
954
967
980uint8_t ssd1306_set_display_offset(ssd1306_handle_t *handle, uint8_t offset);
981
996uint8_t ssd1306_set_display_clock(ssd1306_handle_t *handle, uint8_t oscillator_frequency, uint8_t clock_divide);
997
1010
1025uint8_t ssd1306_set_precharge_period(ssd1306_handle_t *handle, uint8_t phase1_period, uint8_t phase2_period);
1026
1040
1053
1057
1064
1077uint8_t ssd1306_write_cmd(ssd1306_handle_t *handle, uint8_t *buf, uint8_t len);
1078
1091uint8_t ssd1306_write_data(ssd1306_handle_t *handle, uint8_t *buf, uint8_t len);
1092
1096
1100
1101#ifdef __cplusplus
1102}
1103#endif
1104
1105#endif
uint8_t ssd1306_write_point(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t data)
write a point
struct ssd1306_info_s ssd1306_info_t
ssd1306 information structure definition
ssd1306_left_right_remap_t
ssd1306 left right remap enumeration definition
uint8_t ssd1306_set_contrast(ssd1306_handle_t *handle, uint8_t contrast)
set the display contrast
uint8_t ssd1306_set_page_address_range(ssd1306_handle_t *handle, uint8_t start_addr, uint8_t end_addr)
set the page address range
uint8_t ssd1306_gram_read_point(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t *data)
read a point from the gram
uint8_t ssd1306_set_zoom_in(ssd1306_handle_t *handle, ssd1306_zoom_in_t zoom)
set the display zoom in
uint8_t ssd1306_set_scan_direction(ssd1306_handle_t *handle, ssd1306_scan_direction_t dir)
set the scan direction
ssd1306_scan_direction_t
ssd1306 scan direction enumeration definition
uint8_t ssd1306_set_precharge_period(ssd1306_handle_t *handle, uint8_t phase1_period, uint8_t phase2_period)
set the pre charge period
uint8_t ssd1306_gram_write_point(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t data)
write a point in the gram
uint8_t ssd1306_set_memory_addressing_mode(ssd1306_handle_t *handle, ssd1306_memory_addressing_mode_t mode)
set the memory addressing mode
ssd1306_interface_t
ssd1306 interface enumeration definition
struct ssd1306_handle_s ssd1306_handle_t
ssd1306 handle structure definition
ssd1306_display_t
ssd1306 display enumeration definition
uint8_t ssd1306_set_addr_pin(ssd1306_handle_t *handle, ssd1306_address_t addr_pin)
set the chip iic address
ssd1306_charge_pump_t
ssd1306 charge pump enumeration definition
ssd1306_memory_addressing_mode_t
ssd1306 memory addressing mode enumeration definition
uint8_t ssd1306_gram_draw_picture(ssd1306_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img)
draw a picture in the gram
ssd1306_entire_display_t
ssd1306 entire display enumeration definition
ssd1306_pin_conf_t
ssd1306 pin conf enumeration definition
uint8_t ssd1306_info(ssd1306_info_t *info)
get chip's information
ssd1306_font_t
ssd1306 font enumeration definition
ssd1306_segment_column_remap_t
ssd1306 segment column remap enumeration definition
uint8_t ssd1306_set_vertical_scroll_area(ssd1306_handle_t *handle, uint8_t start_row, uint8_t end_row)
set the vertical scroll area
uint8_t ssd1306_gram_fill_rect(ssd1306_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t color)
fill a rectangle in the gram
uint8_t ssd1306_set_charge_pump(ssd1306_handle_t *handle, ssd1306_charge_pump_t enable)
enable or disable the charge pump
uint8_t ssd1306_set_page_address(ssd1306_handle_t *handle, uint8_t addr)
set the page address
uint8_t ssd1306_get_interface(ssd1306_handle_t *handle, ssd1306_interface_t *interface)
get the chip interface
ssd1306_zoom_in_t
ssd1306 zoom in enumeration definition
uint8_t ssd1306_read_point(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t *data)
read a point
uint8_t ssd1306_set_display_mode(ssd1306_handle_t *handle, ssd1306_display_mode_t mode)
set the display mode
uint8_t ssd1306_set_display_offset(ssd1306_handle_t *handle, uint8_t offset)
set the display offset
uint8_t ssd1306_set_display(ssd1306_handle_t *handle, ssd1306_display_t on_off)
enable or disable the display
uint8_t ssd1306_activate_scroll(ssd1306_handle_t *handle)
activate the scroll
uint8_t ssd1306_set_multiplex_ratio(ssd1306_handle_t *handle, uint8_t multiplex)
set the multiplex ratio
uint8_t ssd1306_set_display_start_line(ssd1306_handle_t *handle, uint8_t l)
set the display start line
uint8_t ssd1306_deactivate_scroll(ssd1306_handle_t *handle)
deactivate the scroll
ssd1306_address_t
ssd1306 address pin enumeration definition
uint8_t ssd1306_get_addr_pin(ssd1306_handle_t *handle, ssd1306_address_t *addr_pin)
get the chip iic address
uint8_t ssd1306_set_high_column_start_address(ssd1306_handle_t *handle, uint8_t addr)
set the high column start address
uint8_t ssd1306_set_display_clock(ssd1306_handle_t *handle, uint8_t oscillator_frequency, uint8_t clock_divide)
set the display clock
uint8_t ssd1306_deinit(ssd1306_handle_t *handle)
close the chip
ssd1306_display_mode_t
ssd1306 display mode enumeration definition
uint8_t ssd1306_set_segment_remap(ssd1306_handle_t *handle, ssd1306_segment_column_remap_t remap)
set the segment remap
ssd1306_scroll_frame_t
ssd1306 scroll frame enumeration definition
uint8_t ssd1306_set_right_horizontal_scroll(ssd1306_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, ssd1306_scroll_frame_t frames)
set the right horizontal scroll
uint8_t ssd1306_set_com_pins_hardware_conf(ssd1306_handle_t *handle, ssd1306_pin_conf_t conf, ssd1306_left_right_remap_t remap)
set the hardware com pins
uint8_t ssd1306_gram_write_string(ssd1306_handle_t *handle, uint8_t x, uint8_t y, char *str, uint16_t len, uint8_t color, ssd1306_font_t font)
draw a string in the gram
uint8_t ssd1306_set_left_horizontal_scroll(ssd1306_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, ssd1306_scroll_frame_t frames)
set the left horizontal scroll
uint8_t ssd1306_set_fade_blinking_mode(ssd1306_handle_t *handle, ssd1306_fade_blinking_mode_t mode, uint8_t frames)
set the fade blinking mode
uint8_t ssd1306_clear(ssd1306_handle_t *handle)
clear the screen
uint8_t ssd1306_set_deselect_level(ssd1306_handle_t *handle, ssd1306_deselect_level_t level)
set the deselect level
uint8_t ssd1306_set_column_address_range(ssd1306_handle_t *handle, uint8_t start_addr, uint8_t end_addr)
set the column address range
uint8_t ssd1306_set_vertical_left_horizontal_scroll(ssd1306_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, uint8_t rows, ssd1306_scroll_frame_t frames)
set the vertical left horizontal scroll
uint8_t ssd1306_gram_update(ssd1306_handle_t *handle)
update the gram data
uint8_t ssd1306_set_low_column_start_address(ssd1306_handle_t *handle, uint8_t addr)
set the low column start address
ssd1306_fade_blinking_mode_t
ssd1306 fade blinking mode enumeration definition
uint8_t ssd1306_set_entire_display(ssd1306_handle_t *handle, ssd1306_entire_display_t enable)
enable or disable the entire display
ssd1306_deselect_level_t
ssd1306 deselect level enumeration definition
uint8_t ssd1306_set_vertical_right_horizontal_scroll(ssd1306_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, uint8_t rows, ssd1306_scroll_frame_t frames)
set the vertical right horizontal scroll
uint8_t ssd1306_set_interface(ssd1306_handle_t *handle, ssd1306_interface_t interface)
set the chip interface
uint8_t ssd1306_init(ssd1306_handle_t *handle)
initialize the chip
@ SSD1306_LEFT_RIGHT_REMAP_DISABLE
@ SSD1306_LEFT_RIGHT_REMAP_ENABLE
@ SSD1306_SCAN_DIRECTION_COMN_1_START
@ SSD1306_SCAN_DIRECTION_COM0_START
@ SSD1306_INTERFACE_IIC
@ SSD1306_INTERFACE_SPI
@ SSD1306_DISPLAY_ON
@ SSD1306_DISPLAY_OFF
@ SSD1306_CHARGE_PUMP_DISABLE
@ SSD1306_CHARGE_PUMP_ENABLE
@ SSD1306_MEMORY_ADDRESSING_MODE_PAGE
@ SSD1306_MEMORY_ADDRESSING_MODE_VERTICAL
@ SSD1306_MEMORY_ADDRESSING_MODE_HORIZONTAL
@ SSD1306_ENTIRE_DISPLAY_OFF
@ SSD1306_ENTIRE_DISPLAY_ON
@ SSD1306_PIN_CONF_SEQUENTIAL
@ SSD1306_PIN_CONF_ALTERNATIVE
@ SSD1306_FONT_16
@ SSD1306_FONT_24
@ SSD1306_FONT_12
@ SSD1306_SEGMENT_COLUMN_ADDRESS_0
@ SSD1306_SEGMENT_COLUMN_ADDRESS_127
@ SSD1306_ZOOM_IN_DISABLE
@ SSD1306_ZOOM_IN_ENABLE
@ SSD1306_ADDR_SA0_0
@ SSD1306_ADDR_SA0_1
@ SSD1306_DISPLAY_MODE_NORMAL
@ SSD1306_DISPLAY_MODE_INVERSE
@ SSD1306_SCROLL_FRAME_128
@ SSD1306_SCROLL_FRAME_25
@ SSD1306_SCROLL_FRAME_256
@ SSD1306_SCROLL_FRAME_2
@ SSD1306_SCROLL_FRAME_3
@ SSD1306_SCROLL_FRAME_64
@ SSD1306_SCROLL_FRAME_4
@ SSD1306_SCROLL_FRAME_5
@ SSD1306_FADE_BLINKING_MODE_BLINKING
@ SSD1306_FADE_BLINKING_MODE_DISABLE
@ SSD1306_FADE_BLINKING_MODE_FADE_OUT
@ SSD1306_DESELECT_LEVEL_0P83
@ SSD1306_DESELECT_LEVEL_0P65
@ SSD1306_DESELECT_LEVEL_0P77
uint8_t ssd1306_write_data(ssd1306_handle_t *handle, uint8_t *buf, uint8_t len)
write the register data
uint8_t ssd1306_write_cmd(ssd1306_handle_t *handle, uint8_t *buf, uint8_t len)
write the register command
ssd1306 handle structure definition
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* spi_cmd_data_gpio_deinit)(void)
uint8_t(* reset_gpio_deinit)(void)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* spi_deinit)(void)
uint8_t(* reset_gpio_init)(void)
uint8_t(* spi_cmd_data_gpio_init)(void)
uint8_t gram[128][8]
uint8_t(* spi_write_cmd)(uint8_t *buf, uint16_t len)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* spi_cmd_data_gpio_write)(uint8_t value)
uint8_t(* reset_gpio_write)(uint8_t value)
uint8_t(* iic_deinit)(void)
ssd1306 information structure definition
uint32_t driver_version
char manufacturer_name[32]