Buzzer¶
raspbot.actuators.buzzer.Buzzer
Controls the on-board piezo buzzer via I2C register 0x06.
Access via Robot.buzzer.
The Buzzer is fully non-blocking. Schedule a beep or pattern with
beep() / pattern(), then call update(ct) on every main-loop iteration
to advance the internal state machine. No time.sleep() is ever called.
Methods¶
on()¶
Turn the buzzer on immediately (raw hardware command).
off()¶
Turn the buzzer off immediately (raw hardware command).
beep(duration=0.2)¶
Schedule a single non-blocking beep of duration seconds.
The buzzer turns on immediately. update() will turn it off after
duration seconds. Any previously scheduled sequence is cancelled.
| Parameter | Type | Default | Description |
|---|---|---|---|
duration |
float |
0.2 |
How long to beep, in seconds |
pattern(on_time, off_time, count)¶
Schedule a non-blocking repeated beep pattern.
The first beep starts immediately. update() drives all subsequent
on/off transitions without blocking.
| Parameter | Type | Description |
|---|---|---|
on_time |
float |
Duration of each beep (seconds) |
off_time |
float |
Silence between beeps (seconds) |
count |
int |
Number of beeps |
update(ct)¶
Advance the buzzer state machine.
Call this on every main-loop iteration with ct = time.monotonic().
It is cheap (a float comparison) when nothing is scheduled.
| Parameter | Type | Description |
|---|---|---|
ct |
float |
Current time in seconds (from time.monotonic()) |
is_active¶
True while a beep or pattern is in progress.