Skip to content

Commit 2c49008

Browse files
authored
Refactor write guarded service (#65)
* Refactor write services into force vs guarded flows * Update __init__.py * Update manifest.json
1 parent 67b62a4 commit 2c49008

4 files changed

Lines changed: 270 additions & 182 deletions

File tree

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,68 @@ target:
191191

192192
---
193193

194+
## Service: `gicisky.write_guarded`
195+
196+
`gicisky.write_guarded` uses the same rendering pipeline as `gicisky.write`, but applies guard checks before BLE transmission:
197+
198+
- duplicate image prevention (when option `prevent_duplicate_send` is enabled)
199+
- write lock check
200+
- debounce scheduling (config `debounce_ms`, optionally overridden per call)
201+
202+
Use this service when your automation can fire frequently and you want skip/coalescing behavior.
203+
204+
### Service Parameters
205+
206+
| Parameter | Required | Default | Description |
207+
|-----------|----------|---------|-------------|
208+
| `payload` | ✅ | — | List of drawing elements (see [Payload Element Types](#payload-element-types)) |
209+
| `rotate` | ❌ | `0` | Image rotation: `0`, `90`, `180`, `270` |
210+
| `background` | ❌ | `white` | Background color: `white`, `black`, `red` |
211+
| `threshold` | ❌ | `128` | Black binary threshold (`0`–`255`) |
212+
| `red_threshold` | ❌ | `128` | Red binary threshold (`0`–`255`) |
213+
| `dry_run` | ❌ | `false` | Generate preview image without sending to device |
214+
| `debounce_override_ms` | ❌ | option `debounce_ms` | Override debounce delay for this call (`0` = immediate write) |
215+
216+
### Basic Usage
217+
218+
```yaml
219+
action: gicisky.write_guarded
220+
data:
221+
payload:
222+
- type: text
223+
value: Guarded Write
224+
x: 10
225+
y: 10
226+
size: 36
227+
target:
228+
device_id: <your device>
229+
```
230+
231+
### Immediate Guarded Write (Skip Debounce Once)
232+
233+
```yaml
234+
action: gicisky.write_guarded
235+
data:
236+
debounce_override_ms: 0
237+
payload:
238+
- type: text
239+
value: Immediate
240+
x: 10
241+
y: 10
242+
size: 36
243+
target:
244+
device_id: <your device>
245+
```
246+
247+
### Service Selection Guide
248+
249+
| Service | Behavior |
250+
|---------|----------|
251+
| `gicisky.write` | Always executes write flow (except explicit `dry_run`) |
252+
| `gicisky.write_guarded` | Applies guard checks (duplicate/lock/debounce), and may skip or coalesce writes |
253+
254+
---
255+
194256
### Payload Element Examples
195257

196258
> [!TIP]

0 commit comments

Comments
 (0)