refactor(driver): harden preset parsing and refresh tooling
This commit is contained in:
28
docs/API.md
28
docs/API.md
@@ -48,17 +48,17 @@ Presets define LED patterns with their configuration. Each preset has a name and
|
||||
|
||||
- **`pattern`** (required): Pattern type. Options:
|
||||
- `"off"` - Turn off all LEDs
|
||||
- `"on"` - Solid color
|
||||
- `"on"` - Solid colour
|
||||
- `"blink"` - Blinking pattern
|
||||
- `"rainbow"` - Rainbow color cycle
|
||||
- `"rainbow"` - Rainbow colour cycle
|
||||
- `"pulse"` - Pulse/fade pattern
|
||||
- `"transition"` - Color transition
|
||||
- `"transition"` - Colour transition
|
||||
- `"chase"` - Chasing pattern
|
||||
- `"circle"` - Circle loading pattern
|
||||
|
||||
- **`colors`** (optional): Array of hex color strings (e.g., `"#FF0000"` for red). Default: `["#FFFFFF"]`
|
||||
- Colors are automatically converted from hex to RGB and reordered based on device color order setting
|
||||
- Supports multiple colors for patterns that use them
|
||||
- **`colors`** (optional): Array of hex colour strings (e.g., `"#FF0000"` for red). Default: `["#FFFFFF"]`
|
||||
- Colours are automatically converted from hex to RGB and reordered based on device colour order setting
|
||||
- Supports multiple colours for patterns that use them
|
||||
|
||||
- **`delay`** (optional): Delay in milliseconds between pattern updates. Default: `100`
|
||||
|
||||
@@ -74,7 +74,7 @@ Presets define LED patterns with their configuration. Each preset has a name and
|
||||
### Pattern-Specific Parameters
|
||||
|
||||
#### Rainbow
|
||||
- **`n1`**: Step increment (how many color wheel positions to advance per update). Default: `1`
|
||||
- **`n1`**: Step increment (how many colour wheel positions to advance per update). Default: `1`
|
||||
|
||||
#### Pulse
|
||||
- **`n1`**: Attack time in milliseconds (fade in)
|
||||
@@ -86,8 +86,8 @@ Presets define LED patterns with their configuration. Each preset has a name and
|
||||
- **`delay`**: Transition duration in milliseconds
|
||||
|
||||
#### Chase
|
||||
- **`n1`**: Number of LEDs with first color
|
||||
- **`n2`**: Number of LEDs with second color
|
||||
- **`n1`**: Number of LEDs with first colour
|
||||
- **`n2`**: Number of LEDs with second colour
|
||||
- **`n3`**: Movement amount on even steps (can be negative)
|
||||
- **`n4`**: Movement amount on odd steps (can be negative)
|
||||
|
||||
@@ -235,7 +235,7 @@ All devices will start at step 10 and advance together on subsequent beats.
|
||||
|
||||
1. **Version Check**: Messages with `v != "1"` are rejected
|
||||
2. **Preset Processing**: Presets are created or updated (upsert behavior)
|
||||
3. **Color Conversion**: Hex colors are converted to RGB tuples and reordered based on device color order
|
||||
3. **Colour Conversion**: Hex colours are converted to RGB tuples and reordered based on device colour order
|
||||
4. **Selection**: Devices select their assigned preset, optionally with step value
|
||||
|
||||
## Best Practices
|
||||
@@ -244,20 +244,20 @@ All devices will start at step 10 and advance together on subsequent beats.
|
||||
2. **Use "off" for sync**: Select "off" pattern to synchronize devices before starting patterns
|
||||
3. **Beats for manual mode**: Send select messages repeatedly with same preset name to advance manual patterns
|
||||
4. **Step for precision**: Use step parameter when exact synchronization is required
|
||||
5. **Color format**: Always use hex strings (`"#RRGGBB"`), conversion is automatic
|
||||
5. **Colour format**: Always use hex strings (`"#RRGGBB"`), conversion is automatic
|
||||
|
||||
## Error Handling
|
||||
|
||||
- Invalid version: Message is ignored
|
||||
- Missing preset: Selection fails, device keeps current preset
|
||||
- Invalid pattern: Selection fails, device keeps current preset
|
||||
- Missing colors: Pattern uses default white color
|
||||
- Missing colours: Pattern uses default white colour
|
||||
- Invalid step: Step value is used as-is (may cause unexpected behavior)
|
||||
|
||||
## Notes
|
||||
|
||||
- Colors are automatically converted from hex strings to RGB tuples
|
||||
- Color order reordering happens automatically based on device settings
|
||||
- Colours are automatically converted from hex strings to RGB tuples
|
||||
- Colour order reordering happens automatically based on device settings
|
||||
- Step counter wraps around (0-255 for rainbow, unbounded for others)
|
||||
- Manual mode patterns stop after one step/cycle, waiting for next beat
|
||||
- Auto mode patterns run continuously until changed
|
||||
|
||||
Reference in New Issue
Block a user