Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MicroPython SSD1327

A MicroPython library for SSD1327 128x128 4-bit greyscale OLED displays, over I2C.
A MicroPython library for SSD1327 128x128 4-bit greyscale OLED displays, over I2C or SPI.

For example, the [Grove - OLED Display 1.12"](http://wiki.seeed.cc/Grove-OLED_Display_1.12inch/) which features a 96x96 display.

Expand All @@ -19,6 +19,11 @@ $ ampy put ssd1327.py
```python
import ssd1327

# using Hardware SPI
# from machine import Pin, SPI
# spi = SPI(1, baudrate=10000000, sck=Pin(SCK_PIN), mosi=Pin(MOSI_PIN))
# display = ssd1327.SSD1327_SPI(128, 128, spi, dc=Pin(DC_PIN), res=Pin(RST_PIN), cs=Pin(CS_PIN))

# using Software I2C
from machine import SoftI2C, Pin
i2c = SoftI2C(sda=Pin(21), scl=Pin(22)) # TinyPICO
Expand Down Expand Up @@ -51,6 +56,7 @@ See [/examples](/examples) for more.
* [Raspberry Pi Pico](https://core-electronics.com.au/raspberry-pi-pico.html)
* [WeMos D1 Mini](https://www.aliexpress.com/item/32529101036.html)
* [Grove Male Jumper Cable](https://www.seeedstudio.com/Grove-4-pin-Male-Jumper-to-Grove-4-pin-Conversion-Cable-5-PCs-per-Pack.html)
* [WaveShare 1.5inch OLED Module, SPI/I2C interface](https://www.waveshare.com/1.5inch-oled-module.htm)

## Connections

Expand Down
42 changes: 42 additions & 0 deletions ssd1327.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,45 @@ def lookup(self, table):
class WS_OLED_128X128(SSD1327_I2C):
def __init__(self, i2c, addr=0x3c):
super().__init__(128, 128, i2c, addr)

class SSD1327_SPI(SSD1327):
def __init__(self, width, height, spi, dc, res=None, cs=None):
self.spi = spi
self.dc = dc
self.res = res
self.cs = cs

# Initialize pins
self.dc.init(self.dc.OUT, value=0)

if self.res:
self.res.init(self.res.OUT, value=1)

if self.cs:
self.cs.init(self.cs.OUT, value=1)

# Perform hardware reset
if self.res:
self.res(0)
import time
time.sleep_ms(10)
self.res(1)
time.sleep_ms(10)

super().__init__(width, height)

def write_cmd(self, cmd):
if self.cs:
self.cs(0)
self.dc(0) # Command mode
self.spi.write(bytearray([cmd]))
if self.cs:
self.cs(1)

def write_data(self, data_buf):
if self.cs:
self.cs(0)
self.dc(1) # Data mode
self.spi.write(data_buf)
if self.cs:
self.cs(1)