beep. Object
The beep. object allows you to generate "beep" patters using the beeper (buzzer) attached to the CO pin of your device. "CO" stands for "clock output" and its output can be actually used for anything, not just controlling the beeper. The frequency available on the CO pin is defined by the beep.divider property.
When the pattern starts playing, the CO line becomes an output automatically. Therefore, you do not need to use the io.enabled property to configure this line as output. When the pattern stops playing, the line will return to the input/output and HIGH/LOW state that it had before the pattern started playing.
The pattern you play can be up to 16 steps long. Each "step" can be either "-" (buzzer off) or "B" (buzzer on). You can also define whether the pattern will only execute one or loop and play indefinitely. Additionally, you can make the pattern play at "normal" or double speed.
You load the new pattern to play with the beep.play method. If the pattern is looped, it will continue playing until you change it. If the pattern is not looped, it will play once and then the on_beep event will be generated.
Buzzer patterns offer a convenient way to tell the user what your system is doing. You can devise different patterns for different states of your device. You can use these patterns together with LED patterns generated by the pat. object.
Here is a simple example in which we generate three beeps on the power-up of the device.
sub on_sys_init
beep.play("B-B-B",PL_PAT_CANINT)
end sub
To obtain a permanent, non-stop square wave on the CO pin, load the following pattern:
beep.play("B~",PL_PAT_CANINT)