bricknil.sensor.sound

All sound related output devices

Classes

DuploSpeaker(name[, port, capabilities]) Plays one of five preset sounds through the Duplo built-in speaker

Members

class bricknil.sensor.sound.DuploSpeaker(name, port=None, capabilities=[])[source]

Bases: bricknil.sensor.peripheral.Peripheral

Plays one of five preset sounds through the Duplo built-in speaker

See sounds for the list.

Examples:

@attach(DuploSpeaker, name='speaker')
...
await self.speaker.play_sound(DuploSpeaker.sounds.brake)

Notes

Uses Mode 1 to play the presets

class sounds

Bases: enum.Enum

An enumeration.

brake = 3
horn = 9
station = 5
steam = 10
water = 7
activate_updates()[source]

For some reason, even though the speaker is an output device we need to send a Port Input Format Setup command (0x41) to enable notifications. Otherwise, none of the sound output commands will play. This function is called automatically after this sensor is attached.

play_sound(sound)[source]