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: object

Small 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 pin is invalid or value is 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 d0 in [0.0, 1.0].

property d1

Current duty cycle for d1 in [0.0, 1.0].

property d2

Current duty cycle for d2 in [0.0, 1.0].