|
| 1 | +# STeaMi Screen MicroPython Driver |
| 2 | + |
| 3 | +High-level UI and drawing library for STeaMi displays. |
| 4 | + |
| 5 | +This driver provides a **device-agnostic abstraction layer** on top of display drivers |
| 6 | +(SSD1327, GC9A01, etc.) and exposes a **simple API to draw UI elements** such as: |
| 7 | + |
| 8 | +- text layouts |
| 9 | +- widgets (bars, gauges, graphs) |
| 10 | +- menus |
| 11 | +- icons and faces |
| 12 | + |
| 13 | +It is designed to make building **embedded UIs fast and consistent**. |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## Features |
| 18 | + |
| 19 | +* Display abstraction (works with multiple backends) |
| 20 | +* Automatic layout helpers (center, north, etc.) |
| 21 | +* Text rendering with alignment and scaling |
| 22 | +* Basic drawing primitives (pixel, line, rect, circle) |
| 23 | +* UI components: |
| 24 | + * title / subtitle / value blocks |
| 25 | + * progress bar |
| 26 | + * menu rendering |
| 27 | + * graph plotting |
| 28 | + * gauge display |
| 29 | + * compass |
| 30 | + * watch (clock UI) |
| 31 | + * face / icon rendering |
| 32 | +* Backend delegation (compatible with FrameBuffer-based drivers) |
| 33 | +* Mock-testable architecture (no hardware required) |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## Supported Backends |
| 38 | + |
| 39 | +The driver works with any display exposing a FrameBuffer-like API: |
| 40 | + |
| 41 | +- `fill()` |
| 42 | +- `pixel()` |
| 43 | +- `line()` |
| 44 | +- `rect()` / `fill_rect()` |
| 45 | +- `text()` |
| 46 | +- `show()` |
| 47 | + |
| 48 | +Tested with: |
| 49 | + |
| 50 | +- SSD1327 (OLED 128x128) :contentReference[oaicite:0]{index=0} |
| 51 | +- GC9A01 (round TFT) |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +## Basic Usage |
| 56 | + |
| 57 | +```python |
| 58 | +from machine import I2C |
| 59 | +from ssd1327 import WS_OLED_128X128_I2C |
| 60 | +from steami_screen import Screen |
| 61 | + |
| 62 | +i2c = I2C(1) |
| 63 | +display = WS_OLED_128X128_I2C(i2c) |
| 64 | + |
| 65 | +screen = Screen(display) |
| 66 | + |
| 67 | +screen.clear() |
| 68 | +screen.title("STeaMi") |
| 69 | +screen.value(42, label="Temp", unit="C") |
| 70 | +screen.show() |
| 71 | +``` |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## API Reference |
| 76 | + |
| 77 | +## Initialization |
| 78 | + |
| 79 | +```python |
| 80 | +screen = Screen(display) |
| 81 | +``` |
| 82 | + |
| 83 | +* `display`: backend display driver (SSD1327, GC9A01, etc.) |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## Core Methods |
| 88 | + |
| 89 | +### Clear screen |
| 90 | + |
| 91 | +```python |
| 92 | +screen.clear() |
| 93 | +``` |
| 94 | + |
| 95 | +Fill the screen with background color. |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +### Update display |
| 100 | + |
| 101 | +```python |
| 102 | +screen.show() |
| 103 | +``` |
| 104 | + |
| 105 | +Push buffer to display. |
| 106 | + |
| 107 | +--- |
| 108 | + |
| 109 | +## Drawing Primitives |
| 110 | + |
| 111 | +### Pixel |
| 112 | + |
| 113 | +```python |
| 114 | +screen.pixel(x, y, color) |
| 115 | +``` |
| 116 | + |
| 117 | +--- |
| 118 | + |
| 119 | +### Line |
| 120 | + |
| 121 | +```python |
| 122 | +screen.line(x1, y1, x2, y2, color) |
| 123 | +``` |
| 124 | + |
| 125 | +--- |
| 126 | + |
| 127 | +### Rectangle |
| 128 | + |
| 129 | +```python |
| 130 | +screen.rect(x, y, w, h, color) |
| 131 | +screen.rect(x, y, w, h, color, fill=True) |
| 132 | +``` |
| 133 | + |
| 134 | +--- |
| 135 | + |
| 136 | +### Circle |
| 137 | + |
| 138 | +```python |
| 139 | +screen.circle(x, y, r, color) |
| 140 | +screen.circle(x, y, r, color, fill=True) |
| 141 | +``` |
| 142 | + |
| 143 | +--- |
| 144 | + |
| 145 | +## Text Rendering |
| 146 | + |
| 147 | +### Basic text |
| 148 | + |
| 149 | +```python |
| 150 | +screen.text("Hello", x, y) |
| 151 | +``` |
| 152 | + |
| 153 | +--- |
| 154 | + |
| 155 | +### Positioned text |
| 156 | + |
| 157 | +```python |
| 158 | +screen.text("Centered", position="CENTER") |
| 159 | +``` |
| 160 | + |
| 161 | +Supported positions: |
| 162 | + |
| 163 | +* `"CENTER"` |
| 164 | +* `"NORTH"` |
| 165 | +* `"SOUTH"` |
| 166 | +* `"EAST"` |
| 167 | +* `"WEST"` |
| 168 | + |
| 169 | +Invalid values fallback to center. |
| 170 | + |
| 171 | +--- |
| 172 | + |
| 173 | +### Scaled text |
| 174 | + |
| 175 | +```python |
| 176 | +screen.text("Big", x, y, scale=2) |
| 177 | +``` |
| 178 | + |
| 179 | +--- |
| 180 | + |
| 181 | +## Layout Helpers |
| 182 | + |
| 183 | +### Title |
| 184 | + |
| 185 | +```python |
| 186 | +screen.title("Title") |
| 187 | +``` |
| 188 | + |
| 189 | +Draws text near the top (NORTH). |
| 190 | + |
| 191 | +--- |
| 192 | + |
| 193 | +### Subtitle |
| 194 | + |
| 195 | +```python |
| 196 | +screen.subtitle(["Line 1", "Line 2"]) |
| 197 | +``` |
| 198 | + |
| 199 | +Supports multiple lines. |
| 200 | + |
| 201 | +--- |
| 202 | + |
| 203 | +### Value |
| 204 | + |
| 205 | +```python |
| 206 | +screen.value(23.5, label="Temp", unit="C") |
| 207 | +``` |
| 208 | + |
| 209 | +Displays a main value with optional label and unit. |
| 210 | + |
| 211 | +--- |
| 212 | + |
| 213 | +## Widgets |
| 214 | + |
| 215 | +### Progress Bar |
| 216 | + |
| 217 | +```python |
| 218 | +screen.bar(value=75, max_value=100) |
| 219 | +``` |
| 220 | + |
| 221 | +--- |
| 222 | + |
| 223 | +### Menu |
| 224 | + |
| 225 | +```python |
| 226 | +screen.menu(["Item 1", "Item 2", "Item 3"], selected=1) |
| 227 | +``` |
| 228 | + |
| 229 | +--- |
| 230 | + |
| 231 | +### Face / Icon |
| 232 | + |
| 233 | +```python |
| 234 | +screen.face("happy") |
| 235 | +``` |
| 236 | + |
| 237 | +Supports predefined expressions or custom bitmaps. |
| 238 | + |
| 239 | +--- |
| 240 | + |
| 241 | +### Graph |
| 242 | + |
| 243 | +```python |
| 244 | +screen.graph([10, 20, 15, 30]) |
| 245 | +``` |
| 246 | + |
| 247 | +Draws a simple line graph. |
| 248 | + |
| 249 | +--- |
| 250 | + |
| 251 | +### Gauge |
| 252 | + |
| 253 | +```python |
| 254 | +screen.gauge(value=60, min_value=0, max_value=100) |
| 255 | +``` |
| 256 | + |
| 257 | +--- |
| 258 | + |
| 259 | +### Compass |
| 260 | + |
| 261 | +```python |
| 262 | +screen.compass(angle=45) |
| 263 | +``` |
| 264 | + |
| 265 | +Displays a compass with direction labels. |
| 266 | + |
| 267 | +--- |
| 268 | + |
| 269 | +### Watch (Clock) |
| 270 | + |
| 271 | +```python |
| 272 | +screen.watch(hours=10, minutes=30) |
| 273 | +``` |
| 274 | + |
| 275 | +Draws an analog-style clock. |
| 276 | + |
| 277 | +--- |
| 278 | + |
| 279 | +## Examples |
| 280 | + |
| 281 | +| Example | Description | |
| 282 | +| ------------- | -------------------------- | |
| 283 | +| `watch.py` | Analog clock display | |
| 284 | + |
| 285 | +Run with: |
| 286 | + |
| 287 | +```bash |
| 288 | +mpremote mount lib/steami_screen run lib/steami_screen/examples/watch.py |
| 289 | +``` |
| 290 | + |
| 291 | +--- |
| 292 | + |
| 293 | +## Design Notes |
| 294 | + |
| 295 | +* The driver **does not depend on a specific display** |
| 296 | +* All drawing is delegated to the backend (`display`) |
| 297 | +* Layout logic is handled in `Screen` |
| 298 | +* Optimized for **readability over raw performance** |
0 commit comments