Skip to content
Merged
Changes from 1 commit
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
175 changes: 170 additions & 5 deletions lib/ssd1327/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,174 @@
# MicroPython library for SSD1327 128x128 4-bit greyscale OLED displays
# SSD1327 MicroPython Driver

This library is a port of the [MicroPython library for SSD1327 128x128 4-bit greyscale OLED displays](https://github.com/mcauser/micropython-ssd1327).
MicroPython driver for the **SSD1327 128x128 4-bit greyscale OLED display controller**.

The examples could be easily tested with [mpremote](https://docs.micropython.org/en/latest/reference/mpremote.html) with the following command :
This library is a port of the original MicroPython SSD1327 driver.

```sh
mpremote mount . run examples/hello_world.py
## Features

* 128x128 **OLED display support**
* **4-bit greyscale** (16 levels)
* I²C and SPI interfaces
* Full **frame buffer integration**
* Drawing primitives:
* pixels, lines, text
* scrolling
* Display control:
* contrast
* invert
* rotation
* Power management:
* display on/off
* Optimized buffer rendering
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feature bullet "Optimized buffer rendering" looks inaccurate for this driver: show() always writes the full framebuffer (self.write_data(self.buffer)), with no partial/dirty-rectangle updates. Consider rewording this bullet to avoid implying incremental rendering, or document what is actually optimized here (if anything).

Suggested change
* Optimized buffer rendering
* Framebuffer-based rendering API

Copilot uses AI. Check for mistakes.

## Display Specifications

| Feature | Value |
| ----------- | ----------------- |
| Resolution | 128 × 128 pixels |
| Color depth | 4-bit (16 levels) |
| Controller | SSD1327 |
| Interfaces | I²C, SPI |

## I2C Address

Default I²C address:

```
0x3C
```

## Basic Usage

```python
from machine import I2C
from ssd1327 import WS_OLED_128X128_I2C

# Init I2C
i2c = I2C(1)

# Init display
display = WS_OLED_128X128_I2C(i2c)

# Draw
display.fill(0)
display.text("Hello STeaMi", 0, 0)

# Update screen
display.show()
```

## FrameBuffer Integration

The driver internally uses `framebuf.FrameBuffer`, meaning **all standard drawing methods are available**.

This allows you to use:

* `fill()`
* `pixel()`
* `line()`
* `rect()`
* `text()`
* `scroll()`
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FrameBuffer integration section claims "all standard drawing methods are available" and lists rect(), but the driver only exposes a small wrapper set (fill, pixel, line, scroll, text). Other FrameBuffer methods (e.g., rect, fill_rect) are only available via display.framebuf.* in the current implementation. Please update the documentation to match the actual API (or add forwarding methods).

Copilot uses AI. Check for mistakes.

Example:

```python
display.line(0, 0, 127, 127, 15)
display.pixel(10, 10, 8)
display.show() # Required to update the screen
```

The buffer is stored in **4-bit greyscale format (GS4_HMSB)**.

## API Reference

### Initialization

#### I2C

```python
SSD1327_I2C(width, height, i2c, address=0x3C)
WS_OLED_128X128_I2C(i2c, address=0x3C)
```

#### SPI

```python
SSD1327_SPI(width, height, spi, dc, res, cs)
WS_OLED_128X128_SPI(spi, dc, res, cs)
```
Comment on lines +69 to +73
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README documents SSD1327_SPI(...), but SSD1327_SPI is not exported by ssd1327/__init__.py (only WS_OLED_128X128_SPI is). As written, from ssd1327 import SSD1327_SPI / ssd1327.SSD1327_SPI won’t work. Either export SSD1327_SPI as part of the public API or adjust the docs to reference the correct import path / supported public classes.

Copilot uses AI. Check for mistakes.

### Drawing Methods (FrameBuffer)

* `fill(color)`
* `pixel(x, y, color)`
* `line(x1, y1, x2, y2, color)`
* `text(string, x, y, color=15)`
* `scroll(dx, dy)`

### Display Control

* `show()` — update display with buffer
* `contrast(value)` — set brightness (0–255)
* `invert(enable)` — enable/disable inversion
* `rotate(enable)` — rotate display

### Power Management

* `power_on()` — turn display on
* `power_off()` — turn display off (low power mode)

### Low-Level

* `write_cmd(cmd)`
* `write_data(buf)`

(Implemented internally for I²C/SPI communication)

## Examples

This driver includes many examples available in the `examples/` folder:

| File | Description |
| -------------- | ------------------ |
| bitmap.py | Image display |
| framebuf_lines.py | Draw a line |
| framebuf_pixel.py | Draw a pixel |
| framebuf_rect.py | Draw a rectangle |
| framebuf_scroll.py | Scroll a text |
| framebuf_text.py | Display a text |
| hello_world.py | Display "Hello World" |
| illusion.py | Display an optic illusion |
| invert.py | invert greyscale lookup table |
| lookup_table.py | Display gradiant |
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the examples table description: "gradiant" should be "gradient".

Suggested change
| lookup_table.py | Display gradiant |
| lookup_table.py | Display gradient |

Copilot uses AI. Check for mistakes.
| micropython_logo.py | Display micropython logo |
| random_pixel.py | Display random pixels |
| rotating_3D_cube.py | Display a rotating 3D cube |
| rotation.py | Rotate the 3D logo |
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several example filenames in the table don't match the actual files in lib/ssd1327/examples/ (e.g., framebuf_pixels.py, framebuf_rects.py, random_pixels.py, rotating_3d_cube.py). Please update the table so each row links to/mentions the correct filename, otherwise users will get "file not found" when trying to run them.

Copilot uses AI. Check for mistakes.
| shades.py | Display 15 shades of grey |

```bash
mpremote mount lib/ssd1327 run lib/ssd1327/examples/hello_world.py
```

## Notes

* The driver uses an internal buffer of:

```
width × height / 2 bytes
```

(4-bit per pixel)

* Display updates only occur when calling:

```python
display.show() # Required to update the screen
```

## Source

This library is a port of:
https://github.com/mcauser/micropython-ssd1327
Loading