Current Lua downloadable firmware will be posted here

User avatar
By 1flx
#55111 Hi!

I recently got my hands on a Nokia 3310/5110 display and since u8g supports it (pcd8544_84x48_hw_spi), I had to try hooking it up to a Wemos D1 Mini ... but I just can't manage to get it to work. Backlight works fine, but all I get is "snow", i.e. random pixels activated (black) once I run the u8g initialization function.

My wiring:
  • LED to 3v3
  • RST to D2 (physical GPIO 19)
  • CS to D1 (20)
  • D/C to D6 (12)
  • DIN to D7 (GPIO 13, MOSI)
  • CLK to D5 (GPIO 14, CLK)
  • VCC to 3v3
  • G to Ground

Here's the script I run to test the setup (tried both via luatool.py and serial):

Code: Select all-- SPI setup as in various examples
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 8)

cs  = 1
dc = 6
res = 2

disp = u8g.pcd8544_84x48_hw_spi(cs, dc, res)
-- now i get random pixels

disp:begin()
-- display doesn't change, still random pixel snow
disp:drawLine(1, 1, 20, 20)
-- still same random pixels, no line


I tried two different Wemos D1 Minis. I tried different pins for RST, CS and D/C, also pulling down the CS pin (since some examples do this), but all I get is a snow-like random pixel pattern (with about 10% or so of pixels active, sprinkled all over the display). I have no problems lighting LEDs, talking to various sensors (e.g. a BME280) and the like, so I guess it's not something fundamental. The display works fine on a Raspberry Pi Zero.

The firmware I use is a float one from the build service with 18 modules (bme280, file, gpio, i2c, mdns, mqtt, net, node, pwm, rotary, rtctime, sntp, spi, tmr, u8g, uart, wifi, ws2812) and three fonts, built a few days ago against master.

I'm a bit stuck, any advice or suggestions?

Thanks!

Regards,
Felix
User avatar
By devsaurus
#55244 You need to encapsulate the drawing functions in what U8glib calls the "pictureloop". See https://github.com/olikraus/u8glib/wiki/tpictureloop for some theoretical background.
Best would be to study the examples in https://github.com/nodemcu/nodemcu-firm ... les/u8glib and adopt the mechanics in there.
User avatar
By 1flx
#55301 Thanks for the feedback, but that doesn't seem to solve the problem completely. I modified u8g_graphics_test.lua from your second link to use the right display init function (and SPI) by replacing line 37 like this ...

Code: Select all--disp = u8g.ssd1306_128x64_hw_spi(cs, dc, res)
disp = u8g.pcd8544_84x48_hw_spi(cs, dc, res)


and switching the commenting in ln 173/174 like this:

Code: Select all--init_i2c_display()
init_spi_display()


Now I'm getting a perpetually blank display (no snow, just no picture either) and the Wemos's LED is always on.