SRA Board Components
ESP-IDF component for SRA Board
Macros | Functions
lvgl_helpers.c File Reference
#include "lvgl_helpers.h"
#include "esp_log.h"
Include dependency graph for lvgl_helpers.c:

Macros

#define TAG   "lvgl_helpers_ssd1306"
 
#define BIT_SET(a, b)   ((a) |= (1U << (b)))
 
#define BIT_CLEAR(a, b)   ((a) &= ~(1U << (b)))
 

Functions

void ssd1306_init (void)
 Initialize ssd1306 device. More...
 
void ssd1306_set_px_cb (lv_disp_drv_t *disp_drv, uint8_t *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa)
 Draw a pixel into the buffer. More...
 
void ssd1306_flush (lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p)
 Flush the buffer on the screen. More...
 
void ssd1306_rounder (lv_disp_drv_t *disp_drv, lv_area_t *area)
 Round the area that needs to be updated. More...
 
void ssd1306_sleep_in (void)
 Turn off the display. More...
 
void ssd1306_sleep_out (void)
 Turn on the display. More...
 
bool lvgl_i2c_driver_init (int sda_pin, int scl_pin, int speed_hz)
 Initialize LVGL I2C Master. More...
 

Macro Definition Documentation

◆ BIT_CLEAR

#define BIT_CLEAR (   a,
 
)    ((a) &= ~(1U << (b)))

◆ BIT_SET

#define BIT_SET (   a,
 
)    ((a) |= (1U << (b)))

◆ TAG

#define TAG   "lvgl_helpers_ssd1306"

Code from https://github.com/yanbe/ssd1306-esp-idf-i2c.git is used as a starting point, in addition to code from https://github.com/espressif/esp-iot-solution.

Definitions are borrowed from: http://robotcantalk.blogspot.com/2015/03/interfacing-arduino-with-ssd1306-driven.html

For LVGL the forum has been used, in particular: https://blog.littlevgl.com/2019-05-06/oled

Function Documentation

◆ lvgl_i2c_driver_init()

bool lvgl_i2c_driver_init ( int  sda_pin,
int  scl_pin,
int  speed_hz 
)

Initialize LVGL I2C Master.

Parameters
sda_pingpio number for I2C master data
scl_pingpio number for I2C master clock
speed_hzI2C master clock frequency
Returns
esp_err_t returns ESP_OK if I2C is initialized successfully, else the appropriate error code

◆ ssd1306_flush()

void ssd1306_flush ( lv_disp_drv_t *  drv,
const lv_area_t *  area,
lv_color_t *  color_map 
)

Flush the buffer on the screen.

Parameters
drvpointer to the display driver structure
arearepresents an area on the screen
color_maprepresents the color map

◆ ssd1306_init()

void ssd1306_init ( void  )

Initialize ssd1306 device.

Returns
esp_err_t returns ESP_OK if I2C is initialized successfully, else the appropriate error code

◆ ssd1306_rounder()

void ssd1306_rounder ( lv_disp_drv_t *  disp_drv,
lv_area_t *  area 
)

Round the area that needs to be updated.

Parameters
drvpointer to the display driver structure
arearepresents an area on the screen

◆ ssd1306_set_px_cb()

void ssd1306_set_px_cb ( lv_disp_drv_t *  disp_drv,
uint8_t *  buf,
lv_coord_t  buf_w,
lv_coord_t  x,
lv_coord_t  y,
lv_color_t  color,
lv_opa_t  opa 
)

Draw a pixel into the buffer.

Parameters
disp_drvpointer to the display driver structure
bufpointer to the memory range where you want to update the data
buf_wwidth of the range where you want to update the data
xx co-ordinate of pixel to update
yy co-ordinate of pixel to update
colormonochrome color setting, either full or clear
opaopacity value

◆ ssd1306_sleep_in()

void ssd1306_sleep_in ( void  )

Turn off the display.

◆ ssd1306_sleep_out()

void ssd1306_sleep_out ( void  )

Turn on the display.