LibDriver SSD1309
Loading...
Searching...
No Matches
driver_ssd1309.c File Reference

driver ssd1309 source file More...

Include dependency graph for driver_ssd1309.c:

Go to the source code of this file.

Macros

#define CHIP_NAME   "Solomon Systech SSD1309"
 chip information definition
#define MANUFACTURER_NAME   "Solomon Systech"
#define SUPPLY_VOLTAGE_MIN   1.65f
#define SUPPLY_VOLTAGE_MAX   3.3f
#define MAX_CURRENT   0.58f
#define TEMPERATURE_MIN   -40.0f
#define TEMPERATURE_MAX   85.0f
#define DRIVER_VERSION   1000
#define SSD1309_CMD   0
 chip command data definition
#define SSD1309_DATA   1
#define SSD1309_CMD_LOWER_COLUMN_START_ADDRESS   0x00
 chip command definition
#define SSD1309_CMD_HIGHER_COLUMN_START_ADDRESS   0x10
#define SSD1309_CMD_MEMORY_ADDRESSING_MODE   0x20
#define SSD1309_CMD_SET_COLUMN_ADDRESS   0x21
#define SSD1309_CMD_SET_PAGE_ADDRESS   0x22
#define SSD1309_CMD_RIGHT_HORIZONTAL_SCROLL   0x26
#define SSD1309_CMD_LEFT_HORIZONTAL_SCROLL   0x27
#define SSD1309_CMD_VERTICAL_RIGHT_HORIZONTAL_SCROLL   0x29
#define SSD1309_CMD_VERTICAL_LEFT_HORIZONTAL_SCROLL   0x2A
#define SSD1309_CMD_RIGHT_HORIZONTAL_SCROLL_ONE_COL   0x2C
#define SSD1309_CMD_LEFT_HORIZONTAL_SCROLL_ONE_COL   0x2D
#define SSD1309_CMD_DEACTIVATE_SCROLL   0x2E
#define SSD1309_CMD_ACTIVATE_SCROLL   0x2F
#define SSD1309_CMD_DISPLAY_START_LINE   0x40
#define SSD1309_CMD_CONTRAST_CONTROL   0x81
#define SSD1309_CMD_COLUMN_0_MAPPED_TO_SEG0   0xA0
#define SSD1309_CMD_COLUMN_127_MAPPED_TO_SEG0   0xA1
#define SSD1309_CMD_VERTICAL_SCROLL_AREA   0xA3
#define SSD1309_CMD_ENTIRE_DISPLAY_OFF   0xA4
#define SSD1309_CMD_ENTIRE_DISPLAY_ON   0xA5
#define SSD1309_CMD_NORMAL_DISPLAY   0xA6
#define SSD1309_CMD_INVERSE_DISPLAY   0xA7
#define SSD1309_CMD_MULTIPLEX_RATIO   0xA8
#define SSD1309_CMD_DISPLAY_OFF   0xAE
#define SSD1309_CMD_DISPLAY_ON   0xAF
#define SSD1309_CMD_PAGE_ADDR   0xB0
#define SSD1309_CMD_SCAN_DIRECTION_COM0_START   0xC0
#define SSD1309_CMD_SCAN_DIRECTION_COMN_1_START   0xC8
#define SSD1309_CMD_DISPLAY_OFFSET   0xD3
#define SSD1309_CMD_DISPLAY_CLOCK_DIVIDE   0xD5
#define SSD1309_CMD_PRE_CHARGE_PERIOD   0xD9
#define SSD1309_CMD_COM_PINS_CONF   0xDA
#define SSD1309_CMD_COMH_DESLECT_LEVEL   0xDB
#define SSD1309_CMD_GPIO   0xDC
#define SSD1309_CMD_LOCK   0xFD

Functions

uint8_t ssd1309_clear (ssd1309_handle_t *handle)
 clear the screen
uint8_t ssd1309_gram_update (ssd1309_handle_t *handle)
 update the gram data
uint8_t ssd1309_write_point (ssd1309_handle_t *handle, uint8_t x, uint8_t y, uint8_t data)
 write a point
uint8_t ssd1309_read_point (ssd1309_handle_t *handle, uint8_t x, uint8_t y, uint8_t *data)
 read a point
