SSD1306 micropython
Go to file
Stefan Lehmann 9582998cd8
Increase version
2020-12-16 16:43:58 +01:00
.gitignore Initial commit 2018-11-18 17:57:40 +01:00
LICENSE Initial commit 2018-11-18 17:57:40 +01:00
README.md Add example usage and installation to README 2018-11-18 19:00:47 +01:00
sdist_upip.py Add example usage and installation to README 2018-11-18 19:00:47 +01:00
setup.py Increase version 2020-12-16 16:43:58 +01:00
ssd1306.py Update ssd1306.py to latest version from upstream micropython repo 2020-12-10 08:05:51 +00:00

README.md

micropython-ssd1306

This is a fork of the driver for SSD1306 displays which is hosted in the Micropython package. The purpose of this fork is to make the driver available on PyPi and thus installable via the upip package manager.

Installation

Use the upip package manager:

upip.install('micropython-ssd1306')

If your board or your computer doesn't have an active internet connection you can also clone this project on your local drive and copy the ssd1306.py to your board.

Example Usage

This shows an example usage on an ESP32 board with an SSD1306 display with an resolution of 128x32 pixels. The display is connected via I2C. On the ESP32 the I2C pins are: SDA: 23, SCL: 22.

First we set up the I2C bus on our ESP32 and scan for devices.

>>> import machine
>>> i2c = machine.I2C(sda=machine.Pin(23), scl=machine.Pin(22))
>>> i2c.scan()
[60]

This shows us that there is a device on address 60 which is 3C in Hex. That is where our display is supposed to live. Now we create an object for our OLED display.

>>> from ssd1306 import SSD1306_I2C
>>> oled = SSD1306_I2C(128, 32, i2c)

This is it. Now we can use our OLED display:

>>> oled.fill(1)
>>> oled.show()

This fills the whole display with white pixels. To clear the display do:

>>> oled.fill(0)
>>> oled.show()

Now we can also write some text:

>>> oled.text('Hello', 0, 0)
>>> oled.text('World', 0, 10)
>>> oled.show()

Find more information on how to use the SSD1306 on the great tutorial about the OLED featherwing from Adafruit.