wafer v0.1.0 Wafer.InterruptRegistry
This module provides Wafer's interrupt registry. This allows multiple subscribers to be subscribed to interrupts from many different pins.
It is used by Driver.Circuits.GPIO.Dispatcher and
Driver.ElixirALE.GPIO.Dispatcher and you should probably use it if you're
writing your own driver which supports sending interrupts to subscribers.
Link to this section Summary
Functions
Count the number of active subscriptions for key.
Count the number of active subscriptions for key and pin_condition.
Publish an interrupt to subscribers that are interested in key and
pin_condition.
Subscribe the calling process to interrupts for the specified pin_condition
using the provided key.
Subscribe the calling process to interrupts for the specified pin_condition
using the provided key.
Are there any subscribers to key?
Are there any subscribers to key and pin_condition?
Returns a list of all subscriptions to key.
Returns a list of all subscriptions key and pin_condition.
Remove all subscriptions for key, pin_condition and conn.
Link to this section Types
Link to this section Functions
Count the number of active subscriptions for key.
count_subscriptions(key, pin_condition)
count_subscriptions(key(), Wafer.GPIO.pin_condition()) :: non_neg_integer()
Count the number of active subscriptions for key and pin_condition.
publish(key, pin_condition)
publish(key(), :rising | :falling) :: {:ok, non_neg_integer()}
Publish an interrupt to subscribers that are interested in key and
pin_condition.
Searches the registry for all subscribers to are subscribed to pin_condition
or :both and publishes the interrupt message to them. The interrupt message
takes the form {:interrupt, Conn.t(), :rising | :falling, metadata :: any}.
subscribe(key, pin_condition, conn)
subscribe(key(), Wafer.GPIO.pin_condition(), Wafer.Conn.t()) :: :ok
Subscribe the calling process to interrupts for the specified pin_condition
using the provided key.
See subscribe/4 for more information.
Example
iex> subscribe({MCP230017.Pin, 13}, :rising, conn)
:ok
subscribe(key, pin_condition, conn, metadata)
subscribe(key(), Wafer.GPIO.pin_condition(), Wafer.Conn.t(), any()) :: :ok
Subscribe the calling process to interrupts for the specified pin_condition
using the provided key.
Arguments
keya key which uniquely describes the pin. Probably a combination of device name and pin.pin_conditioneither:rising,:fallingor:both.connthe receiver's connection to the pin, sent back to them in the interrupt message.metadataarbitrary data which will be sent to the receiver process in the interrupt message. Defaults tonil.
Are there any subscribers to key?
subscribers?(key, pin_condition)
subscribers?(key(), Wafer.GPIO.pin_condition()) :: boolean()
Are there any subscribers to key and pin_condition?
subscriptions(key)
subscriptions(key()) :: [ {Wafer.GPIO.pin_condition(), Wafer.Conn.t(), metadata :: any(), receiver :: pid()} ]
Returns a list of all subscriptions to key.
subscriptions(key, pin_condition)
subscriptions(key(), Wafer.GPIO.pin_condition()) :: [ {Wafer.GPIO.pin_condition(), Wafer.Conn.t(), metadata :: any(), receiver :: pid()} ]
Returns a list of all subscriptions key and pin_condition.
unsubscribe(key, pin_condition, conn)
unsubscribe(key(), Wafer.GPIO.pin_condition(), Wafer.Conn.t()) :: :ok
Remove all subscriptions for key, pin_condition and conn.