While testing tft 2.2 (ili9341) display using ucg library I noticed that whenever I try to write to display for about >4 seconds nodeMCU will reboot. However, after adding tmr.delay(1) into on of the loops it no longer reboots. I was wondering if that's the right fix and if there's a better command (I read in another thread that tmr.delay() should not be used). Here's my code:
function init_spi_display()
local cs = 1 -- GPIO12, pull-down 10k to GND
local dc = 4 --8 GPIO15
local res = 11 -- GPIO16
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 8)
disp = ucg.ili9341_18x240x320_hw_spi(cs, dc, res)
end
init_spi_display()
disp:begin(ucg.FONT_MODE_SOLID)
disp:setColor(1, 0, 0, 0);
disp:clearScreen()
c = 0
x = 0
disp:setPrintPos(2,18)
disp:setPrintDir(0)
disp:setFont(ucg.font_helvB10_hr)
while x < 200 do
while c < 20 do
disp:setColor(0, 255, 0, 0)
disp:print("A")
c = c + 1
end
tmr.delay(1) -- commenting it out will cause reboot
x=x+16
c=0
disp:setPrintPos(2,18+x)
end