Replace allLVGL driver I2C code with I2C Manager
For discussion see #70
This commit is contained in:
parent
8f1370d1c4
commit
e52112376f
24 changed files with 896 additions and 679 deletions
|
@ -13,10 +13,9 @@
|
|||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "driver/i2c.h"
|
||||
#include "assert.h"
|
||||
|
||||
#include "lvgl_i2c_conf.h"
|
||||
#include "i2c_manager/i2c_manager.h"
|
||||
|
||||
#include "ssd1306.h"
|
||||
|
||||
|
@ -25,6 +24,7 @@
|
|||
*********************/
|
||||
#define TAG "SSD1306"
|
||||
|
||||
#define OLED_I2C_PORT (CONFIG_LV_I2C_DISPLAY_PORT)
|
||||
// SLA (0x3C) + WRITE_MODE (0x00) = 0x78 (0b01111000)
|
||||
#define OLED_I2C_ADDRESS 0x3C
|
||||
#define OLED_WIDTH 128
|
||||
|
@ -70,8 +70,6 @@
|
|||
// Charge Pump (pg.62)
|
||||
#define OLED_CMD_SET_CHARGE_PUMP 0x8D // follow with 0x14
|
||||
|
||||
#define OLED_IIC_FREQ_HZ 400000 // I2C colock frequency
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
@ -217,20 +215,22 @@ static uint8_t send_data(lv_disp_drv_t *disp_drv, void *bytes, size_t bytes_len)
|
|||
|
||||
uint8_t *data = (uint8_t *) bytes;
|
||||
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
err = lvgl_i2c_write(OLED_I2C_PORT, OLED_I2C_ADDRESS, data[0], data + 1, bytes_len - 1 );
|
||||
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (OLED_I2C_ADDRESS << 1) | I2C_MASTER_WRITE, true);
|
||||
|
||||
for (size_t idx = 0; idx < bytes_len; idx++) {
|
||||
i2c_master_write_byte(cmd, data[idx], true);
|
||||
}
|
||||
|
||||
i2c_master_stop(cmd);
|
||||
|
||||
/* Send queued commands */
|
||||
err = i2c_master_cmd_begin(DISP_I2C_PORT, cmd, 10 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
// i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
//
|
||||
// i2c_master_start(cmd);
|
||||
// i2c_master_write_byte(cmd, (OLED_I2C_ADDRESS << 1) | I2C_MASTER_WRITE, true);
|
||||
//
|
||||
// for (size_t idx = 0; idx < bytes_len; idx++) {
|
||||
// i2c_master_write_byte(cmd, data[idx], true);
|
||||
// }
|
||||
//
|
||||
// i2c_master_stop(cmd);
|
||||
//
|
||||
// /* Send queued commands */
|
||||
// err = i2c_master_cmd_begin(DISP_I2C_PORT, cmd, 10 / portTICK_PERIOD_MS);
|
||||
// i2c_cmd_link_delete(cmd);
|
||||
|
||||
return ESP_OK == err ? 0 : 1;
|
||||
}
|
||||
|
@ -240,17 +240,7 @@ static uint8_t send_pixels(lv_disp_drv_t *disp_drv, void *color_buffer, size_t b
|
|||
(void) disp_drv;
|
||||
esp_err_t err;
|
||||
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (OLED_I2C_ADDRESS << 1) | I2C_MASTER_WRITE, true);
|
||||
|
||||
i2c_master_write_byte(cmd, OLED_CONTROL_BYTE_DATA_STREAM, true);
|
||||
i2c_master_write(cmd, (uint8_t *) color_buffer, buffer_len, true);
|
||||
i2c_master_stop(cmd);
|
||||
|
||||
/* Send queued commands */
|
||||
err = i2c_master_cmd_begin(DISP_I2C_PORT, cmd, 10 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
err = lvgl_i2c_write(OLED_I2C_PORT, OLED_I2C_ADDRESS, OLED_CONTROL_BYTE_DATA_STREAM, color_buffer, buffer_len);
|
||||
|
||||
return ESP_OK == err ? 0 : 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue