Interface: moteiv.tos.sensorboards.invent.Speaker

interface Speaker

Interface for sending sound through a speaker.

Author:
Joe Polastre, Moteiv Corporation <info@moteiv.com>

Commands
command result_t start(void *addr, uint16_t length, bool word, uint16_t freq, bool repeat) Start sending sound through a speaker based on data at a specified address in memory.
command result_t stop() Stop the currently playing sample.

Events
event void done(void *addr, uint16_t length, bool repeat) Notification that the sample is no longer in use.
event void repeat(void *addr, uint16_t length) Notification that a sample is repeating.
event void started(void *addr, uint16_t length, result_t result) Notification that the audio sample has started playing

Commands - Details

start

command result_t start(void *addr, uint16_t length, bool word, uint16_t freq, bool repeat)

Start sending sound through a speaker based on data at a specified address in memory.

Parameters:
addr - Memory address of first sample
length - The length of the audio sample
word - TRUE if 12-bit data, FALSE for 8-bit data
freq - Frequency that the audio sample was recorded
repeat - TRUE to repeat the sample infinitely, FALSE to play once
Returns:
SUCCESS if the playback can begin immediately

stop

command result_t stop()

Stop the currently playing sample. If no sample is playing or if the playback cannot be stopped, FAIL will be returned by stop(). If a sample is being played, after it is stopped with the stop() command, a done() event will be signalled to notify the caller that the buffer is now free and playback has halted.

Returns:
SUCCESS if playback is halted (a done() event will be signalled), FAIL if no sample is playing or if it cannot be halted.

Events - Details

done

event void done(void *addr, uint16_t length, bool repeat)

Notification that the sample is no longer in use. done() is fired after a single sample playback (start() with repeat = FALSE) or after stop() is called.

Parameters:
addr - Address of the audio sample
length - Length of the audio sample
freq - Frequency of the recorded audio sample
repeat - Notification of a repeat-play or single-play sample

repeat

event void repeat(void *addr, uint16_t length)

Notification that a sample is repeating. This event is purely informational.

started

event void started(void *addr, uint16_t length, result_t result)

Notification that the audio sample has started playing

Parameters:
addr - Address of the audio sample
length - Length of the audio sample