GrovePi v0.3.2 GrovePi.Sound View Source
Listen for events from a GrovePi sound module. There are two types of
events by default; loud and quiet. When registering for an event the sound
will then send a message of {pin, :loud, _trigger_date}
or
{pin, :quiet, _trigger_data}
. The sound works by polling
GrovePi.Analog
on the pin that you have registered to a sound.
Example usage:
iex> {:ok, sound} = GrovePi.Sound.start_link(3)
:ok
iex> GrovePi.Sound.subscribe(3, :loud)
:ok
iex> GrovePi.Sound.subscribe(3, :quiet)
:ok
Link to this section Summary
Functions
Stops the current scheduled polling event and starts a new one with the new interval
Callback implementation for GrovePi.Poller.read_value/2
Options
Stops polling immediately
Link to this section Functions
Link to this function
change_polling(pin, interval, prefix \\ Default)
View Source
change_polling(GrovePi.pin, integer, atom) :: :ok
Stops the current scheduled polling event and starts a new one with the new interval.
Link to this function
read(pin, prefix \\ Default)
View Source
read(GrovePi.pin, atom) :: GrovePi.Analog.adc_level
Callback implementation for GrovePi.Poller.read_value/2
.
Options
:poll_interval
- The time in ms between polling for state.i If set to 0 polling will be turned off. Default:100
:trigger
- This is used to pass in a trigger to use for triggering events. See specific poller for defaults:trigger_opts
- This is used to pass options to a triggerinit1
. The default is[]
Link to this function
stop_polling(pin, prefix \\ Default)
View Source
stop_polling(GrovePi.pin, atom) :: :ok
Stops polling immediately
Link to this function
subscribe(pin, event, prefix \\ Default)
View Source
subscribe(GrovePi.pin, GrovePi.Trigger.event, atom) :: {:ok, pid} | {:error, {:already_registered, pid}}