rcute_cozmars.buzzer

class rcute_cozmars.buzzer.Buzzer(robot)

Buzzer is only for Cozmars v1

The buzzer vibrates at different frequencies to emit different tones.

注解

A tone is represented by different data types in program.

For example, the A4 key has a frequency of 440 Hz, and its MIDI code is 69, so, ‘A4’, 440.0 and 69 can all be used To represent this tone.

Use None or 0 to indicate mute

closed

Is the data stream closed

play(song, tempo=120, duty_cycle=0.9)

Play a sequence of tones

参数:
  • song (collections.Iterable) – tones to be played
  • tempo (int) – playback speed, BPM, default is 120 beats/minute
  • duty_cycle (float) – ratio of the tone duration to the entire beat, 0~1, the default is 0.9

注解

This API may change in the future when we come up with a more convenient API to play music

quiet()

Mute/Stop

set_tone(tone, duration=None)
参数:
  • tone (str / int / float) – tone
  • duration (float) – duration (seconds), default is None, which means non-stop, until quiet() is called
tone

The current tone the buzzer is playing