Skip to content

Commit 52f0e9a

Browse files
committed
docs(steami_screen): Add README with API reference.
1 parent ff9be7c commit 52f0e9a

1 file changed

Lines changed: 218 additions & 0 deletions

File tree

lib/steami_screen/README.md

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
# STeaMi Screen
2+
3+
High-level UI library for STeaMi displays.
4+
5+
Provides a device-agnostic abstraction layer on top of display drivers (SSD1327, GC9A01) with a simple API to draw UI elements: text layouts, widgets, menus, icons.
6+
7+
---
8+
9+
## Features
10+
11+
* Display abstraction (works with any FrameBuffer-based backend)
12+
* Automatic layout for round screens (cardinal positioning, safe margins)
13+
* Text rendering with alignment and scaling
14+
* Drawing primitives (pixel, line, rect, circle)
15+
* 10 widgets: title, subtitle, value, bar, gauge, graph, menu, compass, watch, face
16+
17+
---
18+
19+
## Basic Usage
20+
21+
```python
22+
import ssd1327
23+
from machine import SPI, Pin
24+
from steami_screen import Screen
25+
26+
spi = SPI(1)
27+
dc = Pin("DATA_COMMAND_DISPLAY")
28+
res = Pin("RST_DISPLAY")
29+
cs = Pin("CS_DISPLAY")
30+
31+
display = ssd1327.WS_OLED_128X128_SPI(spi, dc, res, cs)
32+
screen = Screen(display)
33+
34+
screen.clear()
35+
screen.title("STeaMi")
36+
screen.value(42, label="Temp", unit="C")
37+
screen.show()
38+
```
39+
40+
---
41+
42+
## API Reference
43+
44+
### Initialization
45+
46+
```python
47+
screen = Screen(display)
48+
```
49+
50+
`display` must expose `fill()`, `pixel()`, `line()`, `rect()`, `fill_rect()`, `text()`, `show()`. Width and height are auto-detected from the display backend.
51+
52+
---
53+
54+
### Drawing Primitives
55+
56+
```python
57+
screen.pixel(x, y, color)
58+
screen.line(x1, y1, x2, y2, color)
59+
screen.rect(x, y, w, h, color, fill=False)
60+
screen.circle(x, y, r, color, fill=False)
61+
```
62+
63+
---
64+
65+
### Text
66+
67+
```python
68+
screen.text("Hello", at="CENTER")
69+
screen.text("Top", at="N")
70+
screen.text("Custom", at=(10, 20))
71+
screen.text("Big", at="CENTER", scale=2)
72+
```
73+
74+
Cardinal positions: `"N"`, `"NE"`, `"E"`, `"SE"`, `"S"`, `"SW"`, `"W"`, `"NW"`, `"CENTER"`.
75+
76+
---
77+
78+
### Widgets
79+
80+
#### Title
81+
82+
```python
83+
screen.title("STeaMi")
84+
```
85+
86+
Draws text centered at the top (N position).
87+
88+
---
89+
90+
#### Subtitle
91+
92+
```python
93+
screen.subtitle("Line 1", "Line 2")
94+
```
95+
96+
Draws text centered at the bottom (S position). Accepts multiple lines.
97+
98+
---
99+
100+
#### Value
101+
102+
```python
103+
screen.value(23.5, label="Temp", unit="C")
104+
```
105+
106+
Displays a large centered value with optional label above and unit below.
107+
108+
---
109+
110+
#### Progress Bar
111+
112+
```python
113+
screen.bar(value=75, max_value=100)
114+
```
115+
116+
---
117+
118+
#### Gauge
119+
120+
```python
121+
screen.gauge(value=60, min_value=0, max_value=100, unit="C")
122+
```
123+
124+
Draws a 270-degree arc gauge near the screen border.
125+
126+
---
127+
128+
#### Graph
129+
130+
```python
131+
screen.graph([10, 20, 15, 30], min_val=0, max_val=100)
132+
```
133+
134+
Draws a scrolling line graph with the last value displayed above.
135+
136+
---
137+
138+
#### Menu
139+
140+
```python
141+
screen.menu(["Item 1", "Item 2", "Item 3"], selected=1)
142+
```
143+
144+
---
145+
146+
#### Compass
147+
148+
```python
149+
screen.compass(heading=45)
150+
```
151+
152+
Draws a compass with cardinal labels and a rotating needle.
153+
154+
---
155+
156+
#### Watch
157+
158+
```python
159+
screen.watch(hours=10, minutes=30, seconds=15)
160+
```
161+
162+
Draws an analog clock face.
163+
164+
---
165+
166+
#### Face
167+
168+
```python
169+
screen.face("happy")
170+
```
171+
172+
Draws a pixel-art expression. Available: `"happy"`, `"sad"`, `"surprised"`, `"sleeping"`, `"angry"`, `"love"`.
173+
174+
---
175+
176+
### Control
177+
178+
```python
179+
screen.clear()
180+
screen.show()
181+
```
182+
183+
---
184+
185+
### Properties
186+
187+
```python
188+
screen.center # (64, 64) for 128x128
189+
screen.radius # 64 for 128x128
190+
screen.max_chars # 16 for 128px width
191+
```
192+
193+
---
194+
195+
## Color Constants
196+
197+
```python
198+
from steami_screen import BLACK, DARK, GRAY, LIGHT, WHITE
199+
from steami_screen import RED, GREEN, BLUE, YELLOW
200+
```
201+
202+
Colors are RGB tuples. On SSD1327 they degrade to greyscale automatically.
203+
204+
---
205+
206+
## Color Utilities
207+
208+
```python
209+
from steami_screen import rgb_to_gray4, rgb_to_rgb565, rgb_to_rgb8
210+
```
211+
212+
| Function | Output |
213+
|----------|--------|
214+
| `rgb_to_gray4(color)` | 4-bit greyscale (0-15) for SSD1327 |
215+
| `rgb_to_rgb565(color)` | 16-bit RGB565 for GC9A01 |
216+
| `rgb_to_rgb8(color)` | RGB tuple pass-through |
217+
218+
All accept int values for backward compatibility.

0 commit comments

Comments
 (0)