WIP debug I2C driver error
E (413) i2c: CONFLICT! driver_ng is not allowed to be used with this old driver
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
idf_component_register(
|
||||
SRCS "main.cpp"
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES driver
|
||||
)
|
||||
add_compile_definitions(PUBLIC "-DLOG_LOCAL_LEVEL=ESP_LOG_VERBOSE")
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
dependencies:
|
||||
## Required IDF version
|
||||
idf:
|
||||
version: '>=4.1.0'
|
||||
version: '>=5.3.2'
|
||||
# # Put list of dependencies here
|
||||
# # For components maintained by Espressif:
|
||||
# component: "~1.0.0"
|
||||
@@ -15,5 +15,6 @@ dependencies:
|
||||
# # All dependencies of `main` are public by default.
|
||||
# public: true
|
||||
espressif/arduino-esp32: ^3.1.1
|
||||
espressif/esp_lvgl_port: ^2.4.4
|
||||
# fasani/adafruit_gfx: ^1.7.8
|
||||
lvgl/lvgl: "^8"
|
||||
esp_lcd_sh1107: "^1"
|
||||
esp_lvgl_port: "*"
|
||||
@@ -1,39 +1,40 @@
|
||||
#include <driver/i2c_master.h>
|
||||
#include <esp_lcd_io_i2c.h>
|
||||
#include "driver/i2c_master.h"
|
||||
#include "esp_lcd_panel_ssd1306.h"
|
||||
#include "esp_lvgl_port.h"
|
||||
|
||||
#include "HardwareSerial.h"
|
||||
#include "WiFi.h"
|
||||
|
||||
#include "lvgl.h"
|
||||
#include "soc/gpio_num.h"
|
||||
#include "esp_lvgl_port.h"
|
||||
|
||||
static const char *TAG = "lcd-panel";
|
||||
|
||||
// https://www.digikey.com/en/products/detail/winstar-display/WEA012864DWPP3N00003/20533255
|
||||
// According to SSD1306 datasheet
|
||||
// Bit number used to represent command and parameter
|
||||
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
|
||||
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
||||
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
||||
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
|
||||
#define LCD_H_RES SCREEN_WIDTH
|
||||
#define LCD_V_RES SCREEN_HEIGHT
|
||||
#define I2C_HW_ADDR 0x3C
|
||||
#define LCD_PIXEL_CLOCK_HZ (400 * 1000)
|
||||
#define LCD_CMD_BITS 8
|
||||
#define LCD_PARAM_BITS 8
|
||||
#define PIN_NUM_RST -1
|
||||
#define LCD_H_RES 128
|
||||
|
||||
#define LCD_V_RES 64
|
||||
// TODO: Or?
|
||||
//#define LCD_V_RES 32
|
||||
|
||||
// Pin number may vary based on your schematic
|
||||
// Pin may vary based on your schematic
|
||||
#define SDA_PIN GPIO_NUM_21
|
||||
#define SCL_PIN GPIO_NUM_22
|
||||
|
||||
#include "Wire.h"
|
||||
#include "HardwareI2C.h"
|
||||
#include "hal/lv_hal_disp.h"
|
||||
#include "core/lv_obj.h"
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Wire.begin();
|
||||
ESP_LOGI(TAG, "Initialize I2C bus");
|
||||
Serial.println("Initialize I2C bus");
|
||||
i2c_master_bus_handle_t i2c_bus = nullptr;
|
||||
i2c_master_bus_config_t bus_config = {
|
||||
.i2c_port = I2C_STATUS_READ,
|
||||
@@ -50,6 +51,7 @@ void setup()
|
||||
ESP_ERROR_CHECK(i2c_new_master_bus(&bus_config, &i2c_bus));
|
||||
|
||||
ESP_LOGI(TAG, "Install panel IO");
|
||||
Serial.println("Install panel IO");
|
||||
esp_lcd_panel_io_handle_t io_handle = nullptr;
|
||||
esp_lcd_panel_io_i2c_config_t io_config = {
|
||||
.dev_addr = I2C_HW_ADDR,
|
||||
@@ -73,10 +75,12 @@ void setup()
|
||||
};
|
||||
panel_config.vendor_config = &ssd1306_config;
|
||||
ESP_LOGI(TAG, "Install SSD1306 panel driver");
|
||||
Serial.println("Install SSD1306 panel driver");
|
||||
ESP_ERROR_CHECK(
|
||||
esp_lcd_new_panel_ssd1306(io_handle, &panel_config, &panel_handle));
|
||||
|
||||
ESP_LOGI(TAG, "Initialize LVGL");
|
||||
Serial.println("Initialize LVGL");
|
||||
const lvgl_port_cfg_t lvgl_cfg = ESP_LVGL_PORT_INIT_CONFIG();
|
||||
lvgl_port_init(&lvgl_cfg);
|
||||
|
||||
@@ -93,7 +97,6 @@ void setup()
|
||||
.mirror_x = false,
|
||||
.mirror_y = false,
|
||||
},
|
||||
.color_format = LV_COLOR_FORMAT_RGB565,
|
||||
.flags = {
|
||||
.sw_rotate = false,
|
||||
}
|
||||
@@ -101,23 +104,23 @@ void setup()
|
||||
lv_disp_t *disp = lvgl_port_add_disp(&disp_cfg);
|
||||
|
||||
ESP_LOGI(TAG, "Display Scroll Text");
|
||||
Serial.println("Display Scroll Text");
|
||||
// Lock the mutex due to the LVGL APIs are not thread-safe
|
||||
if (lvgl_port_lock(0)) {
|
||||
Serial.println("Display Scroll Text mutex aquired");
|
||||
/* Rotation of the screen */
|
||||
lv_disp_set_rotation(disp, LV_DISPLAY_ROTATION_0);
|
||||
lv_disp_set_rotation(disp, LV_DISP_ROT_NONE);
|
||||
|
||||
//
|
||||
// TODO: Set text here
|
||||
lv_obj_t *scr = lv_disp_get_scr_act(disp);
|
||||
lv_obj_t *label = lv_label_create(scr);
|
||||
// Circular scroll
|
||||
lv_label_set_long_mode(label,
|
||||
LV_LABEL_LONG_SCROLL_CIRCULAR);
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
|
||||
lv_label_set_text(label, "Hello world!");
|
||||
// Size of the screen
|
||||
// If you use rotation 90 or 270, please set disp->driver->ver_res
|
||||
lv_obj_set_width(label,
|
||||
lv_display_get_physical_horizontal_resolution(disp));
|
||||
lv_obj_set_width(label, lv_disp_get_physical_hor_res(disp));
|
||||
lv_obj_align(label, LV_ALIGN_TOP_MID, 0, 0);
|
||||
|
||||
// Release the mutex
|
||||
@@ -127,5 +130,4 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user