Porting Nokia5110 lcd code in C to available in upython?

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
Post Reply
Posts: 20
Joined: Thu May 25, 2017 2:21 pm

Porting Nokia5110 lcd code in C to available in upython?

Post by Delebel » Fri May 26, 2017 9:33 pm

Hi I'm very certainly a Newbie but hopefully a persistent one so that I will advance my project... So turning C code from an 8 bit (pic18f4620) platform to some kind of driver like for the LCD upython already supports. Specially the LCD is a Nokia3110/5110 type. I got the code off github originally. I just want to get some guidance as to what an where to look for info on doing it because I wish to learn in the process.

Thanks Denis the newbie...

User avatar
Posts: 1319
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Porting Nokia5110 lcd code in C to available in upython?

Post by Roberthh » Sat May 27, 2017 7:16 am

If you search thi forum for 5110 you'll find a driver and a lot of useful discussion too. Just use the "search" button. @mcauser has contributed many useful drivers.

User avatar
Posts: 356
Joined: Mon Jun 15, 2015 8:03 am

Re: Porting Nokia5110 lcd code in C to available in upython?

Post by mcauser » Thu Jun 01, 2017 5:29 am

I've used mbirth's wipy-upcd8544 driver in a bunch of my ESP8266 projects.

It was originally created for wipy, but with a few small modifications, works with ESP8266.

Edit: since have created my own version, which is compatible with MicroPython 1.9, ESP8266 and uses the framebuf:

https://github.com/mcauser/MicroPython- ... Nokia-5110
https://github.com/mcauser/MicroPython- ... me-of-Life
https://github.com/mcauser/MicroPython- ... 10-Bitcoin

It's really easy to write to the display. You can either throw a 84x48 byte array (84*48/8=504 bytes) at the lcd.data() method, or use framebuf, which lets you draw basic shapes an use fonts.

Bytes in the byte array passed to data() are in column major / horizontal orientation.


Code: Select all

from machine import Pin, SPI
from upcd8544 import PCD8544

spi = SPI(1)
spi.init(baudrate=8000000, polarity=0, phase=0)
RST = Pin(0, Pin.OUT)
CE = Pin(2, Pin.OUT)
DC = Pin(15, Pin.OUT)
BL = Pin(12, Pin.OUT)
lcd = PCD8544(spi, RST, CE, DC, BL)

from framebuf import FrameBuffer1
width = 84
height = 48
buffer = bytearray((height // 8) * width)
framebuf = FrameBuffer1(buffer, width, height)

# black screen

# white screen

# write some text

# reset

# draw a 84x48 picture
image = bytearray([
This is the bitmap displayed above:
https://github.com/mcauser/WeMos-D1-min ... -84x48.bmp
The Nokia loading screen.
Last edited by mcauser on Fri Jun 23, 2017 12:54 am, edited 1 time in total.

Posts: 20
Joined: Thu May 25, 2017 2:21 pm

Re: Porting Nokia5110 lcd code in C to available in upython?

Post by Delebel » Thu Jun 01, 2017 12:25 pm

Thanks I'm still wrestling with the learning curve to learn uPython as an the old school C coder. I've setup the Pyboard with a compatible connector to my Homestat (thermostat/venmar/humidifyer/dehumidifyer+AC) IO panel so that I can experiment with the Pyboard and then retreat to my old C controller so I don't freeze at night... LOL

Thanks again...Denis

Posts: 20
Joined: Thu May 25, 2017 2:21 pm

Re: Porting Nokia5110 lcd code in C to available in upython?

Post by Delebel » Wed Jul 25, 2018 4:02 pm

Finally got the Nokia LCD to work with the example. Had a hardware issue with the io lines (SPI In/Out lines reversed). I also was trying to get the LCD to work without a RST line because I was getting away with it on my C coded platform. When I added it back the example code used it, it worked immediately. I will try later to have the LCD reset to happen in hardware (power up RC). Thanks for the feedback...Denis

Post Reply