Add I2C example to communication abstraction interface
This commit is contained in:
parent
8bdc2aed38
commit
db8be8a4da
5 changed files with 33 additions and 38 deletions
|
@ -7,6 +7,11 @@
|
|||
#include "driver/gpio.h"
|
||||
|
||||
#include "disp_spi.h"
|
||||
#include "lvgl_i2c/i2c_manager.h"
|
||||
|
||||
/* TODO: This is ssd1306 specific */
|
||||
#define OLED_I2C_PORT (CONFIG_LV_I2C_DISPLAY_PORT)
|
||||
#define OLED_I2C_ADDRESS 0x3C
|
||||
|
||||
#define LV_DISPLAY_DC_CMD_MODE 0
|
||||
#define LV_DISPLAY_DC_DATA_MODE 1
|
||||
|
@ -75,6 +80,9 @@ void display_interface_send_cmd(lv_disp_drv_t *drv, uint8_t cmd, void *args, siz
|
|||
disp_spi_send_data(args, args_len);
|
||||
}
|
||||
#elif defined (CONFIG_LV_TFT_DISPLAY_PROTOCOL_I2C)
|
||||
(void) drv;
|
||||
uint8_t *data = (uint8_t *) args;
|
||||
lvgl_i2c_write(OLED_I2C_PORT, OLED_I2C_ADDRESS, cmd, data, args_len);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -86,5 +94,20 @@ void display_interface_send_data_async(lv_disp_drv_t *drv, void *data, size_t le
|
|||
|
||||
disp_spi_send_colors(data, len);
|
||||
#elif defined (CONFIG_LV_TFT_DISPLAY_PROTOCOL_I2C)
|
||||
(void) drv;
|
||||
lvgl_i2c_write(OLED_I2C_PORT, OLED_I2C_ADDRESS, OLED_CONTROL_BYTE_DATA_STREAM, data, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
void display_interface_send_data(lv_disp_drv_t *drv, void *data, size_t len)
|
||||
{
|
||||
#if defined (CONFIG_LV_TFT_DISPLAY_PROTOCOL_SPI)
|
||||
disp_wait_for_pending_transactions();
|
||||
display_port_gpio_dc(drv, LV_DISPLAY_DC_DATA_MODE);
|
||||
|
||||
disp_spi_send_colors(data, len);
|
||||
#elif defined (CONFIG_LV_TFT_DISPLAY_PROTOCOL_I2C)
|
||||
(void) drv;
|
||||
lvgl_i2c_write(OLED_I2C_PORT, OLED_I2C_ADDRESS, OLED_CONTROL_BYTE_DATA_STREAM, data, len);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue