Multiple displays Oled with u8g2 Library
Posted: Mon Apr 08, 2024 1:21 am
I am using a library called u8g2 to display the data on the i2c oled display.
This library "Originally made for Arduino" I can make it work with a port made by a colleague.
And it works perfectly.
I have a 16 channel multiplexer and everything is mounted on the breadboard. Working perfectly.
https://github.com/mkfrey/u8g2-hal-esp-idf
I use this library below to port and it works perfectly.
However, when I repeat the code to create a new u8g2 object, it gives an error during execution.
I'm lost on how to solve this problem, which way to go. He knows
Where am I going wrong?
This library "Originally made for Arduino" I can make it work with a port made by a colleague.
And it works perfectly.
I have a 16 channel multiplexer and everything is mounted on the breadboard. Working perfectly.
https://github.com/mkfrey/u8g2-hal-esp-idf
I use this library below to port and it works perfectly.
- #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(1);//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);
- */
- }
I'm lost on how to solve this problem, which way to go. He knows
Where am I going wrong?
- I (872) wifi_init: tcp tx win: 5760
- I (872) wifi_init: tcp rx win: 5760
- I (872) wifi_init: tcp mss: 1440
- I (882) wifi_init: WiFi IRAM OP enabled
- I (882) wifi_init: WiFi RX IRAM OP enabled
- I (892) phy_init: phy_version 4791,2c4672b,Dec 20 2023,16:06:06
- I (982) wifi:mode : sta (08:d1:f9:e1:06:60)
- I (982) wifi:enable tsf
- I (992) INFO: Wifi-Conectando...
- I (1002) wifi:new:<11,0>, old:<1,0>, ap:<255,255>, sta:<11,0>, prof:1
- I (1002) wifi:state: init -> auth (b0)
- I (1012) wifi:state: auth -> assoc (0)
- W (1012) Multiplexer: Canal 1 - (1 0 0 0)
- I (1012) u8g2_hal: sda_io_num 21
- I (1012) wifi:state: assoc -> run (10)
- I (1012) u8g2_hal: scl_io_num 22
- I (1022) u8g2_hal: clk_speed 50000
- I (1022) u8g2_hal: i2c_param_config 1
- I (1032) u8g2_hal: i2c_driver_install 1
- I (1252) wifi:<ba-add>idx:0 (ifx:0, 38:6b:1c:01:ea:a8), tid:0, ssn:462, winSize:64
- I (1262) wifi:connected with WifiStudio, aid = 7, channel 11, BW20, bssid = 38:6b:1c:01:ea:a8
- I (1262) wifi:security: WPA2-PSK, phy: bgn, rssi: -54
- I (1272) wifi:pm start, type: 1
- I (1272) wifi:dp: 1, bi: 102400, li: 3, scale listen interval from 307200 us to 307200 us
- I (1282) INFO: Wifi-Conectado
- I (1342) wifi:AP's beacon interval = 102400 us, DTIM period = 1
- W (1342) wifi:[ADDBA]rx delba, code:39, delete tid:0
- I (1342) wifi:<ba-del>idx:0, tid:0
- W (1602) Multiplexer: Canal 3 - (1 1 0 0)
- I (1602) u8g2_hal: sda_io_num 21
- I (1602) u8g2_hal: scl_io_num 22
- I (1602) u8g2_hal: clk_speed 50000
- I (1602) u8g2_hal: i2c_param_config 1
- I (1612) u8g2_hal: i2c_driver_install 1
- E (1612) i2c: i2c driver install error
- E (1612) err: esp_err_t = -1
- assert failed: u8g2_esp32_i2c_byte_cb u8g2_esp32_hal.c:148 (0 && "i2c_driver_install(I2C_MASTER_NUM, conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0)")
- Backtrace: 0x40081bae:0x3ffba780 0x4008a471:0x3ffba7a0 0x40092795:0x3ffba7c0 0x400db513:0x3ffba8e0 0x400db129:0x3ffba920 0x400db177:0x3ffba940 0x400db321:0x3ffba960 0x401661ed:0x3ffba980 0x400d92e9:0x3ffba9a0 0x400d8850:0x3ffba9e0 0x4016d47b:0x3ffbaa80 0x4008afe9:0x3ffbaab0
- 0x40081bae: panic_abort at /home/allan/esp32/esp-idf/components/esp_system/panic.c:469
- 0x4008a471: esp_system_abort at /home/allan/esp32/esp-idf/components/esp_system/port/esp_system_chip.c:92
- 0x40092795: __assert_func at /home/allan/esp32/esp-idf/components/newlib/assert.c:81
- 0x400db513: u8g2_esp32_i2c_byte_cb at /home/allan/Codigos/EnervisionMegaDash/components/u8g2-hal-esp-idf/src/u8g2_esp32_hal.c:148 (discriminator 17)
- 0x400db129: u8x8_cad_ssd13xx_fast_i2c at /home/allan/Codigos/EnervisionMegaDash/components/u8g2/csrc/u8x8_cad.c:592
- 0x400db177: u8x8_d_helper_display_init at /home/allan/Codigos/EnervisionMegaDash/components/u8g2/csrc/u8x8_display.c:68
- 0x400db321: u8x8_d_sh1106_128x64_noname at /home/allan/Codigos/EnervisionMegaDash/components/u8g2/csrc/u8x8_d_ssd1306_128x64_noname.c:487
- 0x401661ed: u8x8_InitDisplay at /home/allan/Codigos/EnervisionMegaDash/components/u8g2/csrc/u8x8_display.c:137
- 0x400d92e9: f_setupI2c at /home/allan/Codigos/EnervisionMegaDash/main/f_display.c:44
- 0x400d8850: app_main at /home/allan/Codigos/EnervisionMegaDash/main/main.c:40
- 0x4016d47b: main_task at /home/allan/esp32/esp-idf/components/freertos/app_startup.c:208
- 0x4008afe9: vPortTaskWrapper at /home/allan/esp32/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:134
- ELF file SHA256: 757a52547
- Rebooting...
- ets Jul 29 2019 12:21:46
- rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
- configsip: 0, SPIWP:0xee
- clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
- mode:DIO, clock div:2
- load:0x3fff0030,len:7172
- load:0x40078000,len:15556
- load:0x40080400,len:4
- 0x40080400: _init at ??:?
- ho 8 tail 4 room 4
- load:0x40080404,len:3904
- entry 0x40080640
- I (31) boot: ESP-IDF v5.3-dev-1922-g5454d37d49 2nd stage bootloader
- I (31) boot: compile time Apr 6 2024 17:06:50
- I (33) boot: Multicore bootloader
- I (37) boot: chip revision: v3.1
- I (41) boot.esp32: SPI Speed : 40MHz
- I (45) boot.esp32: SPI Mode : DIO
- I (50) boot.esp32: SPI Flash Size : 4MB
- I (54) boot: Enabling RNG early entropy source...
- I (60) boot: Partition Table:
- I (63) boot: ## Label Usage Type ST Offset Length
- I (71) boot: 0 nvs WiFi data 01 02 00009000 00010000
- I (78) boot: 1 phy_init RF data 01 01 00019000 00010000
- I (86) boot: 2 factory factory app 00 00 00030000 00100000
- I (93) boot: 3 storage Unknown data 01 82 00130000 00100000
- I (101) boot: End of partition table