uint8_t ssd1309_gram_write_point (ssd1309_handle_t *handle, uint8_t x, uint8_t y, uint8_t data)
 write a point in the gram
uint8_t ssd1309_gram_read_point (ssd1309_handle_t *handle, uint8_t x, uint8_t y, uint8_t *data)
 read a point from the gram
uint8_t ssd1309_gram_write_string (ssd1309_handle_t *handle, uint8_t x, uint8_t y, char *str, uint16_t len, uint8_t color, ssd1309_font_t font)
 draw a string in the gram
uint8_t ssd1309_gram_fill_rect (ssd1309_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 ssd1309_gram_draw_picture (ssd1309_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img)
 draw a picture in the gram
uint8_t ssd1309_init (ssd1309_handle_t *handle)
 initialize the chip
uint8_t ssd1309_deinit (ssd1309_handle_t *handle)
 close the chip
uint8_t ssd1309_set_interface (ssd1309_handle_t *handle, ssd1309_interface_t interface)
 set the chip interface
uint8_t ssd1309_get_interface (ssd1309_handle_t *handle, ssd1309_interface_t *interface)
 get the chip interface
uint8_t ssd1309_set_addr_pin (ssd1309_handle_t *handle, ssd1309_address_t addr_pin)
 set the chip iic address
uint8_t ssd1309_get_addr_pin (ssd1309_handle_t *handle, ssd1309_address_t *addr_pin)
 get the chip iic address
uint8_t ssd1309_set_low_column_start_address (ssd1309_handle_t *handle, uint8_t addr)
 set the low column start address
uint8_t ssd1309_set_high_column_start_address (ssd1309_handle_t *handle, uint8_t addr)
 set the high column start address
uint8_t ssd1309_set_memory_addressing_mode (ssd1309_handle_t *handle, ssd1309_memory_addressing_mode_t mode)
 set the memory addressing mode
uint8_t ssd1309_set_column_address_range (ssd1309_handle_t *handle, uint8_t start_addr, uint8_t end_addr)
 set the column address range
uint8_t ssd1309_set_page_address_range (ssd1309_handle_t *handle, uint8_t start_addr, uint8_t end_addr)
 set the page address range
uint8_t ssd1309_set_right_horizontal_scroll (ssd1309_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, ssd1309_scroll_frame_t frames, uint8_t start_column_addr, uint8_t end_column_addr)
 set the right horizontal scroll
uint8_t ssd1309_set_left_horizontal_scroll (ssd1309_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, ssd1309_scroll_frame_t frames, uint8_t start_column_addr, uint8_t end_column_addr)
 set the left horizontal scroll
uint8_t ssd1309_set_vertical_right_horizontal_scroll (ssd1309_handle_t *handle, ssd1309_bool_t horizontal_scroll, uint8_t start_page_addr, uint8_t end_page_addr, uint8_t rows, ssd1309_scroll_frame_t frames, uint8_t start_column_addr, uint8_t end_column_addr)
 set the vertical right horizontal scroll
uint8_t ssd1309_set_vertical_left_horizontal_scroll (ssd1309_handle_t *handle, ssd1309_bool_t horizontal_scroll, uint8_t start_page_addr, uint8_t end_page_addr, uint8_t rows, ssd1309_scroll_frame_t frames, uint8_t start_column_addr, uint8_t end_column_addr)
 set the vertical left horizontal scroll
uint8_t ssd1309_deactivate_scroll (ssd1309_handle_t *handle)
 deactivate the scroll
uint8_t ssd1309_activate_scroll (ssd1309_handle_t *handle)
 activate the scroll
uint8_t ssd1309_set_display_start_line (ssd1309_handle_t *handle, uint8_t l)
 set the display start line
uint8_t ssd1309_set_contrast (ssd1309_handle_t *handle, uint8_t contrast)
 set the display contrast
uint8_t ssd1309_set_segment_remap (ssd1309_handle_t *handle, ssd1309_segment_column_remap_t remap)
 set the segment remap
uint8_t ssd1309_set_vertical_scroll_area (ssd1309_handle_t *handle, uint8_t start_row, uint8_t end_row)
 set the vertical scroll area
uint8_t ssd1309_set_entire_display (ssd1309_handle_t *handle, ssd1309_entire_display_t enable)
 enable or disable the entire display
uint8_t ssd1309_set_display_mode (ssd1309_handle_t *handle, ssd1309_display_mode_t mode)
 set the display mode
uint8_t ssd1309_set_multiplex_ratio (ssd1309_handle_t *handle, uint8_t multiplex)
 set the multiplex ratio
uint8_t ssd1309_set_display (ssd1309_handle_t *handle, ssd1309_display_t on_off)
 enable or disable the display
uint8_t ssd1309_set_page_address (ssd1309_handle_t *handle, uint8_t addr)
 set the page address
uint8_t ssd1309_set_scan_direction (ssd1309_handle_t *handle, ssd1309_scan_direction_t dir)
 set the scan direction
uint8_t ssd1309_set_display_offset (ssd1309_handle_t *handle, uint8_t offset)
 set the display offset
uint8_t ssd1309_set_display_clock (ssd1309_handle_t *handle, uint8_t oscillator_frequency, uint8_t clock_divide)
 set the display clock
uint8_t ssd1309_set_precharge_period (ssd1309_handle_t *handle, uint8_t phase1_period, uint8_t phase2_period)
 set the pre charge period
uint8_t ssd1309_set_com_pins_hardware_conf (ssd1309_handle_t *handle, ssd1309_pin_conf_t conf, ssd1309_left_right_remap_t remap)
 set the hardware com pins
uint8_t ssd1309_set_deselect_level (ssd1309_handle_t *handle, ssd1309_deselect_level_t level)
 set the deselect level
uint8_t ssd1309_set_right_horizontal_scroll_one_column (ssd1309_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, uint8_t start_column_addr, uint8_t end_column_addr)
 set right horizontal scroll one column
uint8_t ssd1309_set_left_horizontal_scroll_one_column (ssd1309_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, uint8_t start_column_addr, uint8_t end_column_addr)
 set left horizontal scroll one column
uint8_t ssd1309_set_gpio (ssd1309_handle_t *handle, ssd1309_gpio_t gpio)
 set gpio
uint8_t ssd1309_set_mcu_interface_lock (ssd1309_handle_t *handle, ssd1309_bool_t enable)
 enable or disable mcu interface lock
uint8_t ssd1309_write_cmd (ssd1309_handle_t *handle, uint8_t *buf, uint8_t len)
 write the register command
uint8_t ssd1309_write_data (ssd1309_handle_t *handle, uint8_t *buf, uint8_t len)
 write the register data
uint8_t ssd1309_info (ssd1309_info_t *info)
 get chip's information

Detailed Description

driver ssd1309 source file

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version
1.0.0
Author
Shifeng Li
Date
2024-10-30

history

Date Version Author Description
2024/10/30 1.0 Shifeng Li first upload

Definition in file driver_ssd1309.c.

Macro Definition Documentation

◆ CHIP_NAME

#define CHIP_NAME   "Solomon Systech SSD1309"

chip information definition

chip name

Definition at line 43 of file driver_ssd1309.c.

◆ DRIVER_VERSION

#define DRIVER_VERSION   1000

driver version

Definition at line 50 of file driver_ssd1309.c.

◆ MANUFACTURER_NAME

#define MANUFACTURER_NAME   "Solomon Systech"

manufacturer name

Definition at line 44 of file driver_ssd1309.c.

◆ MAX_CURRENT

#define MAX_CURRENT   0.58f

chip max current

Definition at line 47 of file driver_ssd1309.c.

◆ SSD1309_CMD

#define SSD1309_CMD   0

chip command data definition

command

Definition at line 55 of file driver_ssd1309.c.

◆ SSD1309_CMD_ACTIVATE_SCROLL

#define SSD1309_CMD_ACTIVATE_SCROLL   0x2F

command activate scroll

Definition at line 73 of file driver_ssd1309.c.

◆ SSD1309_CMD_COLUMN_0_MAPPED_TO_SEG0

#define SSD1309_CMD_COLUMN_0_MAPPED_TO_SEG0   0xA0

command column 0 mapped to seg 0

Definition at line 76 of file driver_ssd1309.c.

◆ SSD1309_CMD_COLUMN_127_MAPPED_TO_SEG0

#define SSD1309_CMD_COLUMN_127_MAPPED_TO_SEG0   0xA1

command column 127 mapped to seg 0

Definition at line 77 of file driver_ssd1309.c.

◆ SSD1309_CMD_COM_PINS_CONF

#define SSD1309_CMD_COM_PINS_CONF   0xDA

command com pins conf

Definition at line 92 of file driver_ssd1309.c.

◆ SSD1309_CMD_COMH_DESLECT_LEVEL

#define SSD1309_CMD_COMH_DESLECT_LEVEL   0xDB

command comh deslect level

Definition at line 93 of file driver_ssd1309.c.

◆ SSD1309_CMD_CONTRAST_CONTROL

#define SSD1309_CMD_CONTRAST_CONTROL   0x81

command contrast control

Definition at line 75 of file driver_ssd1309.c.

◆ SSD1309_CMD_DEACTIVATE_SCROLL

#define SSD1309_CMD_DEACTIVATE_SCROLL   0x2E

command deactivate scroll

Definition at line 72 of file driver_ssd1309.c.

◆ SSD1309_CMD_DISPLAY_CLOCK_DIVIDE

#define SSD1309_CMD_DISPLAY_CLOCK_DIVIDE   0xD5

command display clock divide

Definition at line 90 of file driver_ssd1309.c.

◆ SSD1309_CMD_DISPLAY_OFF

#define SSD1309_CMD_DISPLAY_OFF   0xAE

command display off

Definition at line 84 of file driver_ssd1309.c.

◆ SSD1309_CMD_DISPLAY_OFFSET

#define SSD1309_CMD_DISPLAY_OFFSET   0xD3

command display offset

Definition at line 89 of file driver_ssd1309.c.

◆ SSD1309_CMD_DISPLAY_ON

#define SSD1309_CMD_DISPLAY_ON   0xAF

command display on

Definition at line 85 of file driver_ssd1309.c.

◆ SSD1309_CMD_DISPLAY_START_LINE

#define SSD1309_CMD_DISPLAY_START_LINE   0x40

command display start line

Definition at line 74 of file driver_ssd1309.c.

◆ SSD1309_CMD_ENTIRE_DISPLAY_OFF

#define SSD1309_CMD_ENTIRE_DISPLAY_OFF   0xA4

command entire display off

Definition at line 79 of file driver_ssd1309.c.

◆ SSD1309_CMD_ENTIRE_DISPLAY_ON

#define SSD1309_CMD_ENTIRE_DISPLAY_ON   0xA5

command entire display on

Definition at line 80 of file driver_ssd1309.c.

◆ SSD1309_CMD_GPIO

#define SSD1309_CMD_GPIO   0xDC

command set gpio

Definition at line 94 of file driver_ssd1309.c.

◆ SSD1309_CMD_HIGHER_COLUMN_START_ADDRESS

#define SSD1309_CMD_HIGHER_COLUMN_START_ADDRESS   0x10

command higher column start address

Definition at line 62 of file driver_ssd1309.c.

◆ SSD1309_CMD_INVERSE_DISPLAY

#define SSD1309_CMD_INVERSE_DISPLAY   0xA7

command inverse display

Definition at line 82 of file driver_ssd1309.c.

◆ SSD1309_CMD_LEFT_HORIZONTAL_SCROLL

#define SSD1309_CMD_LEFT_HORIZONTAL_SCROLL   0x27

command left horizontal scroll

Definition at line 67 of file driver_ssd1309.c.

◆ SSD1309_CMD_LEFT_HORIZONTAL_SCROLL_ONE_COL

#define SSD1309_CMD_LEFT_HORIZONTAL_SCROLL_ONE_COL   0x2D

command left horizontal scroll by one column

Definition at line 71 of file driver_ssd1309.c.

◆ SSD1309_CMD_LOCK

#define SSD1309_CMD_LOCK   0xFD

command set lock

Definition at line 95 of file driver_ssd1309.c.

◆ SSD1309_CMD_LOWER_COLUMN_START_ADDRESS

#define SSD1309_CMD_LOWER_COLUMN_START_ADDRESS   0x00

chip command definition

command lower column start address

Definition at line 61 of file driver_ssd1309.c.

◆ SSD1309_CMD_MEMORY_ADDRESSING_MODE

#define SSD1309_CMD_MEMORY_ADDRESSING_MODE   0x20

command memory addressing mode

Definition at line 63 of file driver_ssd1309.c.

◆ SSD1309_CMD_MULTIPLEX_RATIO

#define SSD1309_CMD_MULTIPLEX_RATIO   0xA8

command multiplex ratio

Definition at line 83 of file driver_ssd1309.c.

◆ SSD1309_CMD_NORMAL_DISPLAY

#define SSD1309_CMD_NORMAL_DISPLAY   0xA6

command normal display

Definition at line 81 of file driver_ssd1309.c.

◆ SSD1309_CMD_PAGE_ADDR

#define SSD1309_CMD_PAGE_ADDR   0xB0

command page address

Definition at line 86 of file driver_ssd1309.c.

◆ SSD1309_CMD_PRE_CHARGE_PERIOD

#define SSD1309_CMD_PRE_CHARGE_PERIOD   0xD9

command pre charge period

Definition at line 91 of file driver_ssd1309.c.

◆ SSD1309_CMD_RIGHT_HORIZONTAL_SCROLL

#define SSD1309_CMD_RIGHT_HORIZONTAL_SCROLL   0x26

command right horizontal scroll

Definition at line 66 of file driver_ssd1309.c.

◆ SSD1309_CMD_RIGHT_HORIZONTAL_SCROLL_ONE_COL

#define SSD1309_CMD_RIGHT_HORIZONTAL_SCROLL_ONE_COL   0x2C

command right horizontal scroll by one column

Definition at line 70 of file driver_ssd1309.c.

◆ SSD1309_CMD_SCAN_DIRECTION_COM0_START

#define SSD1309_CMD_SCAN_DIRECTION_COM0_START   0xC0

command scan direction com 0 start

Definition at line 87 of file driver_ssd1309.c.

◆ SSD1309_CMD_SCAN_DIRECTION_COMN_1_START

#define SSD1309_CMD_SCAN_DIRECTION_COMN_1_START   0xC8

command scan direction com n-1 start

Definition at line 88 of file driver_ssd1309.c.

◆ SSD1309_CMD_SET_COLUMN_ADDRESS

#define SSD1309_CMD_SET_COLUMN_ADDRESS   0x21

command set column address

Definition at line 64 of file driver_ssd1309.c.

◆ SSD1309_CMD_SET_PAGE_ADDRESS

#define SSD1309_CMD_SET_PAGE_ADDRESS   0x22

command set page address

Definition at line 65 of file driver_ssd1309.c.

◆ SSD1309_CMD_VERTICAL_LEFT_HORIZONTAL_SCROLL

#define SSD1309_CMD_VERTICAL_LEFT_HORIZONTAL_SCROLL   0x2A

command vertical left horizontal scroll

Definition at line 69 of file driver_ssd1309.c.

◆ SSD1309_CMD_VERTICAL_RIGHT_HORIZONTAL_SCROLL

#define SSD1309_CMD_VERTICAL_RIGHT_HORIZONTAL_SCROLL   0x29

command vertical right horizontal scroll

Definition at line 68 of file driver_ssd1309.c.

◆ SSD1309_CMD_VERTICAL_SCROLL_AREA

#define SSD1309_CMD_VERTICAL_SCROLL_AREA   0xA3

command vertical scroll area

Definition at line 78 of file driver_ssd1309.c.

◆ SSD1309_DATA

#define SSD1309_DATA   1

data

Definition at line 56 of file driver_ssd1309.c.

◆ SUPPLY_VOLTAGE_MAX

#define SUPPLY_VOLTAGE_MAX   3.3f

chip max supply voltage

Definition at line 46 of file driver_ssd1309.c.

◆ SUPPLY_VOLTAGE_MIN

#define SUPPLY_VOLTAGE_MIN   1.65f

chip min supply voltage

Definition at line 45 of file driver_ssd1309.c.

◆ TEMPERATURE_MAX

#define TEMPERATURE_MAX   85.0f

chip max operating temperature

Definition at line 49 of file driver_ssd1309.c.

◆ TEMPERATURE_MIN

#define TEMPERATURE_MIN   -40.0f

chip min operating temperature

Definition at line 48 of file driver_ssd1309.c.