Skip to content
Merged
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
3 changes: 3 additions & 0 deletions lib/ssd1327/ssd1327/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ def scroll(self, dx, dy):
def text(self, string, x, y, col=15):
self.framebuf.text(string, x, y, col)

def fill_rect(self, x, y, w, h, col):
self.framebuf.fill_rect(x, y, w, h, col)

def write_cmd(self):
raise NotImplementedError

Expand Down
7 changes: 4 additions & 3 deletions lib/steami_screen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ Provides a device-agnostic abstraction layer on top of display drivers (SSD1327,
```python
import ssd1327
from machine import SPI, Pin
from steami_screen import Screen
from steami_screen import Screen, SSD1327Display

spi = SPI(1)
dc = Pin("DATA_COMMAND_DISPLAY")
res = Pin("RST_DISPLAY")
cs = Pin("CS_DISPLAY")

display = ssd1327.WS_OLED_128X128_SPI(spi, dc, res, cs)
raw = ssd1327.WS_OLED_128X128_SPI(spi, dc, res, cs)
display = SSD1327Display(raw)
screen = Screen(display)

screen.clear()
Expand Down Expand Up @@ -120,7 +121,7 @@ screen.bar(75, max_val=100)
#### Gauge

```python
screen.gauge(60, min_val=0, max_val=100, unit="C")
screen.gauge(60, min_val=0, max_val=100)
```

Draws a 270-degree arc gauge near the screen border.
Expand Down
38 changes: 38 additions & 0 deletions lib/steami_screen/examples/comfort_bar_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
Shows temperature with a bar graph indicating how close it is to 40°C.
"""

from time import sleep_ms

import ssd1327
from hts221 import HTS221
from machine import I2C, SPI, Pin
from steami_screen import GREEN, Screen, SSD1327Display

# --- Screen setup ---
spi = SPI(1)
dc = Pin("DATA_COMMAND_DISPLAY")
res = Pin("RST_DISPLAY")
cs = Pin("CS_DISPLAY")

raw_display = ssd1327.WS_OLED_128X128_SPI(spi, dc, res, cs)
display = SSD1327Display(raw_display)
screen = Screen(display)

# --- Sensor setup ---
i2c = I2C(1)
sensor = HTS221(i2c)

# --- Main loop ---
while True:
temp = round(sensor.temperature(), 1)

screen.clear()
screen.title("Temp")

screen.value(temp, unit="C", label="TEMP")
screen.bar(temp, max_val=40, color=GREEN)

screen.show()

sleep_ms(100)
42 changes: 42 additions & 0 deletions lib/steami_screen/examples/compass_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""
Displays a compass with a rotating needle based on the LIS2MDL magnetometer.
"""

from time import sleep_ms

import ssd1327
from lis2mdl import LIS2MDL
from machine import I2C, SPI, Pin
from steami_screen import Screen, SSD1327Display

# --- Screen setup ---
spi = SPI(1)
dc = Pin("DATA_COMMAND_DISPLAY")
res = Pin("RST_DISPLAY")
cs = Pin("CS_DISPLAY")

raw_display = ssd1327.WS_OLED_128X128_SPI(spi, dc, res, cs)
display = SSD1327Display(raw_display)
screen = Screen(display)

# --- Sensor setup ---
i2c = I2C(1)
sensor = LIS2MDL(i2c)

print("Calibrate the magnetometer by moving it flat.")
sensor.calibrate_minmax_2d()
print("Calibration complete.")

heading = 0

# --- Main loop ---
while True:
angle = sensor.heading_flat_only()

screen.clear()
screen.compass(angle)
screen.show()

print("Cap:", angle, "°")

sleep_ms(50)
58 changes: 58 additions & 0 deletions lib/steami_screen/examples/ddap_menu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""
Displays a scrollable menu navigated with the D-pad buttons.
"""

from time import sleep_ms

import ssd1327
from machine import I2C, SPI, Pin
from mcp23009e import MCP23009E
from mcp23009e.const import (
MCP23009_BTN_DOWN,
MCP23009_BTN_UP,
MCP23009_DIR_INPUT,
MCP23009_I2C_ADDR,
MCP23009_LOGIC_LOW,
MCP23009_PULLUP,
)
from steami_screen import Screen, SSD1327Display

# --- Screen setup ---
spi = SPI(1)
dc = Pin("DATA_COMMAND_DISPLAY")
res = Pin("RST_DISPLAY")
cs = Pin("CS_DISPLAY")

raw_display = ssd1327.WS_OLED_128X128_SPI(spi, dc, res, cs)
display = SSD1327Display(raw_display)
screen = Screen(display)

# --- D-pad setup ---
i2c = I2C(1)

reset = Pin("RST_EXPANDER", Pin.OUT)
mcp = MCP23009E(i2c, address=MCP23009_I2C_ADDR, reset_pin=reset)

mcp.setup(MCP23009_BTN_UP, MCP23009_DIR_INPUT, pullup=MCP23009_PULLUP)
mcp.setup(MCP23009_BTN_DOWN, MCP23009_DIR_INPUT, pullup=MCP23009_PULLUP)

# --- Menu items ---
items = ["Temperature", "Humidity", "Distance", "Light", "Battery", "Proximity"]
selected = 0

# --- Main loop ---
while True:
if mcp.get_level(MCP23009_BTN_UP) == MCP23009_LOGIC_LOW:
selected = (selected - 1) % len(items)
sleep_ms(200)

if mcp.get_level(MCP23009_BTN_DOWN) == MCP23009_LOGIC_LOW:
selected = (selected + 1) % len(items)
sleep_ms(200)

screen.clear()
screen.title("Menu")
screen.menu(items, selected=selected)
screen.show()

sleep_ms(50)
39 changes: 39 additions & 0 deletions lib/steami_screen/examples/face_gallery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
Cycle through all 6 built-in face expressions.
"""

from time import sleep_ms

import ssd1327
from machine import SPI, Pin
from steami_screen import Screen, SSD1327Display

# --- Display setup ---
spi = SPI(1)
dc = Pin("DATA_COMMAND_DISPLAY")
res = Pin("RST_DISPLAY")
cs = Pin("CS_DISPLAY")

raw_display = ssd1327.WS_OLED_128X128_SPI(spi, dc, res, cs)
display = SSD1327Display(raw_display)
screen = Screen(display)

faces = [
("happy", "HAPPY"),
("sad", "SAD"),
("surprised", "SURPRISED"),
("sleeping", "SLEEPING"),
("angry", "ANGRY"),
("love", "LOVE"),
]

compact = True

while True:
compact = not compact
for expression, label in faces:
screen.clear()
screen.face(expression, compact=compact)
screen.show()
print("Showing face:", label, "Compact:", compact)
sleep_ms(1000)
35 changes: 35 additions & 0 deletions lib/steami_screen/examples/gauge_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Displays VL53L1X time-of-flight distance with an arc gauge.
"""

from time import sleep_ms

import ssd1327
from machine import I2C, SPI, Pin
from steami_screen import BLACK, Screen, SSD1327Display
from vl53l1x import VL53L1X

# --- Display setup ---
spi = SPI(1)
dc = Pin("DATA_COMMAND_DISPLAY")
res = Pin("RST_DISPLAY")
cs = Pin("CS_DISPLAY")

raw_display = ssd1327.WS_OLED_128X128_SPI(spi, dc, res, cs)
display = SSD1327Display(raw_display)
screen = Screen(display)

# --- Sensor setup ---
i2c = I2C(1)
sensor = VL53L1X(i2c)

# --- Main loop ---
while True:
dist = sensor.read()

screen.clear()
screen.gauge(dist, min_val=0, max_val=500, color=BLACK)
screen.value(dist, label="Distance", unit="mm")
screen.show()

sleep_ms(10)
43 changes: 43 additions & 0 deletions lib/steami_screen/examples/graph_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""
Displays APDS9960 ambient light with a scrolling line graph.
"""

from time import sleep_ms

import ssd1327
from apds9960 import uAPDS9960 as APDS9960
from machine import I2C, SPI, Pin
from steami_screen import Screen, SSD1327Display

# --- Display setup ---
spi = SPI(1)
dc = Pin("DATA_COMMAND_DISPLAY")
res = Pin("RST_DISPLAY")
cs = Pin("CS_DISPLAY")

raw_display = ssd1327.WS_OLED_128X128_SPI(spi, dc, res, cs)
display = SSD1327Display(raw_display)
screen = Screen(display)

# --- Sensor setup ---
i2c = I2C(1)
apds = APDS9960(i2c)

# --- Data buffer (scrolling window) ---
MAX_POINTS = 20
data = []

# --- Main loop ---
while True:
lux = apds.ambient_light()
data.append(lux)
if len(data) > MAX_POINTS:
data.pop(0)

screen.clear()
screen.title("Light (lux)")
screen.graph(data, min_val=0, max_val=1000)
screen.subtitle("APDS9960", "20s window")
screen.show()

sleep_ms(1000)
38 changes: 38 additions & 0 deletions lib/steami_screen/examples/hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
hello_world.py
Basic steami_screen example:
- clear screen
- title
- value
- subtitle
- show
"""

from time import sleep_ms

import ssd1327
from machine import SPI, Pin
from steami_screen import Screen, SSD1327Display

# --- Display setup ---
spi = SPI(1)
dc = Pin("DATA_COMMAND_DISPLAY")
res = Pin("RST_DISPLAY")
cs = Pin("CS_DISPLAY")

raw_display = ssd1327.WS_OLED_128X128_SPI(spi, dc, res, cs)
display = SSD1327Display(raw_display)
screen = Screen(display)

# --- Demo loop ---
counter = 0

while True:
screen.clear()
screen.title("HELLO")
screen.subtitle("screen", "Hello world")
screen.value(counter, label="Demo")
screen.show()

counter += 1
sleep_ms(1000)
Loading
Loading