s6.utils.sync_controllerΒΆ
Client for an ESP32 PWM sync controller.
Provides SyncControllerClient to query and set duty cycles for three
outputs (d0, d1, d2) over a simple HTTP API exposed by an ESP32.
EndpointsΒΆ
GET /statusβ{"d0": float, "d1": float, "d2": float}GET /set?d0=...&d1=...&d2=...β updates duties and returns status
The client caches the last fetched status and refreshes on demand.
- class s6.utils.sync_controller.SyncControllerClient(base_url, timeout=5)
Bases:
objectSmall HTTP client for the ESP32 Sync Controller.
- Parameters:
base_url (str) β Base URL of the device, e.g.,
http://192.168.0.50.timeout (float, default 5) β Perβrequest timeout in seconds.
- property status
Return cached status, fetching from the device if needed.
- Returns:
Mapping with keys
"d0","d1","d2"and float values in[0.0, 1.0].- Return type:
dict
- refresh()
Force a status refresh from the device.
- Raises:
requests.RequestException β If the HTTP request fails.
- set_duty(pin, value)
Set a single duty cycle while preserving the others.
- Parameters:
pin ({'d0', 'd1', 'd2'}) β Which output to update.
value (float) β Duty cycle in
[0.0, 1.0].
- Returns:
JSON response returned by the device after updating.
- Return type:
dict
- Raises:
ValueError β If
pinis invalid orvalueis out of range.requests.RequestException β If the HTTP call fails or returns a nonβ2xx status.
- set_d0(value)
Shortcut for
set_duty('d0', value).
- set_d1(value)
Shortcut for
set_duty('d1', value).
- set_d2(value)
Shortcut for
set_duty('d2', value).
- property d0
Current duty cycle for
d0in[0.0, 1.0].
- property d1
Current duty cycle for
d1in[0.0, 1.0].
- property d2
Current duty cycle for
d2in[0.0, 1.0].