mcp300x v0.1.0 MCP300X

Library for working with MCP300X Analog-to-Digitial Converters.

Link to this section Summary

Types

Options to use when reading a value form the ADC

Functions

Helper conversion function that will take the raw output and pass it along. Useful for default :convert_func option

Quickly read the channel_number from the ADC

Helper conversion function that will take the raw output and turn it into a percent

Helper conversion function that will take the raw output and turn it into a voltage reading

Link to this section Types

Link to this type

channel_number()
channel_number() :: non_neg_integer()

Link to this type

convert_func()
convert_func() :: (non_neg_integer() -> non_neg_integer())

Link to this type

read_opt()
read_opt() :: {:convert_func, convert_func()}

Options to use when reading a value form the ADC

  • :convert_func - A conversion function for the raw output to be passed through (default &MCP300X.id/1)

Link to this section Functions

Helper conversion function that will take the raw output and pass it along. Useful for default :convert_func option.

Link to this function

read_channel(bus_name, driver, channel_number, opts \\ [])
read_channel(binary() | String.t(), MCP300X.ADC.Driver.t(), channel_number(), [
  read_opt()
]) :: {:ok, non_neg_integer()}

Quickly read the channel_number from the ADC.

This is useful when checking the value does not take place vary often or in debugging situations.

If you are doing any serious work reading the ADC value you should use MCP300X.Server instead, as this function will always open and close the SPI device.

Options

Link to this function

to_percent(n)
to_percent(non_neg_integer()) :: float()

Helper conversion function that will take the raw output and turn it into a percent

Link to this function

to_volts(n)
to_volts(non_neg_integer()) :: float()

Helper conversion function that will take the raw output and turn it into a voltage reading