HX1230 96x68 Mono LCD - Nokia 5110 killer

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
User avatar
mcauser
Posts: 444
Joined: Mon Jun 15, 2015 8:03 am

HX1230 96x68 Mono LCD - Nokia 5110 killer

Post by mcauser » Mon Aug 19, 2019 5:54 am

I created a library for HX1230 96x68 monochrome LCDs.
https://github.com/mcauser/micropython-hx1230

"upgrade of the Nokia 5110 LCD"

Image

Using bit-bang SPI and hardware SPI and included a version which extends the Framebuffer.
Last edited by mcauser on Mon Aug 19, 2019 6:58 am, edited 1 time in total.

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

Re: HX1230 96x68 Mono LCD

Post by mcauser » Mon Aug 19, 2019 6:01 am

The display module is configured to use 3-wire SPI mode (No D/C pin).
This means, the DIN pin expects 9 bits per transfer: D/C, then 8 data bits on each CLK pulse.

I was able to bit bang this, but then I discovered I could use hardware SPI by sending two bytes (16 bits) per command, with some padding.
First byte: D/C then 7 data bits (MSB first)
Second byte: 1 data bit (LSB), 7 padding zero bits.

User avatar
jimmo
Posts: 1440
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: HX1230 96x68 Mono LCD - Nokia 5110 killer

Post by jimmo » Tue Aug 20, 2019 5:06 am

Neat!

This is just so you can play Snake, written in MicroPython, on a 5110 display right? :)

(a quick Google turned up https://github.com/Zhebr/snake)

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

Re: HX1230 96x68 Mono LCD - Nokia 5110 killer

Post by mcauser » Tue Aug 20, 2019 5:49 am

I've been mucking around with this display and found the Nokia 5110 display to be significantly faster.

Having to send the 9-bit SPI as 16 bytes means tons of wasted bytes being sent.
96 * 72 / 8 * 7 = 6048 extra padding bits for a full screen refresh.
If I can figure out how to send multiple sequential data bytes, should dramatically improve the speed.

And yes, I'll put together a ubiquitous snake demo at some point :D

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

Re: HX1230 96x68 Mono LCD - Nokia 5110 killer

Post by Roberthh » Tue Aug 20, 2019 6:10 am

Can't you pack that further, like 8 screen symbols in 9 bytes? Obviously, it's a little bit more code, which needs time to pack, which may be slower that just using two bytes for each symbol.

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

Re: HX1230 96x68 Mono LCD - Nokia 5110 killer

Post by mcauser » Tue Aug 20, 2019 7:28 am

@Roberthh I tried squishing it like that, but couldn't get it working.

Edit: Tried again tonight and it worked this time!
Now I just need to figure out how to pack 1 extra bit before every 8th bit, efficiently.

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

Re: HX1230 96x68 Mono LCD - Nokia 5110 killer

Post by mcauser » Thu Aug 22, 2019 3:11 pm

Updated to pack 8 data bytes into 9 bytes, with a byte of DC bits.

On ESP8266, full screen writes (864 bytes) are now more than 2x faster, without writing all of those padding bits.

CPU running at 80mhz
Before: 241,105 us
After: 114,265 us

CPU running at 160mhz
Before: 168,606 us
After: 63,752 us

stanely
Posts: 40
Joined: Fri Jan 17, 2020 5:19 am
Location: Ohio, USA

Re: HX1230 96x68 Mono LCD - Nokia 5110 killer

Post by stanely » Sat Feb 29, 2020 2:50 pm

That's great work, I'm going to try out your driver as soon as my HX1230 gets here. You started out using 9-bit transfers with two bytes. But looking at the hardware SPI specs for the ESP32 here, http://docs.micropython.org/en/latest/l ... e.SPI.html, it says that number of bits is variable in the init statement.

Code: Select all

SPI.init(baudrate=1000000, *, polarity=0, phase=0,
	bits=8,
	firstbit=SPI.MSB, sck=None, mosi=None, miso=None, pins=(SCK, MOSI, MISO))
The docs go on to say,
bits is the width in bits of each transfer. Only 8 is guaranteed to be supported by all hardware.
I tried to find specifics about the ESP32's SPI hardware interface, but couldn't find anything about bit width. Is this a possiblility and has anyone tried it?

Post Reply