Skip to content
Micropython library for ST7920 128x64 monochrome LCD. Tested on a 'Cockle'; NodeMCU module w. Micropython 1.8.7
Branch: master
Clone or download
Pull request Compare This branch is 50 commits ahead of JMW95:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Micropython ST7920

Micropython library for simple graphic primitives on ST7920 128x64 monochrome LCD panel using ESP8266 and SPI


Can initialise a screen and framebuffer with...

import st7920 
screen = st7920.Screen()

Can draw points, lines and rectangles to a framebuffer with e.g.

screen.plot(10, 10)
screen.line(10, 10, 20, 20)
screen.rect(25, 25, 50, 50)
screen.fill_rect(5, 5, 95, 95)

Can draw inverse with e.g.

screen.plot(10, 10, False)
screen.line(10, 10, 20, 20, False)
screen.rect(25, 25, 50, 50, False)
screen.fill_rect(5, 5, 95, 95, False)

Then send finished 1kbyte frame to the screen at 1.8Mbaud with...


Finally clear again with...


Included Example

Install ampy by running...

pip install adafruit-ampy

Then change to this directory and upload files...

ampy --port /dev/ttyUSB0 put
ampy --port /dev/ttyUSB0 put

You should then be able to interactively run the following from the REPL...

import example

Alternatively upload the file as well as follows...

ampy --port /dev/ttyUSB0 put

...and the example will automatically run on boot


See also @ShrimpingIt's bitfont project for pixel typography logic which can be used with micropython-st7920 and other bit-rendering environments.


Developed by @cefn of @ShrimpingIt based on @JMW95's incredibly useful reference Raspberry Pi python SPI port at, funded by the Milecastles project


Consider use of Micropython's framebuf Framebuffer library to see if it offers any acceleration, or just for conformance with other libraries - draw primitives look like they are the same.

See also

ST7920 Datasheet

Micropython SPI reference

Arduino U8G2 reference setup for ST7920 128x64 SPI display

You can’t perform that action at this time.