Archytax v0.1.1 Archytax

This is the Main Module of the Library, it serves as a bridge for the interface and the Board, also it manages the messages coming from the connected devices.

Summary

Functions

Send analog value val to the specified pin_number

Send digital MIDI signal value val to the specified pin_number. Note: If possible use set_digital_pin/2 instead

Get the current state of Archytax

Get the current pins states and values as a Map. Useful to get the current value of digital pins

Get the state of the specified pin

Not gonna make it to the final version

Try to create a new connection using the existing Board GenServer

Enable or Disable analog pin reporting according to the val provided for the specified pin

Enable or Disable digital port reporting according to the val provided for the specified pin

Send reset signal to board

Set the digital value for the specified pin_number

Set the pin mode of the specified mode, for pin modes codes, check firmata documentation: https://github.com/firmata/protocol/blob/master/protocol.md

Issue a sysex command message to the Board

Send any kind of information to the Board

Functions

analog_write(pin_number, val)

Send analog value val to the specified pin_number.

Note: pin_number must be inside the range from 0 to 15 as specified by MIDI message format.

Examples

iex> Archytax.analog_write(9, 222)
:ok

iex> Archytax.analog_write(999, 1)
{:error, "Pin not found"}
digital_write(pin_number, val)

Send digital MIDI signal value val to the specified pin_number. Note: If possible use set_digital_pin/2 instead.

Examples

iex> Archytax.digital_write(13, 1)
:ok

iex> Archytax.digital_write(999, 1)
{:error, "Pin not found"}
get_all()

Get the current state of Archytax.

get_pins()

Get the current pins states and values as a Map. Useful to get the current value of digital pins.

Examples

iex> {:ok, pins} = Archytax.get_pins
iex> digital_value = get_in(pins, [13, :value])
1
pin_state_query(pin)

Get the state of the specified pin.

NOTE: The pin state is any data written to the pin (it is important to note that pin state != pin value).

read(time \\ nil)

Not gonna make it to the final version.

reconnect(port, opts \\ [])

Try to create a new connection using the existing Board GenServer.

report_analog_pin(pin, val)

Enable or Disable analog pin reporting according to the val provided for the specified pin.

Note: pin refers to the analog pin (i.e. A0, A1, etc.) disable(0) / enable(non-zero)

Examples

iex> Archytax.report_analog_pin(5, 1)
:ok
report_digital_port(pin, val)

Enable or Disable digital port reporting according to the val provided for the specified pin.

disable(0) / enable(non-zero)

Examples

iex> Archytax.report_digital_port(5, 1)
:ok

iex> Archytax.report_digital_port(999, 1)
{:error, "Pin not found"}
reset()

Send reset signal to board.

set_digital_pin(pin_number, val)

Set the digital value for the specified pin_number.

Examples

iex> Archytax.set_digital_pin(13, 1)
:ok

iex> Archytax.set_digital_pin(13, 0)
:ok

iex> Archytax.set_digital_pin(999, 1)
{:error, "Pin not found"}
set_pin_mode(pin_number, mode)

Set the pin mode of the specified mode, for pin modes codes, check firmata documentation: https://github.com/firmata/protocol/blob/master/protocol.md

Examples

iex> Archytax.set_pin_mode(13, 1)
:ok

iex> Archytax.set_pin_mode(9, 3)
:ok

iex> Archytax.set_pin_mode(999, 1)
{:error, "Pin not found"}
start_link(device_port, opts \\ [])
sysex_write(command, data \\ "")

Issue a sysex command message to the Board.

command is always required, data is optional.

Examples

iex> Archytax.sysex_write(<< 0xF0 >>)
:ok

iex> Archytax.sysex_write(<< 0x6F >>, << 9, 127, 1 >>)
:ok
write(message)

Send any kind of information to the Board.