- pyproject.toml with FastAPI, uvicorn, Pydantic v2, aiofiles, structlog deps - DeviceConfig Pydantic model with StripType, UUID, validation constraints - ShowModel with AudioRef, TrackModel, CueModel, AnalysisBlock, schema_version=1 - BaseDevice ABC with encode_frame, encode_animation_cmd, bytes_per_pixel - SK6812Device (4 bytes/pixel) and WS2801Device (3 bytes/pixel) implementations
18 lines
427 B
Python
18 lines
427 B
Python
from uuid import UUID, uuid4
|
|
from typing import Literal
|
|
from pydantic import BaseModel, Field
|
|
|
|
StripType = Literal["sk6812", "ws2801", "generic"]
|
|
|
|
|
|
class DeviceConfig(BaseModel):
|
|
id: UUID = Field(default_factory=uuid4)
|
|
name: str
|
|
strip_type: StripType
|
|
led_count: int = Field(gt=0, le=1000)
|
|
ip: str
|
|
port: int = Field(ge=1, le=65535)
|
|
enabled: bool = True
|
|
|
|
model_config = {"populate_by_name": True}
|