crashed when using u8g2 with ssd1306 i2c
galenzhao opened this issue · comments
Expected behavior
i2c ssd1306 works well
Actual behavior
device crashed when drawStr called
dofile("oled.lua")
Function platform_gpio_mode() is called. pin_mux:1610614796, func:3
Function platform_gpio_mode() is called. pin_mux:1610614788, func:3
Fatal exception 28(LoadProhibitedCause):
epc1=0x40261e3c, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000018, depc=0x00000000
�
ets Jan 8 2013,rst cause:2, boot mode:(3,7)
Test code
Provide a Minimal, Complete, and Verifiable example which will reproduce the problem.
-- display object
local disp
local draw_state, loop_tmr = 0, tmr.create()
-- setup I2c and connect display
local function init_i2c_display()
-- SDA and SCL can be assigned freely to available GPIOs
local sda = 5 -- GPIO14
local scl = 6 -- GPIO12
local sla = 0x3c
i2c.setup(0, sda, scl, i2c.SLOW)
disp = u8g2.ssd1306_i2c_128x64_noname(0, sla)
end
local function u8g2_prepare()
disp:setFont(u8g2.font_6x10_tf)
disp:setFontRefHeightExtendedText()
disp:setDrawColor(1)
disp:setFontPosTop()
disp:setFontDirection(0)
end
local function u8g2_ascii_1()
disp:drawStr( 0, 0, "ASCII page 1")
for y = 0, 5 do
for x = 0, 15 do
disp:drawStr(x*7, y*10+10, string.char(y*16 + x + 32))
end
end
end
local function u8g2_ascii_2()
disp:drawStr( 0, 0, "ASCII page 2")
for y = 0, 5 do
for x = 0, 15 do
disp:drawStr(x*7, y*10+10, string.char(y*16 + x + 160))
end
end
end
init_i2c_display()
disp:clearBuffer()
u8g2_ascii_1()
disp:sendBuffer()
NodeMCU startup banner
NodeMCU 3.0.0.0 built on nodemcu-build.com provided by frightanic.com
branch: release
commit: 4f67927
release: 3.0-release_20201107
release DTS: 202011071523
SSL: false
build type: float
LFS: 0x0 bytes total capacity
modules: adc,ads1115,encoder,enduser_setup,file,gpio,i2c,net,node,pwm,rotary,spi,tmr,u8g2,uart,wifi
build 2020-12-09 14:17 powered by Lua 5.1.4 on SDK 3.0.1-dev(fce080e)
Hardware
nodemcu dev kit,
with ssd1306 i2c oled.
Device found at address 0x3C
Device is wired: SDA to GPIO14 - IO index 5
Device is wired: SCL to GPIO12 - IO index 6
sorry, forget to call u8g2_prepare()