effectors — API Reference¶
Effector plugin packages. The base class and registry live in core.effector_base;
the types below are the concrete plugins in effectors/.
effector_base (core)¶
core.effector_base.EffectorBase(effector_id, config)
¶
Bases: ABC
Base for output devices. Subclasses set effector_type/lanes and
implement the lane handler(s) their type uses.
Source code in core/effector_base.py
attach_devices(devices)
¶
Bind the backend device (if this effector drives one).
Source code in core/effector_base.py
descriptor()
¶
Type + channels + lanes + value domain — lets a UI render the right control.
Source code in core/effector_base.py
core.effector_base.create_effector(config)
¶
pwm¶
effectors.pwm.effector.PwmEffector(effector_id, config)
¶
Bases: EffectorBase
Generic PWM outputs (LED brightness, unidirectional motor speed, fans).
Request body: {"levels": {channel: 0.0-1.0}} (or {channel: level}); levels are
normalized and scaled to the device's 0-255 command. channel may be a name
or an index. params.min_duty (0..1) maps a non-zero level into [min_duty, 1]
so loads with a minimum start point (e.g. small fans) actually move; level 0
is always fully off.
Source code in core/effector_base.py
fan_array¶
effectors.fan_array.effector.FanArray(effector_id, config)
¶
Bases: PwmEffector
One or more named fans driven over the request lane.
Built on the generic pwm drive (level 0–1 → device set_duty), adding what's
fan-specific:
- per-fan
min_duty— fans differ in where they actually start;params.per_fan: {<name>: <min_duty>}overrides the effector-wideparams.min_dutyfor that fan.
RPM stays out here: a paired fan_tach sensor publishes RPM to the relay, and
closing the loop (target RPM → trim level) is a policy, not the effector.
Source code in core/effector_base.py
servo¶
effectors.servo.effector.ServoEffector(effector_id, config)
¶
Bases: EffectorBase
Hobby servos — position by angle (or raw µs), over two backends.
Request body, one or both of:
{"angles": {channel: degrees}} — mapped through the channel's
deg↔µs calibration, soft-limited
{"us": {channel: microseconds}} — raw, clamped to [min_us, max_us]
channel may be a name or an index.
Backend (config.backend):
{kind: mcu, device:
Params (global, each overridable per channel via params.per_channel.
The angle→µs map and limits live HERE, in config — the firmware only moves microseconds (and applies its own absolute safety clamp).
Source code in effectors/servo/effector.py
effectors.servo.effector.SysfsPwm(chip, freq_hz, root='/sys/class/pwm')
¶
Minimal Linux hardware-PWM driver (/sys/class/pwm) for the sbc_pwm backend.
One instance per pwmchip; lines are lazily exported. Pulse widths are
written as duty_cycle in ns against a fixed period (the servo frame rate).
root is injectable for tests.
Source code in effectors/servo/effector.py
power_rail¶
effectors.power_rail.effector.PowerRail(effector_id, config)
¶
Bases: EffectorBase
One switchable power rail (relay / high-side switch) — gating, not failure.
Request body (request lane):
{"on": true|false} — direct switch
{"levels": {
Backend (config.backend):
{kind: gpio, line: {backend: libgpiod, chip, line, active_low}}
— SBC kernel GPIO driving the relay IN pin. Most SRD-05VDC
modules energize on LOW: put active_low in the line spec.
{kind: mcu, device:
Config keys (params): initial: "on"|"off" (default "on") — state applied at startup members: [device ids] — devices powered THROUGH this rail. While the rail is off those devices are gated: GET /devices reports them gated (not failed), so a deliberate power cut never reads as a fault. The mcu_serial reconnect loop picks them back up when the rail returns.
Rail state is published to the thalamic relay as power.<id> (1/0) so
policies and other cortices can observe gating like any other signal.
Source code in effectors/power_rail/effector.py
attach_relay(relay)
¶
speaker¶
effectors.speaker.effector.Speaker(effector_id, config)
¶
Bases: EffectorBase
Audio playback through ALSA (MAX98357A on the shared-clock I2S DOUT).
Two lanes
- stream —
WS /effectors/<id>/stream: raw interleaved S16_LE audio fed straight to anaplayraw pipe (spawned lazily on first chunk, respawned on a broken pipe). The same formatsensors/audio_incaptures, so loopback tests are byte-symmetric. - request —
{"on": true|false}: the amp's SD pin via acore/gpio.pyoutput line (params.sd_line). Gating the amp is a GPIO, not a relay — it costs nothing and kills idle hiss.
Config keys (params): alsa_device ("hw:0,0"), sample_rate (48000), channels (2), sd_line ({backend: libgpiod, …} | absent = always enabled).
Volume/limiting note: the 1 W ADA1313 driver hangs off a ~1.8 W-capable amp — the gain strap is the hardware ceiling; software keeps meaning (what to say) and the amp keeps physics (how loud it can be).
Source code in effectors/speaker/effector.py
stream_sink¶
effectors.stream_sink.effector.StreamSink(effector_id, config)
¶
Bases: EffectorBase
Reference stream-lane effector (no hardware) — records what it receives.
Proves the continuous-flow lane end to end (WS /effectors/{id}/stream → feed) and is the template a real speaker / addressable-LED-strip effector follows.