u8g2-hal-esp-idf
u8g2-hal-esp-idf copied to clipboard
Multiple Display Oled with Multiplexer
Firstly I would like to thank you. This library works perfectly.
Although I had a little difficulty configuring the CMAKE file, I managed to make it work perfectly.
My project involves the use of multiple displays.
I need to initialize the i2c bus and then initialize each display.
However, ESP32, after being compiled, gives an error.
Does anyone have any idea which way to go?
I've tried several approaches and I'm lost as to which correct path I should follow.
See my code and project below.
My code approach would be this:
` #include <u8g2.h> #include "sdkconfig.h" #include "u8g2_esp32_hal.h"
#define PIN_SDA 21 #define PIN_SCL 22
u8g2_t u8g2; u8g2_t u8g2_1;
void f_setupI2c(){
selectChannel(2);//Select Display 2
u8g2_esp32_hal_t u8g2_esp32_hal = U8G2_ESP32_HAL_DEFAULT;
u8g2_esp32_hal.bus.i2c.sda = PIN_SDA;
u8g2_esp32_hal.bus.i2c.scl = PIN_SCL;
u8g2_esp32_hal_init(u8g2_esp32_hal);
u8g2_Setup_sh1106_i2c_128x64_noname_f(&u8g2, U8G2_R0,u8g2_esp32_i2c_byte_cb,u8g2_esp32_gpio_and_delay_cb);
u8x8_SetI2CAddress(&u8g2.u8x8, 0x78);
u8g2_InitDisplay(&u8g2);
u8g2_SetPowerSave(&u8g2, 0);
u8g2_ClearBuffer(&u8g2);
u8g2_SetFont(&u8g2, u8g2_font_ncenB10_tr);
u8g2_DrawStr(&u8g2, 0, 17, "ENERVISION");
u8g2_SendBuffer(&u8g2);
selectChannel(3); //Select Display 3
u8g2_Setup_sh1106_i2c_128x64_noname_f(&u8g2_1, U8G2_R0,u8g2_esp32_i2c_byte_cb,u8g2_esp32_gpio_and_delay_cb);
u8x8_SetI2CAddress(&u8g2_1.u8x8, 0x78);
u8g2_InitDisplay(&u8g2_1);
u8g2_SetPowerSave(&u8g2_1, 0);
u8g2_ClearBuffer(&u8g2_1);
u8g2_SetFont(&u8g2_1, u8g2_font_ncenB10_tr);
u8g2_DrawStr(&u8g2_1, 0, 17, "ENERVISION");
u8g2_SendBuffer(&u8g2_1);
}`
However, when you run the 3 display, I have an error during execution.
Does anyone have an idea where I'm going wrong?
How to separate i2c initialization and Display initialization?