GrovePi v0.6.1 GrovePi.Poller behaviour View Source

A behaviour module for implementing polling on a pin.

The GrovePi.Poller behavior abstracts polling on a pin. Developers are responsible for implementing read_value/2 and a module using the GrovePi.Trigger behaviour.


This example shows implementation of GrovePi.Potentiometer. The module should use GrovePi.Poller, specifiying the :default_trigger and :read_type. It should have a read_value/2 callback which reads the desired sensor.

defmodule GrovePi.Potentiometer do
  alias GrovePi.Analog

  use GrovePi.Poller, default_trigger: GrovePi.Potentiometer.DefaultTrigger,
    read_type: Analog.adc_level

  def read_value(prefix, pin) do, pin)

The requirements for creating the :default_trigger are described in GrovePi.Trigger.

Link to this section Summary

Link to this section Callbacks

Link to this callback read_value(atom, arg1) View Source
read_value(atom(), :: any()