General Functions
=================

arduinosetup
------------

 -- RETVAL =: arduinosetup ()
 -- RETVAL =: arduinosetup (PROPERTYNAME, PROPERTYVALUE)
     Open the arduino config / programming tool to program the arduino hardware for usage with the Octave arduino functions.

     arduinosetup will create a temporary project  using the arduino IDE and allow compiling and programming of the code to an arduino.

Inputs
......

PROPERTYNAME, PROPERTYVALUE - A sequence of property name/value pairs can be given to set defaults while programming.

Currently the following properties can be set:

libraries
     The value should be the name of a library, or string array of libraries to program on the arduino board.

arduinobinary
     The value should be the name/path of the arduino IDE binary for programming. If not specified, the function will use getpref preferences of arduino.arduino_binary, and if not found, the function will attempt to find the binary itself.

     If provided, the value will be saved to preferences for future calls.

Outputs
.......

RETVAL - return 1 if arduino IDE returned without an error

arduino, __arduino_binary__

isarduino
---------

 -- RETVAL =: isarduino (OBJ)
     Check if input value is an arduino object

     Function is essentially just a call of

     retval = isa(obj, "arduino");

Inputs
......

OBJ - The object to check

Outputs
.......

RETVAL is true, if obj is an arduino object, false otherwise.

arduino

listArduinoLibraries
--------------------

 -- RETVAL =: listArduinoLibraries ()
 -- RETVAL =: listArduinoLibraries (LIBTYPES)
     Retrieve list of all known arduino library modules that are available.

Inputs
......

LIBTYPES - optional specifier for type of libraries to list.

Options are:

all
     List core and addons

core
     List core only libraries

addons
     List addons only

When no libtypes is specified, all libraries are shown.

Outputs
.......

RETVAL is an cell array of string library names that are available for programming to the arduino.

arduino, arduinosetup

scanForArduinos
---------------

 -- RETVAL =: scanForArduinos ()
 -- RETVAL =: scanForArduinos (MAXCOUNT)
 -- RETVAL =: scanForArduinos ("DEBUG")
 -- RETVAL =: scanForArduinos (MAXCOUNT, TYPE)
 -- RETVAL =: scanForArduinos (PROPERTYNAME, PROPERTVALUE ...)
     Scan system for programmed serial connected arduino boards.

     scanForArduinos will scan the system for programmed arduino boards and return at most MAXCOUNT of them as a cell array in RETVAL.

Inputs
......

MAXCOUNT - max number of arduino boards to detect. if MAXCOUNT is not specified, or is a less than 1, the function will return as many arduino boards as it can detect.

TYPE - optional board type to match. If specified, the board type must match for the arduino to be added to the return list.

"DEBUG" - if single input parameter is "debug", the scanForArduinos will display debug information as it scans all available ports for arduinos.

PROPERTYNAME, PROPERTYVALUE - property name/value pairs to match search with.

'BaudRate'
     Numeric BaudRate to use when trying to scan for arduinos.

'MaxCount'
     Max number of arduinos to scan for.

'BoardType'
     Boardtype to match.

'Debug'
     Logical flag for debug mode.

Outputs
.......

RETVAL structure cell array of matching detected arduino boards.

Each cell value of the cell array will contain a structure with values of:

port
     the serial port the arduino is connected to

board
     the board type of the arduino

arduino

Arduino Functions
=================

@arduino/arduino
----------------

 -- RETVAL =: arduino ()
 -- RETVAL =: arduino (PORT)
 -- RETVAL =: arduino (PORT, BOARD)
 -- RETVAL =: arduino (PORT, BOARD[, [PROPNAME, PROPVALUE]*)
 -- RETVAL =: arduino (IADDRESS)
 -- RETVAL =: arduino (IPADDRESS, BOARD)
     Create a arduino object with a connection to an arduino board.

Inputs
......

PORT - full path of serial port to connect to. For Linux, usually /dev/ttySXXX, for windows COMXX.

BOARD - name of board to connect (default is 'uno').

PROPNAME, PROPVALUE - property name and value pair for additional properties to pass to the creation of the arduino object.

Currently properties are ignored, with the exception of:

debug
     true / false flag for whether setting debug (default false)

forcebuildon
     true / false flag for whether to force show of the arduino IDE to rebuild the installed code on the arduino (default false)

baudrate (read only)
     the communications baudrate to the board. (default 9600)

libraries
     The libraries to be enabled on the arduino board. (default uses whatever is already installed)

if the arduino function is called without parameters, it will scan for the first available arduino it can find and connect to it.

Outputs
.......

RETVAL - a successfully connected arduino object.

Properties
..........

The arduino object has the following public properties:

name
     name assigned to the arduino object

debug
     true / false flag for whether debug is turned on

forcebuildon
     true / false flag for whether to force show of the arduino IDE to reprogram the arduino

port (read only)
     the communications port the board is connected to.

baudrate (read only)
     the communications baudrate to the board.

board  (read only)
     The name of the board type that the arduino connected to

libraries (read only)
     The libraries currently programmed onto the board

availablepins
     The pins available for use on the board

analogreference
     The analog voltage reference

scanForArduinos, arduinosetup

@arduino/checkI2CAddress
------------------------

 -- RETVAL =: checkI2CAddress (AR, ADDRESS)
 -- RETVAL =: checkI2CAddress (AR, ADDRESS, BUS)
     Check that an address of given address responds on the I2C bus

Inputs
......

AR - arduino object connected to a arduino board.

ADDRESS - I2C address number to check

BUS - bus number to check for I2C device, when multiple buses are available. If the bus is not specified, it will default to 0.

Outputs
.......

RETVAL - boolean value of true if address responds on the I2C bus

Example
.......

     {
      # create arduino connection.
      ar = arduino();
      # scan for devices on the I2C bus
      checkI2CAddress (ar)
      # output if a device using that address is attached
      ans =
        1
      }

arduino, scanI2Cbus

@arduino/configurePin
---------------------

 -- CURRMODE =: configurePin (AR, PIN)
 -- configurePin: (AR, PIN, MODE)
     Set/Get pin mode for a specified pin on arduino connection.

     configurePin (AR, PIN) will get the current mode of the specified pin.

     configurePin (AR, PIN, MODE) will attempt set the pin to the specified mode if the mode is unset.

Inputs
......

AR - the arduino object of the connection to an arduino board.

PIN - string name of the pin to set/get the mode of.

MODE - string mode to set the pin to.

Outputs
.......

MODE - string current mode of the pin.

Valid modes can be:

  * AnalogInput - Acquire analog signals from pin

  * DigitalInput - Acquire digital signals from pin

  * DigitalOutput - Generate digital signals from pin

  * I2C - Specify a pin to use with I2C protocol

  * Pullup - Specify pin to use a pullup switch

  * PWM - Specify pin to use a pulse width modulator

  * Servo - Specify pin to use a servo

  * SPI - Specify a pin to use with SPI protocol

  * Interrupt - Specify a pin to use for with interrupts

  * Reserved - Specify a pin to be reserved

  * Unset - Clears pin designation. The pin is no longer reserved and can be automatically set at the next operation.

arduino

@arduino/configurePinResource
-----------------------------

 -- CURRMODE =: configurePinResource (AR, PIN)
 -- configurePinResource: (AR, PIN, OWNER, MODE)
 -- configurePinResource: (AR, PIN, OWNER, MODE, FORCE)
     Set/Get pin mode for a specified pin on arduino connection.

     configurePinResource (AR, PIN) will get the current mode of the specified pin.

     configurePinResource (AR, PIN, OWNER, MODE) will attempt set the pin to the specified mode and owner.

     If the pin is already owned by another owner, the configure will fail unless the force option is used. If the mode is already set, configure will fail unless force is used.

Inputs
......

AR - the arduino object of the connection to an arduino board.

PIN - string name of the pin to set/get the mode of.

MODE - string mode to set the pin to.

OWNER - string name to use as the pin owner.

FORCE - boolean to force mode change. If not set, it will be false.

Outputs
.......

CURRMODE - current string mode of the pin.

Valid modes can be:

  * AnalogInput - Acquire analog signals from pin

  * DigitalInput - Acquire digital signals from pin

  * DigitalOutput - Generate digital signals from pin

  * I2C - Specify a pin to use with I2C protocol

  * Pullup - Specify pin to use a pullup switch

  * PWM - Specify pin to use a pulse width modulator

  * Servo - Specify pin to use a servo

  * SPI - Specify a pin to use with SPI protocol

  * Interrupt - Specify a pin to use with interrupts

  * Reserved - Pin marked reserved, but not for of any particular mode

  * Unset - Clears pin designation. The pin is no longer reserved and can be automatically set at the next operation.

arduino, configurePin

@arduino/decrementResourceCount
-------------------------------

 -- COUNT =: decrementResourceCount (AR, RESOURCE)
     Decrement the count of a named resource by 1 and return the new count.

Inputs
......

AR - connected arduino object

RESOURCE - name of resource to decrement count.

Outputs
.......

COUNT = count of uses registered to resource.

getResourceCount. incrementResourceCount

@arduino/delete
---------------

 -- delete: (DEV)
     Free resources of an arduino object.

Inputs
......

DEV - object to free

arduino

@arduino/disp
-------------

 -- disp: (AR)
     Display the arduino object in a verbose way, showing the board and available pins.

Inputs
......

AR - the arduino object.

If the arduino object has debug mode set, additional information will be displayed.

arduino

@arduino/getEndian
------------------

 -- MCU =: getEndian (AR)
     Get the endian used by the connected arduino.

Inputs
......

AR - arduino object connected to a arduino board.

Outputs
.......

ENDIAN - string representing the endian used by the arduino board.

'L' means little endian, 'B' means big endian

arduino, getMCU

@arduino/getI2CTerminals
------------------------

 -- PINLIST =: getI2CTerminals (AR)
 -- PINLIST =: getI2CTerminals (AR, BUS)
     Get a cell list of pin Ids available are used for I2C mode.

Inputs
......

AR - the arduino object.

BUS - optional bus number 0 or 1 for boards that support more than 1 bus.

Outputs
.......

PINLIST - cell list of pin numbers available for I2C use.

arduino

@arduino/getInterruptTerminals
------------------------------

 -- PINLIST =: getInterruptTerminals (AR)
     Get a cell list of pin Ids available have interrupt functionality

Inputs
......

AR - the arduino object.

Outputs
.......

PINLIST - cell list of pin numbers available for interrupt use.

arduino

@arduino/getLEDTerminals
------------------------

 -- PINLIST =: getLEDTerminals (AR)
     Get a cell list of pin Ids available are connected natively to LEDs.

Inputs
......

AR - the arduino object.

Outputs
.......

PINLIST - cell list of pin numbers available for LED use.

arduino

@arduino/getMCU
---------------

 -- MCU =: getMCU (AR)
     Get the MCU used by the connected arduino.

Inputs
......

AR - arduino object connected to a arduino board.

Outputs
.......

MCU - string representing the mcu used by the arduino board.

arduino

@arduino/getPWMTerminals
------------------------

 -- PINLIST =: getPWMTerminals (AR)
     Get a cell list of pin Ids available for PWM use.

Inputs
......

AR - the arduino object.

Outputs
.......

PINLIST - cell list of pin numbers available for PWM use.

arduino

@arduino/getPinAlias
--------------------

 -- OUY =: getPinAlias (AR, PIN)
     Get the pin actual pin name from a pin alias.

     For example, the arduino Leonardo, pin "D4" is also "A6".

Inputs
......

AR - the connected arduino object.

PIN - a pin name.

Outputs
.......

OUT - alias pin name, or same as PIN if the pin doesnt have any alias names.

arduino, configurePinResource, getResourceOwner

@arduino/getPinInfo
-------------------

 -- PININFO =: getPinInfo (AR, PIN)
 -- PININFOARRAY =: getPinInfo (AR, PINARRAY)
     Get the pin information from the input pins values.

     getPinInfo (AR, PIN) will get information for a single pin.

     getPinInfo (AR, PINARRAY) will get a cell array of pin information

Inputs
......

AR - the connected arduino object.

PIN - a pin number or pin name.

PINARRAY - the array of pin numbers or names

The pininfo struct contains the following fields:

terminal
     Terminal number of the pin

name
     String name of the pin

owner
     Current item owner of the pin

mode
     Current configured mode for the pin

Outputs
.......

PININFO - struct on pin information.

PININFOLIST - cell array of pin info

arduino, configurePinResource, getResourceOwner

@arduino/getPinsFromTerminals
-----------------------------

 -- PINNAMES =: getPinsFromTerminals (AR, TERMINALS)
     Get the pin names from the input terminal values.

Inputs
......

AR - the connected arduino object.

TERMINALS - the numeric pin number, or array of pin numbers to get pin names.

Outputs
.......

PINNAMES - the string names of each input pin. If terminals was a single value, the return will be a single string, otherwise it will return a cell array of each pin name.

arduino, getTerminalsFromPins

@arduino/getResourceCount
-------------------------

 -- COUNT =: getResourceCount (AR, RESOURCE)
     Get the count of uses of  a given resource.

Inputs
......

AR - connected arduino object

RESOURCE - name of resource to get count for.

Outputs
.......

COUNT = count of uses registered to resource.

incrementResourceCount. decrementResourceCount

@arduino/getResourceOwner
-------------------------

 -- OWNER =: getResourceOwner (AR, TERMINAL)
     Get the owner of pin allocated previously by configurePinResource.

Inputs
......

AR - connected arduino object

TERMINAL - terminal number to get owner of.

Outputs
.......

OWNER = owner of the terminal pin, or "" if not owned.

configurePinResource

@arduino/getSPITerminals
------------------------

 -- PINLIST =: getSPITerminals (AR)
     Get a cell list of pin Ids available for SPI mode.

Inputs
......

AR - the arduino object.

Outputs
.......

PINLIST - cell list of pin numbers available for SPI use.

arduino

@arduino/getServoTerminals
--------------------------

 -- PINLIST =: getServoTerminals (AR)
     Get a cell list of pin Ids available for servo use.

Inputs
......

AR - the arduino object.

Outputs
.......

PINLIST - cell list of pin numbers available for servo use.

arduino, getPWMTerminals

@arduino/getSharedResourceProperty
----------------------------------

 -- COUNT =: getSharedResourceProperty (AR, RESOURCE, PROPERTY)
     Get the value of a property from a given resource.

Inputs
......

AR - connected arduino object

RESOURCE - name of resource to get property for.

PROPERTY - name of property from the resource.

Outputs
.......

PROPVALUE - value of the property

getResourceCount, setSharedResourceProperty

@arduino/getTerminalMode
------------------------

 -- MODE =: getTerminalMode (AR, TERMINAL)
     Get the mode of a pin allocated previously by configurePinResource.

Inputs
......

AR - connected arduino object

TERMINAL - terminal number to get owner of.

Outputs
.......

MODE - mode of the terminal pin, or "not_set" if not owned.

configurePinResource, getResourceOwner

@arduino/getTerminalsFromPins
-----------------------------

 -- PINNUMS =: getTerminalsFromPins (AR, PINS)
     Get the terminal number for each pin.

Inputs
......

AR - connected arduino object

PINS - single pin name or cell or vector array of pin names.

Outputs
.......

PINNUMS - pin number of each named pin. If the input was a single string, returns a number. if the input pins was a vector or cell array, return a cell array of pin numbers corresponding to each input pin name.

arduino, getPinsFromTerminals

@arduino/incrementResourceCount
-------------------------------

 -- COUNT =: incrementResourceCount (AR, RESOURCE)
     Increment the count value of a named resource by 1 and return the new count

Inputs
......

AR - connected arduino object

RESOURCE - name of resource to increment count.

Outputs
.......

COUNT = count of uses registered to resource.

getResourceCount. decrementResourceCount

@arduino/isTerminalAnalog
-------------------------

 -- RET = : isTerminalAnalog (OBJ, TERMINAL)
     Return true if pin is capable of analog input

Inputs
......

AR - the connected arduino object

TERMINAL is a terminal number to check

Outputs
.......

RET return 1 if terminal is a analog pin, 0 otherwise

@arduino/isTerminalDigital
--------------------------

 -- RET = : isTerminalDigital(OBJ, TERMINAL)
     Return true if pin is capable of digital functions

Inputs
......

AR - the connected arduino object

TERMINAL is a terminal number to check

Outputs
.......

RET return 1 if terminal is a digital pin, 0 otherwise

@arduino/playTone
-----------------

 -- playTone: (AR, PIN, FREQ, DURATION)
     Play a tone of a given frequency on a specified pin.

Inputs
......

AR - connected arduino object

PIN - digital pin to play tone on

FREQ - frequency in  hertz to play between 0 and 32767Hz.

DURATION duration in seconds to play tone between 0 and 30 seconds

If duration is 0 or not specified, tone will continue to play until next tone is commanded. If frequency is 0, tone will stop playing

NOTE: use of playTone can interfere with PWM output.

@arduino/readAnalogPin
----------------------

 -- VALUE =: readAnalogPin (AR, PIN)
     Read analog voltage of  PIN.

Inputs
......

AR - connected arduino object.

PIN - string name of the pin to read.

Outputs
.......

VALUE - analog value of the pin

Example
.......

      ar = arduino ();
      readAnalogPin(ar, "A4");
      ans =
          87

arduino, readVoltage

@arduino/readDigitalPin
-----------------------

 -- VALUE =: readDigitalPin (OBJ, PIN)
     Read digital value from a digital I/O pin.

Inputs
......

AR - connected arduino object.

PIN - string name of the pin to read.

Outputs
.......

VALUE - the logical value (0, 1, true false) of the current pin state.

Example
.......

      a = arduino ();
      pinvalue = readDigitalPin (a, 'D5');

arduino, writeDigitalPin

@arduino/readVoltage
--------------------

 -- VOLTAGE =: readVoltage (AR, PIN)
     Read analog voltage of a pin.

Inputs
......

AR - connected arduino.

PIN - pin name or number to query for voltage

Outputs
.......

VOLTAGE - scaled pin value as a voltage

Example
.......

      ar = arduino ();
      readVoltage(ar, "A4");
      ans =
          1.401

arduino, readAnalogPin

@arduino/reset
--------------

 -- reset: (AR)
     Send reset command to arduino hardware to force a hardware reset.

Inputs
......

AR - connected arduino object.

arduino

@arduino/sendCommand
--------------------

 -- OUTDATA, OUTSIZE =: sendCommand (AR, LIBNAME, COMMANDID)
 -- OUTDATA, OUTSIZE =: sendCommand (AR, LIBNAME, COMMANDID, DATA)
 -- OUTDATA, OUTSIZE =: sendCommand (AR, LIBNAME, COMMANDID, DATA, TIMEOUT)
     Send a command with option data to the connected arduino, waiting up to a specified number of seconds for a response.

Inputs
......

AR - connected arduino object.

LIBNAME - library sending the command. The name should match a programmed library of the arduino, or an error will be displayed.

COMMANDID - integer value for the command being sent to the arduino.

DATA - optional data sent with the command.

TIMEOUT - optional timeout to wait for data

Outputs
.......

OUTDATA - data returned back from the arduino in response to command

OUTSIZE - size of data received

If the arduino fails to respond with a valid reply, sendCommand will error.

arduino

@arduino/setSharedResourceProperty
----------------------------------

 -- setSharedResourceProperty: (AR, RESOURCE, PROPNAME, PROPVALUE)
 -- setSharedResourceProperty: (AR, RESOURCE, PROPNAME, PROPVALUE, ___)
     Set property values for a given resource.

Inputs
......

AR - connected arduino object

RESOURCE - name of resource to get property for.

PROPNAME - name of property from the resource.

PROPVALUE - value of property from the resource.

Multiple PROPNAME, PROPVALUE pairs can be given.

Outputs
.......

None

Example
.......

      ar = arduino();
      setSharedResourceProperty(ar, "myresource", "myproperty", [1 2 3])

getSharedResourceProperty

@arduino/uptime
---------------

 -- SEC =: uptime (AR)
     Get the number of seconds the arduino board has been running concurrently.

Inputs
......

AR - the arduino object of the connection to an arduino board.

Outputs
.......

SEC - the number seconds the board has been running. Note that the count will wrap around after approximately 50 days.

arduino

@arduino/validatePin
--------------------

 -- validatePin: (AR, PIN, TYPE)
     Validate that the mode is allowed for specified pin

     If the mode is not valid, and error will be thrown.

Inputs
......

AR - connected arduino object

PIN -  name of pin to query mode validity of

MODE - mode to query

Known modes are:

  * 'I2C'

  * 'SPI'

  * 'PWM'

  * 'Servo'

  * 'analog'

  * 'digital'

arduino, configurePin

@arduino/version
----------------

 -- VER =: version (AR)
     Get version of library code installed on arduino board

Inputs
......

AR - the arduino object of the connection to an arduino board.

Outputs
.......

VER - version string in format of X.Y.Z.

arduino

@arduino/writeDigitalPin
------------------------

 -- writeDigitalPin: (AR, PIN, VALUE)
     Write digital value to a digital I/O pin.

Inputs
......

AR - connected arduino object.

PIN - string name of the pin to write to.

VALUE - the logical value (0, 1, true false) to write to the pin.

If pin was unconfigured before using, pin is set into digital mode.

Example
.......

      a = arduino();
      writeDigitalPin(a,'D5',1);

arduino, readDigitalPin

@arduino/writePWMDutyCycle
--------------------------

 -- writePWMDutyCyle: (AR, PIN, VALUE)
     Set pin to output a square wave with a specified duty cycle.

Inputs
......

AR - connected arduino object

PIN - pin to write to.

VALUE - duty cycle value where 0 = off, 0.5 = 50% on, 1 = always on.

Example
.......

      a = arduino();
      writePWMDutyCycle(a,'D5',0.5);

arduino, writePWMVoltage

@arduino/writePWMVoltage
------------------------

 -- writePWMVoltage: (AR, PIN, VOLTAGE)
     Emulate an approximate voltage out of a pin using PWM.

Inputs
......

AR - connected arduino object

PIN - pin to write to.

VOLTAGE - voltage to emulate with PWM, between 0 - 5.0

Example
.......

      a = arduino();
      writePWMVoltage(a,'D5',1.0);

arduino, writePWMDutyCycle

Arduino I2C Functions
=====================

@device/delete
--------------

 -- delete: (DEV)
     Free resources of a device object.

Inputs
......

DEV - object to free

device

@device/disp
------------

 -- disp: (DEV)
     Display device object.

Inputs
......

DEV - device object to display

device

@device/read
------------

 -- DATA =: read (DEV, NUMBYTES)
 -- DATA =: read (DEV, NUMBYTES, PRECISION)
     Read a specified number of bytes from a i2c or serial device object using optional precision for bytesize.

Inputs
......

DEV - connected i2c or serial device opened using device

NUMBYTES - number of bytes to read.

PRECISION - Optional precision for the output data read data. Currently known precision values are uint8 (default), int8, uint16, int16

Outputs
.......

DATA - data read from the device

arduino, device

@device/readRegister
--------------------

 -- DATA =: readRegister (DEV, REG, NUMBYTES)
 -- DATA =: readRegister (DEV, REG, NUMBYTES, PRECISION)
     Read a specified number of bytes from a register of an i2cdev object using optional precision for bytesize.

Inputs
......

DEV - connected i2c device opened using device

REG - registry value number

NUMBYTES - number of bytes to read.

PRECISION - Optional precision for the output data read data. Currently known precision values are uint8 (default), int8, uint16, int16

Output
......

DATA - data read from device.

arduino, device

@device/subsref
---------------

 -- VAL = : subsref (DEV, SUB)
     subref for device

     device

@device/write
-------------

 -- write: (DEV, DATAIN)
 -- write: (DEV, DATAIN, PRECISION)
     Write data to a I2C or serial device object using optional precision for the data byte used for the data.

Inputs
......

DEV - connected i2c or serial device opened using device

DATAIN - data to write to device. Datasize should not exceed the constraints of the data type specified for the precision.

PRECISION - Optional precision for the input write data. Currently known precision values are uint8 (default), int8, uint16, int16

arduino, device, read

@device/writeRegister
---------------------

 -- writeRegister: (DEV, REG, DATAIN)
 -- writeRegister: (DEV, DEV, DATAIN, PRECISION)
     Write data to i2c device object at a given registry position using optional precision for the data byte used for the data.

Inputs
......

DEV - connected i2c device opened using device

REG - registry position to write to.

DATAIN - data to write to device. Datasize should not exceed the constraints of the data type specified for the precision.

PRECISION - Optional precision for the input write data. Currently known precision values are uint8 (default), int8, uint16, int16

arduino, device, read

@i2cdev/delete
--------------

 -- delete: (DEV)
     Free resources of a i2cdev object.

Inputs
......

DEV - object to free

i2cdev

@i2cdev/disp
------------

 -- disp: (DEV)
     Display i2cdev object.

Inputs
......

DEV - i2cdev object

i2cdev

@i2cdev/i2cdev
--------------

 -- DEV =: i2cdev (AR, ADDRESS)
 -- DEV =: i2cdev (AR, ADDRESS, PROPNAME, PROPVALUE)

     i2cdev is depreciated and will be removed in a future version. Use device instead.

     Create an i2cdev object to communicate to the i2c port on a connected arduino.

Inputs
......

AR - connected arduino object

ADDRESS - address to use for device on I2C bus.

PROPNAME, PROPVALUE - property name/value pair for values to pass to devices.

Currently known properties:

bus
     bus number (when arduino board supports multiple I2C buses) with value of 0 or 1.

Outputs
.......

DEV - new created i2cdev object.

Properties
..........

The i2cdev object has the following public properties:

parent
     The parent (arduino) for this device

pins
     pins used by this object

bus
     bus used for created object

address
     I2C address set for object

arduino

@i2cdev/read
------------

 -- DATA =: read (DEV, NUMBYTES)
 -- DATA =: read (DEV, NUMBYTES, PRECISION)
     Read a specified number of bytes from a i2cdev object using optional precision for bytesize.

Inputs
......

DEV - connected i2c device opened using i2cdev

NUMBYTES - number of bytes to read.

PRECISION - Optional precision for the output data read data. Currently known precision values are uint8 (default), int8, uint16, int16

Outputs
.......

DATA - data read from i2cdevice

arduino, i2cdev

@i2cdev/readRegister
--------------------

 -- DATA =: readRegister (DEV, REG, NUMBYTES)
 -- DATA =: readRegister (DEV, REG, NUMBYTES, PRECISION)
     Read a specified number of bytes from a register of an i2cdev object using optional precision for bytesize.

Inputs
......

DEV - connected i2c device opened using i2cdev

REG - registry value number

NUMBYTES - number of bytes to read.

PRECISION - Optional precision for the output data read data. Currently known precision values are uint8 (default), int8, uint16, int16

Output
......

DATA - data read from device.

arduino, i2cdev

@i2cdev/subsref
---------------

 -- VAL = : subsref (DEV, SUB)
     subref for i2cdev

     i2cdev

@i2cdev/write
-------------

 -- write: (DEV, DATAIN)
 -- write: (DEV, DATAIN, PRECISION)
     Write data to a i2cdev object using optional precision for the data byte used for the data.

Inputs
......

DEV - connected i2c device opened using i2cdev

DATAIN - data to write to device. Datasize should not exceed the constraints of the data type specified for the precision.

PRECISION - Optional precision for the input write data. Currently known precision values are uint8 (default), int8, uint16, int16

arduino, i2cdev, read

@i2cdev/writeRegister
---------------------

 -- writeRegister: (DEV, REG, DATAIN)
 -- writeRegister: (DEV, DEV, DATAIN, PRECISION)
     Write data to i2cdev object at a given registry position using optional precision for the data byte used for the data.

Inputs
......

DEV - connected i2c device opened using i2cdev

REG - registry position to write to.

DATAIN - data to write to device. Datasize should not exceed the constraints of the data type specified for the precision.

PRECISION - Optional precision for the input write data. Currently known precision values are uint8 (default), int8, uint16, int16

arduino, i2cdev, read

scanI2Cbus
----------

 -- RETVAL =: scanI2Cbus (AR)
 -- RETVAL =: scanI2Cbus (AR, BUS)
     Scan arduino for devices on the I2C bus.

Inputs
......

AR - arduino object connected to a arduino board.

BUS - bus number to scan I2C devices, when multiple buses are available. If the bus is not specified, it will default to 0.

Outputs
.......

RETVAL - cell array of addresses as strings in format of "0xXX".

Example
.......

     {
      # create arduino connection.
      ar = arduino();
      # scan for devices on the I2C bus
      scanI2Cbus (ar)
      # output is each detected i2c address as a string
      ans =
     {
       [1,1] = 0x50
     }
      }

arduino, i2cdev, checkI2CAddress

Arduino Rotary Encoder Functions
================================

@rotaryEncoder/delete
---------------------

 -- delete: (DEV)
     Free resources of a encoder object.

Inputs
......

DEV - object to free

rotartEncoder

@rotaryEncoder/disp
-------------------

 -- RETVAL =: disp (OBJ)
     Display the rotary encoder object in a verbose way,

Inputs
......

OBJ - the arduino rotary encoder object created with rotaryEncoder

rotaryEncoder

@rotaryEncoder/readCount
------------------------

 -- [COUNT, TIME] =: readCount (OBJ)
 -- [COUNT, TIME] =: readCount (OBJ, NAME, VALUE)
     read count value from the rotary encoder.

     subsubheading Inputs OBJ - rotary encoder object created with rotaryEncoder call.

     NAME, VALUE - optional name,value pairs

     Valid option name pairs currently are:

     reset
          Reset the count after reading (if true)

Outputs
.......

COUNT - returned count read from the encoder.

TIME - seconds since arduino started

rotaryEncoder, resetCount

@rotaryEncoder/readSpeed
------------------------

 -- SPEED =: readSpeed (OBJ)
     read rotational speed from the rotary encoder.

Inputs
......

OBJ - rotary encoder object created with rotaryEncoder call.

Outputs
.......

SPEED - returned speed in revolutions per minute read from the encoder.

rotaryEncoder, resetCount

@rotaryEncoder/resetCount
-------------------------

 -- reset: (OBJ)
 -- reset: (OBJ, CNT)
     reset the rotary encoder count values

Inputs
......

OBJ - the rotaryEncoder object

CNT - optional count value to reset to

rotaryEncoder, readCount

@rotaryEncoder/rotaryEncoder
----------------------------

 -- OBJ =: rotaryEncoder (AR, CHANAPIN, CHANBPIN)
 -- OBJ =: rotaryEncoder (AR, CHANAPIN, CHANBPIN, PPR)
     Create a rotaryEncoder object controlled by the input pins.

Inputs
......

AR - connected arduino object.

CHANAPIN - pin used for channel A

CHANBPIN - pin used for channel B

PPR - count of encoder pulsed required for a full revolution of the encoder.

Outputs
.......

OBJ - created rotary encoder object

Example
.......

      a = arduino ();
      enc = rotaryEncoder(a, "d2", "d3", 180);

Properties
..........

The rotaryEncoder object has the following public properties:

parent
     The parent (arduino) for this device

pins
     pins used by this object

ppr
     Number of pulses used per rotation

arduino

@rotaryEncoder/subsref
----------------------

 -- VAL = : subsref (DEV, SUB)
     subref for rotaryEncoder

     rotaryEncoder

Arduino Servo Functions
=======================

@servo/delete
-------------

 -- delete: (DEV)
     Free resources of a servo object.

Inputs
......

DEV - object to free

servo

@servo/disp
-----------

 -- disp: (DEV)
     Display servo object.

Inputs
......

DEV - servo device to display

servo

@servo/readPosition
-------------------

 -- POSITION = : readPosition (SERVO)
     Read the position of a servo

Inputs
......

SERVO - servo object created from arduino.servo.

Outputs
.......

POSITION - value between 0 .. 1 for the current servo position, where 0 is the servo min position, 1 is the servo maximum position.

servo, writePosition

@servo/servo
------------

 -- OBJ = : servo (ARDUINOOBJ, PIN)
 -- OBJ = : servo (ARDUINOOBJ, PIN, PROPERTYNAME, PROPERTYVALUE)
     Create a servo object using a specified pin on a arduino board.

Inputs
......

OBJ - servo object

ARDUINOOBJ - connected arduino object

PROPERTYNAME,  PROPERTYVALUE - name value pairs for properties to pass to the created servo object.

Current properties are:

minpulseduration
     min PWM pulse value in seconds.

maxpulseduration
     max PWM pulse value in seconds.

Outputs
.......

OBJ - created servo object.

Example
.......

      # create arduino connection
      ar = arduino();
      # create hobby servo (1 - 2 ms pulse range)
      servo = servo(ar, "d9", "minpulseduration", 1.0e-3, "maxpulseduration", 2e-3);
      # center the servo
      writePosition(servo, 0.5);

Properties
..........

The servo object has the following public properties:

parent
     The parent (arduino) for this device

pins
     pins used by this object

minpulseduration
     minpulseduration set for object

maxpulseduration
     maxpulseduration set for object

arduino, readPosition, writePosition

@servo/subsref
--------------

 -- VAL = : subsref (DEV, SUB)
     subref for servo

     servo

@servo/writePosition
--------------------

 -- writePosition: (SERVO, POSITION)
     Write the position to a servo.

Inputs
......

SERVO - servo object created from arduino.servo.

POSITION - value between 0 .. 1 for the current servo position, where 0 is the servo min position, 1 is the servo maximum position.

servo, readPosition

Arduino Shiftregister Functions
===============================

@shiftRegister/delete
---------------------

 -- delete: (DEV)
     Free resources of a shiftRegister object.

Inputs
......

DEV - object to free

shiftRegister

@shiftRegister/disp
-------------------

 -- disp: (REGISTER)
     Display the register object in a verbose way,

Inputs
......

REGISTER - the arduino register object created with shiftRegister.

shiftRegister

@shiftRegister/read
-------------------

 -- RETVAL =: read (REGISTER)
 -- RETVAL =: read (REGISTER, PRECISION)
     read a value from the shift register.

Inputs
......

REGISTER - shift register created from shiftRegister call.

PRECISION - optional precision of the data, where precision can be a number in a multiple of 8 (ie: 8,16,32) or can be a named integer type:     8 of 'uint8', 'uint16', 'uint32'.  The default  precision is 8.

Outputs
.......

RETVAL - returned data read from the register.

shiftRegister, write

@shiftRegister/reset
--------------------

 -- reset: (REGISTER)
     clear the shift register value.

Inputs
......

REGISTER - shift register created from shiftRegister call.

shiftRegister, read, write

@shiftRegister/shiftRegister
----------------------------

 -- REGISTER =: shiftRegister (AR, SHIFTTYPE, DATAPIN, CLOCKPIN ...)
 -- REGISTER =: shiftRegister (AR,'74hc164', DATAPIN, CLOCKPIN, RESETPIN)
 -- REGISTER =: shiftRegister (AR,'74hc165', DATAPIN, CLOCKPIN, LOADPIN, CLOCKENABLEPIN)
 -- REGISTER =: shiftRegister(AR,'74hc595', DATAPIN, CLOCKPIN, LATCHPIN , RESETPIN)
     Create shift register of a given type, controlled by the input pins.

Inputs
......

Common function parameter definition:

AR - connected arduino object.

SHIFTTYPE - string name of the shift register type.

DATAPIN - pin used for data in/out of the device.

CLOCKPIN - pin used for clocking data on the shiftRegister.

Other variables are dependent on the shift register type:

'74hc164'
     Additional inputs:

     RESETPIN - optional  pin for resetting the shift register.

'74hc165'
     Additional inputs:

     LOADPIN - load pin to the shift register. CLOCKENABLEPIN - clock enable pin.

'74hc595'
     Additional inputs:

     LATCHPIN - latching data to the shift register. RESETPIN - optional pin for resetting the shift register.

Outputs
.......

REGISTER - register object

Properties
..........

The shiftRegister object has the following public properties:

parent
     The parent (arduino) for this device

pins
     pins used by this object

model
     model set for object

arduino

@shiftRegister/subsref
----------------------

 -- VAL = : subsref (DEV, SUB)
     subref for shiftRegister

     shiftRegister

@shiftRegister/write
--------------------

 -- write: (REGISTER, DATAIN)
 -- write: (REGISTER, DATAIN, PRECISION)
     Write a value to the shift register.

Inputs
......

REGISTER - shift register created from shiftRegister call.

DATAIN - data to clock into the shiftRegister.

PRECISION - optional precision of the data, where precision can be a number in a multiple of 8 (ie: 8,16,32) or can be a named integer type of 'uint8', 'uint16', 'uint32'.  The default  precision is 8.

shiftRegister, read

Arduino SPI Functions
=====================

@device/delete
--------------

 -- delete: (DEV)
     Free resources of a device object.

Inputs
......

DEV - object to free

device

@device/disp
------------

 -- disp: (DEV)
     Display device object.

Inputs
......

DEV - device object to display

device

@device/subsref
---------------

 -- VAL = : subsref (DEV, SUB)
     subref for device

     device

@device/writeRead
-----------------

 -- DATAOUT =: readWrite (SPI, DATAIN)
     Write uint8 data to spi device and return back clocked out response data of same size.

Inputs
......

SPI - connected spi device on arduino

DATAIN - uint8 sized data to send to spi device framed between SS frame.

Outputs
.......

DATAOUT - uint8 data clocked out during send to dataIn.

arduino, device

@spidev/delete
--------------

 -- delete: (DEV)
     Free resources of a spidev object.

Inputs
......

DEV - spidev object to free

spidev

@spidev/disp
------------

 -- disp: (DEV)
     Display spidev object.

Inputs
......

DEV - spidev object to display

spidev

@spidev/spidev
--------------

 -- DEV =: spidev (AR, CSPIN)
 -- DEV =: spidev (AR, CSPIN, PROPNAME, PROPVALUE)

     spidev is depreciated and will be removed in a future version. Use device instead.

     Create an spidev object to communicate to the SPI port on a connected arduino.

Inputs
......

AR - connected arduino object

CSPIN - chip select pin for attached spi device.

PROPNAME, PROPVALUE - property name/value pair for values to pass to devices.

Currently known properties:

bitrate
     bit rate speed in Mbs

bitorder
     'msbfirst' or 'lsbfirst'

mode
     SPI mode 0 - 3.

Outputs
.......

DEV - created spidev object

Properties
..........

The spidev object has the following public properties:

parent
     The parent (arduino) for this device

pins
     pins used by this object

mode
     mode used for created object

bitrate
     Bitrate set for object

bitorder
     Bitorder set for object

chipselectpin
     Pin used for chipselect

arduino, readWrite

@spidev/subsref
---------------

 -- VAL = : subsref (DEV, SUB)
     subref for spidev

     spidev

@spidev/writeRead
-----------------

 -- DATAOUT =: readWrite (SPI, DATAIN)
     Write uint8 data to spi device and return back clocked out response data of same size.

Inputs
......

SPI - connected spi device on arduino

DATAIN - uint8 sized data to send to spi device framed between SS frame.

Outputs
.......

DATAOUT - uint8 data clocked out during send to dataIn.

arduino, spidev

Arduino Serial Functions
========================

@device/delete
--------------

 -- delete: (DEV)
     Free resources of a device object.

Inputs
......

DEV - object to free

device

@device/device
--------------

 -- DEV =: device (AR, 'I2CAddress', ADDRESS)
 -- DEV =: device (AR, 'SPIChipSelectPin', PIN)
 -- DEV =: device (AR, 'Serial', SERIALID)
 -- DEV =: device (..., PROPNAME, PROPVALUE)
     Create an i2c, spi or serial object to communicate on a connected arduino.

Inputs
......

AR - connected arduino object

PROPNAME, PROPVALUE - property name/value pair for values to pass to devices.

A property of 'i2caddress', 'spichipselectpin' or 'serial'  must be specified to denote the device type to create.

I2CADDRESS - address to use for device on I2C bus.

PIN - pin to use for device SPI chip select.

SERIALID - Serial port id to use

Additional properties can also be specified for the device object

Currently known input I2C properties values:

bus
     bus number (when arduino board supports multiple I2C buses) with value of 0 or 1.

noprobe
     Do not probe the existence of device on creation if set to 1 (default 0)

bitrate
     bit rate speed in Mbs - default 100000

Currently known input SPI properties values:

bitrate
     bit rate speed in Mbs

bitorder
     'msbfirst' or 'lsbfirst'

spimode
     SPI mode 0 - 3.

Currently known input Serial properties values:

baudrate
     baudrate value (default 9600)

databits
     number of databits (5,6,7,8) (default 8)

stopbits
     number of stopbits (1,2) (default 1)

parity
     parity of device ('odd','even','none') (default 'none')

Outputs
.......

DEV - new created device object.

Properties
..........

The object has the following public properties:

parent
     The parent (arduino) for this device

interface
     The interface type for this device ("SPI" or "I2C" or "Serial")

In addition, depending on type, the object will have these properties:

I2C Properties
..............

The object has the following public properties:

bus
     bus used for created object

i2caddress
     I2C address set for object

sclpin
     the SCL pin of the device

sdapin
     the SDA pin of the device

bitrate
     bit rate for the i2c clock

SPI Properties
..............

The object has the following public properties:

spimode
     mode used for created object

bitrate
     Bitrate set for object

bitorder
     Bitorder set for object

spichipselectpin
     Pin used for chipselect

mosipin
     Pin used for mosi

misopin
     Pin used for miso

sckpin
     Pin used for sckpin

Serial Properties
.................

The object has the following public properties:

id
     serial port id

baudrate
     baudrate

databits
     number of databits (5,6,7,8)

stopbits
     number of stopbits (1,2)

parity
     parity of device ('odd','even','none')

arduino, i2cdev, spidev

@device/disp
------------

 -- disp: (DEV)
     Display device object.

Inputs
......

DEV - device object to display

device

@device/flush
-------------

 -- DATA =: flush (DEV)
 -- DATA =: flush (DEV, "input")
 -- DATA =: flush (DEV, "output")
     Flush the serial port buffers

Inputs
......

DEV - connected serial device opened using device

If an additional parameter is provided of "input" or "output", then only the input or output buffer will be flushed

Outputs
.......

None

arduino, device, read

@device/read
------------

 -- DATA =: read (DEV, NUMBYTES)
 -- DATA =: read (DEV, NUMBYTES, PRECISION)
     Read a specified number of bytes from a i2c or serial device object using optional precision for bytesize.

Inputs
......

DEV - connected i2c or serial device opened using device

NUMBYTES - number of bytes to read.

PRECISION - Optional precision for the output data read data. Currently known precision values are uint8 (default), int8, uint16, int16

Outputs
.......

DATA - data read from the device

arduino, device

@device/subsref
---------------

 -- VAL = : subsref (DEV, SUB)
     subref for device

     device

@device/write
-------------

 -- write: (DEV, DATAIN)
 -- write: (DEV, DATAIN, PRECISION)
     Write data to a I2C or serial device object using optional precision for the data byte used for the data.

Inputs
......

DEV - connected i2c or serial device opened using device

DATAIN - data to write to device. Datasize should not exceed the constraints of the data type specified for the precision.

PRECISION - Optional precision for the input write data. Currently known precision values are uint8 (default), int8, uint16, int16

arduino, device, read

Arduino Device Functions
========================

@device/delete
--------------

 -- delete: (DEV)
     Free resources of a device object.

Inputs
......

DEV - object to free

device

@device/device
--------------

 -- DEV =: device (AR, 'I2CAddress', ADDRESS)
 -- DEV =: device (AR, 'SPIChipSelectPin', PIN)
 -- DEV =: device (AR, 'Serial', SERIALID)
 -- DEV =: device (..., PROPNAME, PROPVALUE)
     Create an i2c, spi or serial object to communicate on a connected arduino.

Inputs
......

AR - connected arduino object

PROPNAME, PROPVALUE - property name/value pair for values to pass to devices.

A property of 'i2caddress', 'spichipselectpin' or 'serial'  must be specified to denote the device type to create.

I2CADDRESS - address to use for device on I2C bus.

PIN - pin to use for device SPI chip select.

SERIALID - Serial port id to use

Additional properties can also be specified for the device object

Currently known input I2C properties values:

bus
     bus number (when arduino board supports multiple I2C buses) with value of 0 or 1.

noprobe
     Do not probe the existence of device on creation if set to 1 (default 0)

bitrate
     bit rate speed in Mbs - default 100000

Currently known input SPI properties values:

bitrate
     bit rate speed in Mbs

bitorder
     'msbfirst' or 'lsbfirst'

spimode
     SPI mode 0 - 3.

Currently known input Serial properties values:

baudrate
     baudrate value (default 9600)

databits
     number of databits (5,6,7,8) (default 8)

stopbits
     number of stopbits (1,2) (default 1)

parity
     parity of device ('odd','even','none') (default 'none')

Outputs
.......

DEV - new created device object.

Properties
..........

The object has the following public properties:

parent
     The parent (arduino) for this device

interface
     The interface type for this device ("SPI" or "I2C" or "Serial")

In addition, depending on type, the object will have these properties:

I2C Properties
..............

The object has the following public properties:

bus
     bus used for created object

i2caddress
     I2C address set for object

sclpin
     the SCL pin of the device

sdapin
     the SDA pin of the device

bitrate
     bit rate for the i2c clock

SPI Properties
..............

The object has the following public properties:

spimode
     mode used for created object

bitrate
     Bitrate set for object

bitorder
     Bitorder set for object

spichipselectpin
     Pin used for chipselect

mosipin
     Pin used for mosi

misopin
     Pin used for miso

sckpin
     Pin used for sckpin

Serial Properties
.................

The object has the following public properties:

id
     serial port id

baudrate
     baudrate

databits
     number of databits (5,6,7,8)

stopbits
     number of stopbits (1,2)

parity
     parity of device ('odd','even','none')

arduino, i2cdev, spidev

@device/disp
------------

 -- disp: (DEV)
     Display device object.

Inputs
......

DEV - device object to display

device

@device/flush
-------------

 -- DATA =: flush (DEV)
 -- DATA =: flush (DEV, "input")
 -- DATA =: flush (DEV, "output")
     Flush the serial port buffers

Inputs
......

DEV - connected serial device opened using device

If an additional parameter is provided of "input" or "output", then only the input or output buffer will be flushed

Outputs
.......

None

arduino, device, read

@device/read
------------

 -- DATA =: read (DEV, NUMBYTES)
 -- DATA =: read (DEV, NUMBYTES, PRECISION)
     Read a specified number of bytes from a i2c or serial device object using optional precision for bytesize.

Inputs
......

DEV - connected i2c or serial device opened using device

NUMBYTES - number of bytes to read.

PRECISION - Optional precision for the output data read data. Currently known precision values are uint8 (default), int8, uint16, int16

Outputs
.......

DATA - data read from the device

arduino, device

@device/readRegister
--------------------

 -- DATA =: readRegister (DEV, REG, NUMBYTES)
 -- DATA =: readRegister (DEV, REG, NUMBYTES, PRECISION)
     Read a specified number of bytes from a register of an i2cdev object using optional precision for bytesize.

Inputs
......

DEV - connected i2c device opened using device

REG - registry value number

NUMBYTES - number of bytes to read.

PRECISION - Optional precision for the output data read data. Currently known precision values are uint8 (default), int8, uint16, int16

Output
......

DATA - data read from device.

arduino, device

@device/subsref
---------------

 -- VAL = : subsref (DEV, SUB)
     subref for device

     device

@device/write
-------------

 -- write: (DEV, DATAIN)
 -- write: (DEV, DATAIN, PRECISION)
     Write data to a I2C or serial device object using optional precision for the data byte used for the data.

Inputs
......

DEV - connected i2c or serial device opened using device

DATAIN - data to write to device. Datasize should not exceed the constraints of the data type specified for the precision.

PRECISION - Optional precision for the input write data. Currently known precision values are uint8 (default), int8, uint16, int16

arduino, device, read

@device/writeRead
-----------------

 -- DATAOUT =: readWrite (SPI, DATAIN)
     Write uint8 data to spi device and return back clocked out response data of same size.

Inputs
......

SPI - connected spi device on arduino

DATAIN - uint8 sized data to send to spi device framed between SS frame.

Outputs
.......

DATAOUT - uint8 data clocked out during send to dataIn.

arduino, device

@device/writeRegister
---------------------

 -- writeRegister: (DEV, REG, DATAIN)
 -- writeRegister: (DEV, DEV, DATAIN, PRECISION)
     Write data to i2c device object at a given registry position using optional precision for the data byte used for the data.

Inputs
......

DEV - connected i2c device opened using device

REG - registry position to write to.

DATAIN - data to write to device. Datasize should not exceed the constraints of the data type specified for the precision.

PRECISION - Optional precision for the input write data. Currently known precision values are uint8 (default), int8, uint16, int16

arduino, device, read

Arduino Ultrasonic Functions
============================

@ultrasonic/delete
------------------

 -- delete: (DEV)
     Free resources of a ultrasonic object.

Inputs
......

DEV - ultrasonic object to free

ultrasonic

@ultrasonic/disp
----------------

 -- disp: (DEV)
     Display ultrasonic object.

Inputs
......

DEV - ultrasonic object to display

ultrasonic

@ultrasonic/readDistance
------------------------

 -- DISTANCE =: readDistance (DEV)
     Read the distance from a ultrasonic device

Inputs
......

DEV - connected ultrasonic device opened using ultrasonic

Outputs
.......

DISTANCE - distance value in meters from the ultrasonic device, or Inf if out of sensor range

arduino, ultrasonic

@ultrasonic/readEchoTime
------------------------

 -- TIME =: readEchoTime (DEV)
     Measure the time for waves to reflect back to the ultrasonic device

Inputs
......

DEV - connected ultrasonic device opened using ultrasonic()

Outputs
.......

TIME - time in seconds, or Inf if out of sensor range

arduino, ultrasonic

@ultrasonic/subsref
-------------------

 -- VAL = : subsref (DEV, SUB)
     subref for ultrasonic

     ultrasonic

@ultrasonic/ultrasonic
----------------------

 -- DEV =: ultrasonic (AR, TRIGGERPIN)
 -- DEV =: ultrasonic (AR, TRIGGERPIN, ECHOPIN)
 -- DEV =: ultrasonic (AR, TRIGGERPIN, ECHOPIN, PROPNAME, PROPVALUE)
     Create an ultrasonic object to communicate to a connected ultrasonic device

Inputs
......

AR - connected arduino object

TRIGGERPIN - trigger pin for attached device.

ECHOPIN - trigger pin for attached device.

PROPNAME, PROPVALUE - property name/value pair for values to pass to devices.

Currently known properties:

outputformat
     string designating number format for output ('double')

Outputs
.......

DEV - created ultrasonic object

Properties
..........

The ultrasonic object has the following public properties:

parent
     The parent (arduino) for this device

pins
     pins used by this object

triggerpin
     trigger used for created object

echopin
     Echo pin set for object

outputformat
     Output format for the created object

arduino, readDistance, readEchoTime

Arduino Addons
==============

addon
-----

 -- RETVAL =: addon (AR, ADDONNAME)
 -- RETVAL =: addon (AR, ADDONNAME, varargs)
     Create an addon object using the addon named class.

Inputs
......

AR - connected arduino object

ADDONNAME - the name of the addon to create. The addon name can be a user addon or an inbuilt addon, however must appear in the listArduinoLibraries output and have been programmed onto the arduino.

VARARGS - optional values that will be provided verbatim to the the addon class constructor.

Outputs
.......

RETVAL - cell array of string library names.

arduino, arduinosetup, listArduinoLibraries

arduinoioaddons.EEPRomAddon.EEPRom
----------------------------------

 -- arduinoioaddons.EEPRomAddon.EEPRom:
     EEPROM addon for arduino

     Allows read and write of uint8 data to the onboard arduino EEPROM.

Example
.......

Assuming eeprom addon has been programmed into the Arduino:

      a = arduino ();
      e = addon (a, "eepromaddon/eeprom");
      write (e, 0, uint8("hello world"));
      str = uint8( read(e, 0, 11) )

addon

Properties
..........

LENGTH - Size of the EEPROM.

Methods
-------

 -- EEPROM =: EEPRom ()
     Constructor to create EEPROM device.

Outputs
.......

EEPROM - created EEPROM device.

 -- erase: ()
     Erase all values in EEPROM (Effectively setting the 0xFF)

 -- write: (ADDRESS, UINTDATA)
     Write data to EEPROM at the provided address.

Inputs
......

ADDRESS - start address to write data to, should be an integer between 0 and the size of the EEPROM.

UINTDATA a value or array of uint8 data to write to EEPROM.

 -- DATA =: read (ADDRESS)
 -- DATA =: read (ADDRESS, COUNT)
     Read data from starting address of EEPROM.

Inputs
......

ADDRESS - start address to read data from, should be an integer between 0 and the size of the EEPROM.

COUNT - Number of uint8 values to read from the EEPROM (default is 1)

Outputs
.......

DATA a value or array of uint8 data read from the EEPROM.

arduinoioaddons.ExampleAddon.Echo
---------------------------------

 -- arduinoioaddons.ExampleAddon.Echo:
     Basic Example matlab/octave code to illustrate creating a user addon.

     addon

Properties
..........

PARENT - the parent arduino object.

PINS - the pins allocated the addon.

Methods
-------

 -- OBJ =: Echo(arObj)
     Constructor to create Echo addon

Inputs
......

AROBJ - the arduino parent object

Outputs
.......

OBJ - created Echo object

 -- RESPONSE = : shout(TEXT)
     Send text to arduino and receive back the echoed reply

Inputs
......

TEXT - text to send to arduino

Outputs
.......

RESPONSE - response from the arduino, which should be the same as the input text.

arduinoioaddons.ExampleLCD.LCD
------------------------------

 -- arduinoioaddons.LCDAddon.LCD:
     Basic Example octave addon for LCD

     Allows basic manipulation of an LCD as a illustration of using the addon functionality.

Example
.......

Assuming the arduino has been programmed with the lcd addon:

      a = arduino();
      lcd = addon(a, "examplelcd/lcd", "d8", "d9", "d4", "d5", "d6", "d7")
      clearLCD(lcd);
      printLCD(lcd, "Hello");
      # go to next line
      gotoLCD(lcd, 0, 1);
      printLCD(lcd, "World");

addon

Properties
..........

PINS - the pins allocated the LCD display.

Methods
-------

 -- LCD =: LCD(arObj, rs, enable, d0, d1, d2, d3)
     Constructor to create LCD device

Inputs
......

AROBJ - the arduino parent object

RS - the pin to use for the rs line.

ENABLE - the pin to use for the enable line.

D0 - the pin to use for the d0 line.

D1 - the pin to use for the d1 line.

D2 - the pin to use for the d2 line.

D3 - the pin to use for the d3 line.

Outputs
.......

LCD - created LCD object

 -- freeLCD():
     Free the LCD

     Should be called before discarding the LCD

Inputs
......

None.

Outputs
.......

None.

 -- clearLCD():
     Clear the LCD display and set the cursor position to the home position.

Inputs
......

None.

Outputs
.......

None.

 -- printLCD(TEXT):
     Display text on LCD starting at the current cursor position.

Inputs
......

TEXT - text to display on LCD

Outputs
.......

None.

 -- gotoLCD(COL,: ROW)
     Set the cursor position to row, col

Inputs
......

COL - 0 indexed LCD column to position to.

ROW - 0 indexed LCD row to position to.

Outputs
.......

None.

arduinoioaddons.RTCAddon.DS1307
-------------------------------

 -- arduinoioaddons.RTCAddon.DS1307:
     DS1307 addon

     addon

Properties
..........

PARENT - the parent arduino object.

PINS - the pins allocated the addon.

Methods
-------

 -- OBJ =: DS1307(AROBJ)
 -- OBJ =: DS1307(AROBJ, PROPERTYNAME, PROPERTYVALUE ....)
     Constructor to create DS1307 addon

Inputs
......

AROBJ - the arduino parent object

PROPERTYNAME, PROPERTYVALUE - optional property name, value pairs. Current known properties are:

address
     I2C address of the DS1307 (default 0x68)

Outputs
.......

OBJ - created DS1307 object

Example
.......

     {
      a = arduino()
      rtc = addon(a, "rtcaddon/ds1307")
      }

 -- DATE =: clock(DSOBJ)
 -- clock(DSOBJ,: DATE)
     Get/set the DS1307 clock

Inputs
......

DSOBJ - the ds1307 object

DATE - a date vector in same format as datevec and clock

Outputs
.......

DATE - a date vector in same format as datevec and clock

Example
.......

     {
      a = arduino()
      rtc = addon(a, "rtcaddon/ds1307")
      # get and display rtc time as a date string
      datestr(rtc.clock)
      }

datevec

 -- CTRL =: control(DSOBJ)
 -- control(DSOBJ,: CTRL)
     Get/set the DS1307 clock

Inputs
......

DSOBJ - the ds1307 object

CTRL - a structure containing the control bit fields.

Outputs
.......

CTRL - a structure containing the control bit fields.

Control structure fields are: Current properties are:

out
     Out bit in the control register

sqwe
     Square wave enable bit in control register

rs
     The combined RS0, RS1 value

 -- YN =: isstarted(DSOBJ)
     Get whether the RTC clock is currently counting time

Inputs
......

DSOBJ - the ds1307 object

Outputs
.......

YN - returns true if the RTC is counting

start, stop

 -- start(DSOBJ):
     Start the RTC counting

Inputs
......

DSOBJ - the ds1307 object

Outputs
.......

None

datevec

 -- stop(DSOBJ):
     Stop the RTC counting

Inputs
......

DSOBJ - the ds1307 object

Outputs
.......

None

datevec

arduinoioaddons.SimpleStepper.SimpleStepper
-------------------------------------------

 -- arduinoioaddons.SimpleStepper:
     Stepper class for stepper control using ULN2003 and compatible drivers

Properties
..........

ID
     Id of the stepper (Read only)

SPEED
     Number of steps to do per second.

Status
     Status of stepper (Read only). 0 = not moving, 1 = moving, 2 = rotating

Parent
     the Arduino parent (read only)

Pins
     the pins used for the stepper (read only)

Methods
-------

 -- OBJ =: SimpleStepper(AOBJ, PIN1, PIN2, PIN3, PIN4)
 -- OBJ =: SimpleStepper(AOBJ, PIN1, PIN2, PIN3, PIN4, PIN5)
     Constructor to create a stepper object

Inputs
......

AOBJ - The arduino

PIN1 - The first pin of the controller

PIN2 - The second pin of the controller

PIN3 - The third pin of the controller

PIN4 - The fourth pin of the controller

PIN5 - The fifth pin of the controller

Outputs
.......

S - a simplestepper object

Example
.......

     {
      a = arduino()
      # create stepper object
      s = addon(a, "simplestepper/simplestepper", "d2", "d3", "d4", "d5")
      # start rotating left
      s.rotate(-1);
      }

addon

 -- move(SOBJ,: STEPS)
     Move the motor the specified number of steps using the configured Speed.

Inputs
......

SOBJ - the stepper object

STEPS - the number of steps to move. steps less than 0 will be moving left.

Outputs
.......

None

rotate

 -- rotate(SOBJ,: DIR)
     Start steppermotor moving in the specified direction using the configured Speed.

Inputs
......

SOBJ - the stepper object

DIR - Direction to move. -1 = left, 0 = stop, 1 = right.

Outputs
.......

None

move

 -- release(SOBJ):
     Release this stepper motor

Inputs
......

SOBJ - the stepper object

Outputs
.......

None

arduinoioaddons.adafruit.dcmotorv2
----------------------------------

 -- arduinoioaddons.adafruit.dcmotorv2:
     DC Motor class for dc motor control on the adafruit motor shield

     arduinoioaddons.adafruit.motorshieldv2

Properties
..........

SPEED - The speed value set for the motor

PARENT - The parent shield for object (read only)

MOTORNUMBER - The motor number (read only) values 1-4

ISRUNNING - boolean for if the motor is started (read only)

Methods
-------

 -- OBJ =: dcmotorv2(MOBJ, MNUM)
 -- OBJ =: dcmotorv2(MOBJ, MNUM, PROPERTYNAME, PROPERTYVALUE ....)
     Constructor to create dcmotor object

Inputs
......

MOBJ - the motor shield object

MNUM - The motor number (1 - 4)

PROPERTYNAME, PROPERTYVALUE - Optional property name/value pairs to pass to motor object.

Current known properties are:

Speed
     Initial speed (default 0). Should be a value between -1 and 1.

Outputs
.......

S - a dcmotorv2 object

Example
.......

     {
      a = arduino()
      ms = addon(a, "adafruit/motorshieldv2")
      mtr = dcmotor(ms, 1)
      }

 -- start(DCOBJ):
     Start the motor moving in previously set speed/direction

Inputs
......

DCOBJ - the dcmotor object

Outputs
.......

None

adafruit.motorshieldv2

 -- stop(DCOBJ):
     Stop the motor moving

Inputs
......

DCOBJ - the dcmotor object

Outputs
.......

None

adafruit.motorshieldv2

arduinoioaddons.adafruit.motorshieldv2
--------------------------------------

 -- arduinoioaddons.adafruit.motorshieldv2:
     Adafruit motor shield addon

     addon

Properties
..........

PARENT - the parent arduino object.

PINS - the pins allocated the addon.

I2CADDRESS - the i2c address used for accessing this shield.

PWMFREQUENCY - the set PWM frequency for this shield.

Methods
-------

 -- OBJ =: motorshieldv2(AROBJ)
 -- OBJ =: motorshieldv2(AROBJ, PROPERTYNAME, PROPERTYVALUE ....)
     Constructor to create motorshieldv2 addon object

Inputs
......

AROBJ - the arduino parent object

PROPERTYNAME, PROPERTYVALUE - optional property name, value pairs. Current known properties are:

address
     I2C address of the motor shield  (default 0x60)

pwmfrequency
     PWM Frequency to set on shield  (default 1600)

Outputs
.......

OBJ - created  motorshieldv2 object

Example
.......

     {
      a = arduino()
      mtr = addon(a, "adafruit/motorshieldv2")
      }

 -- S =: servo(MOBJ, MTRNUM)
 -- S =: servo(MOBJ, MTRNUM, PROPERTYNAME, PROPERTYVALUE ...)
     Create a servo object

Inputs
......

MOBJ - the motor shield object

MTRNUM - The servo motor number, where 1 is servo on pin "d10" and 2 is a servo on pin "d9"

PROPERTYNAME, PROPERTYVALUE - Optional property name/value pairs to pass to servo object.

Properties are the same as the base servo object.

Outputs
.......

S - a servo object

Example
.......

     {
      a = arduino()
      ms = addon(a, "adafruit/motorshieldv2")
      # get servo 1 (servo on pin D10)
      s = ms.servo(1)
      }

The function if the equivalent of calling the arduino.servo with the D9 or D10 pin has the input pin.

servo

 -- S =: stepper(MOBJ, MTRNUM, STEPSPERREV)
 -- S =: stepper(MOBJ, MTRNUM, STEPSPERREV, PROPERTYNAME, PROPERTYVALUE ...)
     Create a stepper motor object

Inputs
......

MOBJ - the motor shield object

MTRNUM - The stepper motor number (1 or 2)

STEPSPERREV - Number of steps per revolution.

PROPERTYNAME, PROPERTYVALUE - Optional property name/value pairs to pass to stepper object.

Outputs
.......

S - a stepper object

 -- S =: dcmotor(MOBJ, MTRNUM)
 -- S =: dcmotor(MOBJ, MTRNUM, PROPERTYNAME, PROPERTYVALUE ...)
     Create a dcmotor motor object

Inputs
......

MOBJ - the motor shield object

MTRNUM - The motor number (1 - 4)

PROPERTYNAME, PROPERTYVALUE - Optional property name/value pairs to pass to motor object.

Outputs
.......

S - a dcmotorv2 object

arduinoioaddons.adafruit.stepper
--------------------------------

 -- arduinoioaddons.adafruit.stepper:
     Stepper class for stepper control on the adafruit motor shield

     arduinoioaddons.adafruit.motorshieldv2

Properties
..........

RPM
     The rpm value set for the stepper motor

StepType
     the StepType for the stepper (string) which can be "single", "double", "interleave" or "microstep"

StepsPerRevolution
     the StepsPerRevoluion for the stepper (read only)

MotorNumber
     the motor number for the stepper (read only) value will be 1 or 2.

Parent
     the parent shield of this stepper (read only)

Methods
-------

 -- OBJ =: stepper(MOBJ, MNUM, STEPSPERREV)
 -- OBJ =: stepper(MOBJ, MNUM, STEPSPERREV, PROPERTYNAME, PROPERTYVALUE ....)
     Constructor to create dcmotor object

Inputs
......

MOBJ - the motor shield object

MNUM - The motor number (1 or 2)

STEPSPERREV - Number of steps per revolution.

PROPERTYNAME, PROPERTYVALUE - Optional property name/value pairs to pass to motor object.

Current known properties are:

RPM
     the RPM for the stepper (revolutions per minute)

StepType
     the StepType for the stepper (string) which can be "single", "double", "interleave" or "microstep"

Outputs
.......

S - a stepper object

Example
.......

     {
      a = arduino()
      ms = addon(a, "adafruit/motorshieldv2")
      mtr = stepper(ms, 1, 200)
      }

 -- move(SOBJ,: STEPS)
     Move the motor moving in the specified steps using the configured RPM.

Inputs
......

SOBJ - the stepper object

Outputs
.......

None

adafruit.motorshieldv2

 -- release(SOBJ):
     Release this motor

Inputs
......

SOBJ - the stepper object

Outputs
.......

None

adafruit.motorshieldv2

Arduino Sensors
===============

arduinosensor.DS1307
--------------------

 -- arduinosensor.DS1307:
     DS1307 realtime clock sensor

Methods
-------

 -- OBJ =: DS1307(AROBJ)
 -- OBJ =: DS1307(AROBJ, PROPERTYNAME, PROPERTYVALUE ....)
     Constructor to create DS1307 sensor

Inputs
......

AROBJ - the arduino parent object

PROPERTYNAME, PROPERTYVALUE - optional property name, value pairs. Current known properties are: Current properties are:

i2caddress
     I2C address of the DS1307 (default 0x68)

Outputs
.......

OBJ - created DS1307 object

Example
.......

     {
      a = arduino()
      rtc = arduinosensor.DS1307(a)
      }

 -- DATE =: clock(DSOBJ)
 -- clock(DSOBJ,: DATE)
     Get/set the DS1307 clock

Inputs
......

DSOBJ - the ds1307 object

DATE - a date vector in same format as datevec and clock

Outputs
.......

DATE - a date vector in same format as datevec and clock

Example
.......

     {
      a = arduino()
      rtc = arduinosensor.DS1307(a)
      # get and display rtc time as a date string
      datestr(rtc.clock)
      }

datevec

 -- CTRL =: control(DSOBJ)
 -- control(DSOBJ,: CTRL)
     Get/set the DS1307 clock

Inputs
......

DSOBJ - the ds1307 object

CTRL - a structure containing the control bit fields.

Outputs
.......

CTRL - a structure containing the control bit fields.

Control structure fields are: Current properties are:

out
     Out bit in the control register

sqwe
     Square wave enable bit in control register

rs
     The combined RS0, RS1 value

 -- YN =: isstarted(DSOBJ)
     Get whether the RTC clock is currently counting time

Inputs
......

DSOBJ - the ds1307 object

Outputs
.......

YN - returns true if the RTC is counting

start, stop

 -- start(DSOBJ):
     Start the RTC counting

Inputs
......

DSOBJ - the ds1307 object

Outputs
.......

None

datevec

 -- stop(DSOBJ):
     Stop the RTC counting

Inputs
......

DSOBJ - the ds1307 object

Outputs
.......

None

datevec

arduinosensor.GUVAS12SD
-----------------------

 -- arduinosensor.GUVAS12SD:
     A thin wrapper for the GUVAS12SD analog UV-B sensor

Methods
-------

 -- OBJ =: GUVAS12SD(AROBJ, PIN)
     Constructor to create GUVAS12SD sensor

Inputs
......

AROBJ - the arduino parent object

PIN - the analog pin that the sensor is connected to

Outputs
.......

OBJ - created GUVAS12SD object

Example
.......

     {
      a = arduino()
      # create sensor attached to pin a0.
      sensor = arduinosensor.GUVAS12SD(a, "a0")
      }

 -- V =: read(DSOBJ)
     Read the voltage of the sensor

Inputs
......

DSOBJ - the GUVAS12SD object

Outputs
.......

V - read voltage - effectively equivalent to readAnalogPin(arObj, pin).

Example
.......

     {
      a = arduino()
      s = arduinosensor.GUVAS12SD(a)
      # voltage
      volts = s.read
      }

arduinosensor.GUVAS12SD

 -- IDX =: readIndex(DSOBJ)
     Read the UV index

Inputs
......

DSOBJ - the GUVAS12SD object

Outputs
.......

IDX - the sensor reading as a UV index reading

 -- UA =: readuA(DSOBJ)
     Read the uA of the sensor

Inputs
......

DSOBJ - the GUVAS12SD object

Outputs
.......

UA - the sensor reading as a uAmp value

arduinosensor.MPC3002
---------------------

 -- arduinosensor.MPC3002:
     MCP3002 ADC sensor

Methods
-------

 -- OBJ =: MPC3002(AROBJ, SELECTPIN)
 -- OBJ =: MPC3002(AROBJ, SELECTPIN, PROPERTYNAME, PROPERTYVALUE ....)
     Constructor to create MPC3002 sensor

Inputs
......

AROBJ - the arduino parent object

SELECTPIN - the SPI cs select pin

PROPERTYNAME, PROPERTYVALUE - optional property name, value pairs.

Current properties are:

referenceVoltage
     Reference voltage for scaling the ADC inputs (default 5.0)

Outputs
.......

OBJ - created MCP3002 object

Example
.......

     {
      a = arduino()
      sensor = arduinosensor.MPC3002(a, "d10")
      }

 -- VOLTAGE =: readVoltage(DSOBJ, CHAN)
     Read the voltage from a channel

Inputs
......

DSOBJ - the MPC3002 object

CHAN - the channel to read (0 or 1)

Outputs
.......

VOLTAGE - read voltage.

Example
.......

     {
      a = arduino()
      s = arduinosensor.MPC3002(a, "d10")
      volts = readVoltage(s, 0)
      }

arduinosensor.MPC3002

arduinosensor.SI7021
--------------------

 -- arduinosensor.SI7021:
     SI7021 temperature and humidity sensor

Methods
-------

 -- OBJ =: SI7021(AROBJ)
 -- OBJ =: SI7021(AROBJ, PROPERTYNAME, PROPERTYVALUE ....)
     Constructor to create SI7021 sensor

Inputs
......

AROBJ - the arduino parent object

PROPERTYNAME, PROPERTYVALUE - optional property name, value pairs. Current known properties are: Current properties are:

i2caddress
     I2C address of the SI7021 (default 0x40)

Outputs
.......

OBJ - created SI7020 object

Example
.......

     {
      a = arduino()
      sensor = arduinosensor.SI7021(a)
      }

 -- C =: temperature(DSOBJ)
     Read the temperature

Inputs
......

DSOBJ - the si7021 object

Outputs
.......

C - read temperature in deg C.

Example
.......

     {
      a = arduino()
      s = arduinosensor.SI7021(a)
      # get temp
      temp = s.temperature
      }

arduinosensor.SI7021

 -- RELH =: humidity(DSOBJ)
     Read the relative humidity

Inputs
......

DSOBJ - the si7021 object

Outputs
.......

RELH - relative humidity as a percentage (0 - 100.0)

 -- RELH =: info(DSOBJ)
     Read the sensor info

Inputs
......

DSOBJ - the si7021 object

Outputs
.......

INF - structure containing the sensor information.

Structure fields are:

version
     Chip firmware version

id
     sensor id1,id2 value

type
     String for detected chip type

Arduino I/O package
===================

arduinoio.AddonBase
-------------------

 -- arduinoio.AddonBase:
     Base class used for arduino library sensors

     arduinoio.LibraryBase

Properties
----------

Base properties are expected to be inherited and overwritten in inherited classes. and are constant in order to query through the metaobject mechanism.

PARENT - parent librarybase object

Methods
-------

 -- AB =: AddonBase ()
     Constructor of base class

Outputs
.......

The return value AB is an object of the arduinio.AddonBase class.

arduino, addon

 -- disp: ()
     Display the addon in a verbose way.

arduinoio.FilePath
------------------

 -- RETVAL =: arduinoio.FilePath (FULLPATHNAME)
     Get the directory component of a pathname.

Inputs
......

FULLPATHNAME filepath to get directory component of.

Outputs
.......

RETVAL the directory part of the filename.

arduinoio.LibFiles
------------------

 -- FILELIST =: arduinoio.LibFiles ()
     Get the list of files used for the building arduino library

Outputs
.......

FILELIST - string cell array of files for the arduino project

arduinoio.LibraryBase
---------------------

 -- arduinoio.LibraryBase:
     Base class used for arduino library plugins

     arduino, listArduinoLibraries, addon

Properties
----------

Base properties are expected to be inherited and overwritten in inherited classes and are constant in order to query through the metaobject mechanism.

LIBRARYNAME - name of the addon library

DEPENDENTLIBRARIES - array of dependent library names that must be included when installing this plugin.

CPPHEADERFILE - name (if any) of header file that will be included into the arduino project when adding this library.

CPPSOURCEFILE - name (if any) of source file that will be included into the arduino project when adding this library.

CPPCLASSNAME - name of the cpp class for the addon library. project when adding this library.

PINS - pins allocated to the addon

PARENT - parent arduino object.

Methods
-------

 -- LB =: LibraryBase ()
     Constructor of base class

     The constructor is usually not called but called indirectly from the addon function.

Outputs
.......

The return value LB is an object of the arduinio.LibraryBase class.

arduino, listArduinoLibraries, addon

 -- disp: ()
     Display the addon in a verbose way.

arduinoio.getBoardConfig
------------------------

 -- RETVAL =: arduinoio.getBoardConfig (BOARDNAME)
     Return the configuration for a known arduino board type

     Function is used to get the expected pin/board configuration for a named board type which is used to verify and identify the functionality of the board.

Inputs
......

BOARDNAME - name of board to get configuration of ie: "uno"

Outputs
.......

RETVAL configuration struct.

Matlab Compatibility Classes
============================

matlabshared.addon.LibraryBase
------------------------------

 -- matlabshared.addon.LibraryBase:
     Compatability class used for arduino library plugins using matlabshared.addons.LibraryBase

     arduinoio.LibraryBase, arduino, listArduinoLibraries, addon

Properties
----------

Base properties are expected to be inherited and overwritten in inherited classes and are constant in order to query through the metaobject mechanism.

LIBRARYNAME - name of the addon library

DEPENDENTLIBRARIES - array of dependent library names that must be included when installing this plugin.

CPPHEADERFILE - name (if any) of header file that will be included into the arduino project when adding this library.

CPPSOURCEFILE - name (if any) of source file that will be included into the arduino project when adding this library.

CPPCLASSNAME - name of the cpp class for the addon library. project when adding this library.

PINS - pins allocated to the addon

PARENT - parent arduino object.

Methods
-------

 -- LB =: LibraryBase ()
     Constructor of base class

     The constructor is usually not called but called indirectly from the addon function.

Outputs
.......

The return value LB is an object of the matlabshare.addons.LibraryBase class.

arduino, listArduinoLibraries, addon

 -- disp: ()
     Display the addon in a verbose way.

Sensors
=======

bme280
------

 -- bme280:
     BME280 pressure, temperature and humidity sensor

Methods
-------

 -- OBJ =: bme280(AROBJ)
 -- OBJ =: bme280(AROBJ, PROPERTYNAME, PROPERTYVALUE ....)
     Constructor to create BME280 sensor

Inputs
......

AROBJ - the arduino parent object

PROPERTYNAME, PROPERTYVALUE - optional property name, value pairs. Current known properties are: Current properties are:

I2CAddress
     I2C address of the sensor (default 0x40)

Bus
     I2C bus  - 0 or 1 (default 0)

Outputs
.......

OBJ - created object

Example
.......

     {
      a = arduino()
      sensor = bme280(a)
      }

 -- [C, TIMESTAMP] =: readTemperature(OBJ)
     Read the temperature

Inputs
......

OBJ - the sensor object

Outputs
.......

C - read temperature in deg C.

TIMESTAMP - timestamp when read

Example
.......

     {
      a = arduino()
      s = bme280(a)
      # get temp
      temp = s.readTemperature
      }

bme280

 -- [RELH, TIMESTAMP] =: readHumidity(OBJ)
     Read the relative humidity

Inputs
......

OBJ - the sensor object

Outputs
.......

RELH - relative humidity as a percentage (0 - 100.0)

TIMESTAMP - timestamp when read

 -- [P, TIMESTAMP] =: readPressure(OBJ)
     Read the pressure

Inputs
......

OBJ - the sensor object

Outputs
.......

P - pressure reading from sensor.

TIMESTAMP - timestamp when read

 -- [READINGS, OVERRUN] =: read(OBJ)
 -- [P, H, C, TIMESTAMP, OVERRUN] =: read(OBJ)
     Read the sensor data

Inputs
......

OBJ - the sensor object

Outputs
.......

P - pressure reading from sensor.

H - humidity reading from sensor.

C - temperature reading from sensor.

TIMESTAMP - timestamp when read

OVERRUN - overrun flag.

READINGS - table structure with fields for Timestamp, Pressure, Temperature and Humidity.

 -- INF =: info(OBJ)
     Read the sensor info

Inputs
......

OBJ - the sensor object

Outputs
.......

INF - structure containing the sensor information.

Structure fields are:

Version
     Chip firmware version

SensorId
     sensor id value

Type
     sensor type 'bme280'

Status
     Status value read from sensor

 -- flush(OBJ):
     Flush sensor data

Inputs
......

OBJ - the sensor object

Outputs
.......

None

 -- release(OBJ):
     Release the resources of the sensor

Inputs
......

OBJ - the sensor object

Outputs
.......

None

bno055
------

 -- bno055:
     BNO055 9 axis orientation sensor

Methods
-------

 -- OBJ =: bno055(AROBJ)
 -- OBJ =: bno055(AROBJ, PROPERTYNAME, PROPERTYVALUE ....)
     Constructor to create BME280 sensor

Inputs
......

AROBJ - the arduino parent object

PROPERTYNAME, PROPERTYVALUE - optional property name, value pairs. Current known properties are: Current properties are:

I2CAddress
     I2C address of the sensor (default 0x40)

Bus
     I2C bus  - 0 or 1 (default 0)

OperatingMode
     Operating mode 'ndof' or 'amg'

Outputs
.......

OBJ - created object

Example
.......

     {
      a = arduino()
      sensor = bno055(a)
      }

 -- [C, TIMESTAMP] =: readTemperature(OBJ)
     Read the temperature

Inputs
......

OBJ - the sensor object

Outputs
.......

C - read temperature in deg C.

TIMESTAMP - timestamp when read

Example
.......

     {
      a = arduino()
      s = bno055(a)
      # get temp
      temp = s.readTemperature
      }

bno055

 -- [READVAL, TIMESTAMP] =: readAcceleration(OBJ)
     Read the acceleration rate

Inputs
......

OBJ - the sensor object

Outputs
.......

READVAL - the 3 acceleration values

TIMESTAMP - timestamp when read

 -- [READVAL, TIMESTAMP] =: readAngularVelocity(OBJ)
     Read the angular velocity

Inputs
......

OBJ - the sensor object

Outputs
.......

READVAL - the 3 angular velocity values

TIMESTAMP - timestamp when read

 -- [READVAL, TIMESTAMP] =: readMagneticField(OBJ)
     Read the magnetic field components

Inputs
......

OBJ - the sensor object

Outputs
.......

READVAL - the 3 magnetic field values

TIMESTAMP - timestamp when read

 -- [READVAL, TIMESTAMP] =: readOrientation(OBJ)
     Read the oriientation components

Inputs
......

OBJ - the sensor object

Outputs
.......

READVAL - the 3 orientation values

TIMESTAMP - timestamp when read

 -- [READINGS, OVERRUN] =: read(OBJ)
 -- [ACCEL, GYRO, MAG, TIMESTAMP, OVERRUN] =: read(OBJ)
 -- [ACCEL, GYRO, MAG, ORIENTATION, TIMESTAMP, OVERRUN] =: read(OBJ)
     Read the sensor data

Inputs
......

OBJ - the sensor object

Outputs
.......

ACCEL - acceleration reading from sensor.

GYRO - angular acceleration reading from sensor.

MAG - magnetic field reading from sensor.

ORIENTATION - orientation reading from sensor.

TIMESTAMP - timestamp when read

OVERRUN - overrun flag.

READINGS - table structure with fields for Timestamp, Acceleration, AngularVelocity, MagneticField, Orientation.

 -- INF =: readCalibrationStatus(OBJ)
     Read the sensor calibration status

Inputs
......

OBJ - the sensor object

Outputs
.......

STATUS - structure containing the calibration information.

Structure fields are:

System
     System calibrarion

Accelerometer
     Accelerometer calibration status

Gyroscope
     Gyroscope calibration status

Magnetometer
     Magnetometer calibration status

Values for each will be either 'uncalibrated', 'partial' or 'full'.

 -- INF =: info(OBJ)
     Read the sensor info

Inputs
......

OBJ - the sensor object

Outputs
.......

INF - structure containing the sensor information.

Structure fields are:

Version
     Software firmware version

SensorId
     sensor id value

Type
     sensor type 'bno055'

 -- flush(OBJ):
     Flush sensor data

Inputs
......

OBJ - the sensor object

Outputs
.......

None

 -- release(OBJ):
     Release the resources of the sensor

Inputs
......

OBJ - the sensor object

Outputs
.......

None

lis3dh
------

 -- lis3dh:
     LIS3DH 3 degrees sensor

Methods
-------

 -- OBJ =: lis3dh(AROBJ)
 -- OBJ =: lis3dh(AROBJ, PROPERTYNAME, PROPERTYVALUE ....)
     Constructor to create LIS3DH sensor

Inputs
......

AROBJ - the arduino parent object

PROPERTYNAME, PROPERTYVALUE - optional property name, value pairs. Current known properties are: Current properties are:

I2CAddress
     I2C address of the sensor (default 0x40)

Bus
     I2C bus  - 0 or 1 (default 0)

Outputs
.......

OBJ - created object

Example
.......

     {
      a = arduino()
      sensor = lis3dh(a)
      }

 -- [READVAL, TIMESTAMP] =: readAcceleration(OBJ)
     Read the acceleration rate

Inputs
......

OBJ - the sensor object

Outputs
.......

READVAL - the 3 acceleration values

TIMESTAMP - timestamp when read

 -- [READINGS, OVERRUN] =: read(OBJ)
 -- [ACCEL, TIMESTAMP, OVERRUN] =: read(OBJ)
     Read the sensor data

Inputs
......

OBJ - the sensor object

Outputs
.......

ACCEL - acceleration reading from sensor.

TIMESTAMP - timestamp when read

OVERRUN - overrun flag.

READINGS - table structure with fields for Timestamp, Acceleration.

 -- INF =: info(OBJ)
     Read the sensor info

Inputs
......

OBJ - the sensor object

Outputs
.......

INF - structure containing the sensor information.

Structure fields are:

SensorId
     sensor id value

Type
     sensor type 'lis3dh'

Status
     sensor status value

 -- flush(OBJ):
     Flush sensor data

Inputs
......

OBJ - the sensor object

Outputs
.......

None

 -- release(OBJ):
     Release the resources of the sensor

Inputs
......

OBJ - the sensor object

Outputs
.......

None

lps22hb
-------

 -- lps22hb:
     LPS22HB absolute pressure and temperature sensor

Methods
-------

 -- OBJ =: lps22hb(AROBJ)
 -- OBJ =: lps22hb(AROBJ, PROPERTYNAME, PROPERTYVALUE ....)
     Constructor to create LPS22HB sensor

Inputs
......

AROBJ - the arduino parent object

PROPERTYNAME, PROPERTYVALUE - optional property name, value pairs. Current known properties are: Current properties are:

I2CAddress
     I2C address of the sensor (default 0x5C)

Bus
     I2C bus  - 0 or 1 (default 0)

Outputs
.......

OBJ - created object

Example
.......

     {
      a = arduino()
      sensor = lps22hb(a)
      }

 -- [C, TIMESTAMP] =: readTemperature(OBJ)
     Read the temperature

Inputs
......

OBJ - the sensor object

Outputs
.......

C - read temperature in deg C.

TIMESTAMP - timestamp when read

Example
.......

     {
      a = arduino()
      s = lps22hb(a)
      # get temp
      temp = s.readTemperature
      }

lps22hb

 -- [P, TIMESTAMP] =: readPressure(OBJ)
     Read the pressure

Inputs
......

OBJ - the sensor object

Outputs
.......

P - pressure reading from sensor.

TIMESTAMP - timestamp when read

 -- [READINGS, OVERRUN] =: read(OBJ)
 -- [P, C, TIMESTAMP, OVERRUN] =: read(OBJ)
     Read the sensor data

Inputs
......

OBJ - the sensor object

Outputs
.......

P - pressure reading from sensor.

C - temperature reading from sensor.

TIMESTAMP - timestamp when read

OVERRUN - overrun flag.

READINGS - table structure with fields for Timestamp, Pressure, Temperature and Humidity.

 -- INF =: info(OBJ)
     Read the sensor info

Inputs
......

OBJ - the sensor object

Outputs
.......

INF - structure containing the sensor information.

Structure fields are:

Version
     Chip firmware version

SensorId
     sensor id value

Type
     sensor type 'lps22hb'

Status
     Status value read from sensor

 -- flush(OBJ):
     Flush sensor data

Inputs
......

OBJ - the sensor object

Outputs
.......

None

 -- release(OBJ):
     Release the resources of the sensor

Inputs
......

OBJ - the sensor object

Outputs
.......

None

lsm6dso
-------

 -- lsm6dso:
     LSM6DSO 6 degrees sensor

Methods
-------

 -- OBJ =: lsm6dso(AROBJ)
 -- OBJ =: lsm6dso(AROBJ, PROPERTYNAME, PROPERTYVALUE ....)
     Constructor to create LSM6DSO sensor

Inputs
......

AROBJ - the arduino parent object

PROPERTYNAME, PROPERTYVALUE - optional property name, value pairs. Current known properties are: Current properties are:

I2CAddress
     I2C address of the sensor (default 0x40)

Bus
     I2C bus  - 0 or 1 (default 0)

Outputs
.......

OBJ - created object

Example
.......

     {
      a = arduino()
      sensor = lsm6dso(a)
      }

 -- [C, TIMESTAMP] =: readTemperature(OBJ)
     Read the temperature

Inputs
......

OBJ - the sensor object

Outputs
.......

C - read temperature in deg C.

TIMESTAMP - timestamp when read

Example
.......

     {
      a = arduino()
      s = lsm6dso(a)
      # get temp
      temp = s.readTemperature
      }

lsm6dso

 -- [READVAL, TIMESTAMP] =: readAcceleration(OBJ)
     Read the acceleration rate

Inputs
......

OBJ - the sensor object

Outputs
.......

READVAL - the 3 acceleration values

TIMESTAMP - timestamp when read

 -- [READVAL, TIMESTAMP] =: readAngularVelocity(OBJ)
     Read the angular velocity

Inputs
......

OBJ - the sensor object

Outputs
.......

READVAL - the 3 angular velocity values

TIMESTAMP - timestamp when read

 -- [READINGS, OVERRUN] =: read(OBJ)
 -- [ACCEL, GYRO, MAG, TIMESTAMP, OVERRUN] =: read(OBJ)
     Read the sensor data

Inputs
......

OBJ - the sensor object

Outputs
.......

ACCEL - acceleration reading from sensor.

GYRO - angular acceleration reading from sensor.

TIMESTAMP - timestamp when read

OVERRUN - overrun flag.

READINGS - table structure with fields for Timestamp, Acceleration, AngularVelocity.

 -- INF =: info(OBJ)
     Read the sensor info

Inputs
......

OBJ - the sensor object

Outputs
.......

INF - structure containing the sensor information.

Structure fields are:

SensorId
     sensor id value

Type
     sensor type 'lsm6dso'

 -- flush(OBJ):
     Flush sensor data

Inputs
......

OBJ - the sensor object

Outputs
.......

None

 -- release(OBJ):
     Release the resources of the sensor

Inputs
......

OBJ - the sensor object

Outputs
.......

None

mpu6050
-------

 -- mpu6050:
     MPU-6050 6 degrees sensor

Methods
-------

 -- OBJ =: mpu6050(AROBJ)
 -- OBJ =: mpu6050(AROBJ, PROPERTYNAME, PROPERTYVALUE ....)
     Constructor to create MPU-6050 sensor

Inputs
......

AROBJ - the arduino parent object

PROPERTYNAME, PROPERTYVALUE - optional property name, value pairs. Current known properties are: Current properties are:

I2CAddress
     I2C address of the sensor (default 0x40)

Bus
     I2C bus  - 0 or 1 (default 0)

Outputs
.......

OBJ - created object

Example
.......

     {
      a = arduino()
      sensor = mpu6050(a)
      }

 -- [C, TIMESTAMP] =: readTemperature(OBJ)
     Read the temperature

Inputs
......

OBJ - the sensor object

Outputs
.......

C - read temperature in deg C.

TIMESTAMP - timestamp when read

Example
.......

     {
      a = arduino()
      s = mpu6050(a)
      # get temp
      temp = s.readTemperature
      }

mpu6050

 -- [READVAL, TIMESTAMP] =: readAcceleration(OBJ)
     Read the acceleration rate

Inputs
......

OBJ - the sensor object

Outputs
.......

READVAL - the 3 acceleration values

TIMESTAMP - timestamp when read

 -- [READVAL, TIMESTAMP] =: readAngularVelocity(OBJ)
     Read the angular velocity

Inputs
......

OBJ - the sensor object

Outputs
.......

READVAL - the 3 angular velocity values

TIMESTAMP - timestamp when read

 -- [READINGS, OVERRUN] =: read(OBJ)
 -- [ACCEL, GYRO, MAG, TIMESTAMP, OVERRUN] =: read(OBJ)
     Read the sensor data

Inputs
......

OBJ - the sensor object

Outputs
.......

ACCEL - acceleration reading from sensor.

GYRO - angular acceleration reading from sensor.

TIMESTAMP - timestamp when read

OVERRUN - overrun flag.

READINGS - table structure with fields for Timestamp, Acceleration, AngularVelocity.

 -- INF =: info(OBJ)
     Read the sensor info

Inputs
......

OBJ - the sensor object

Outputs
.......

INF - structure containing the sensor information.

Structure fields are:

SensorId
     sensor id value

Type
     sensor type 'mpu6050'

 -- flush(OBJ):
     Flush sensor data

Inputs
......

OBJ - the sensor object

Outputs
.......

None

 -- release(OBJ):
     Release the resources of the sensor

Inputs
......

OBJ - the sensor object

Outputs
.......

None

si7021
------

 -- si7021:
     SI7021 temperature and humidity sensor

Methods
-------

 -- OBJ =: si7021(AROBJ)
 -- OBJ =: si7021(AROBJ, PROPERTYNAME, PROPERTYVALUE ....)
     Constructor to create si7021 sensor

Inputs
......

AROBJ - the arduino parent object

PROPERTYNAME, PROPERTYVALUE - optional property name, value pairs. Current known properties are: Current properties are:

I2Caddress
     I2C address of the si7021 (default 0x40)

Bus
     I2C bus (default 0)

Outputs
.......

OBJ - created SI7020 object

Example
.......

     {
      a = arduino()
      sensor = si7021(a)
      }

 -- [C, TIMESTAMP] =: readTemperature(OBJ)
     Read the temperature

Inputs
......

OBJ - the si7021 object

Outputs
.......

C - read temperature in deg C.

TIMESTAMP - timestamp when read

Example
.......

     {
      a = arduino()
      s = si7021(a)
      # get temp
      temp = s.readTemperature()
      }

si7021

 -- [RELH, TIMESTAMP] =: readHumidity(OBJ)
     Read the relative humidity

Inputs
......

OBJ - the si7021 object

Outputs
.......

RELH - relative humidity as a percentage (0 - 100.0)

TIMESTAMP - timestamp when read

 -- [READINGS, OVERRUN] =: read(OBJ)
 -- [H, C, TIMESTAMP, OVERRUN] =: read(OBJ)
     Read the sensor data

Inputs
......

OBJ - the si2071 sensor object

Outputs
.......

H - humidity reading from sensor.

C - temperature reading from sensor.

TIMESTAMP - timestamp when read

OVERRUN - overrun flag.

READINGS - table structure with fields for Timestamp, Temperature and Humidity.

 -- RELH =: info(DSOBJ)
     Read the sensor info

Inputs
......

DSOBJ - the si7021 object

Outputs
.......

INF - structure containing the sensor information.

Structure fields are:

Version
     Chip firmware version

SensorDd
     sensor id value

Type
     String for detected chip type

 -- flush(OBJ):
     Flush sensor data

Inputs
......

OBJ - the sensor object

Outputs
.......

None

 -- release(OBJ):
     Release the resources of the sensor

Inputs
......

OBJ - the sensor object

Outputs
.......

None

Test Functions
==============

arduino_bistsetup
-----------------

 -- RETVAL =: arduino_bistsetup ()
 -- RETVAL =: arduino_bistsetup (PROPERTYNAME, PROPERTYVALUE)
     Install on an arduino the required core libraries to run the BIST tests

     As part of the setup, the arduino IDE will be opened to allow programming the arduino board.

Inputs
......

PROPERTYNAME, PROPERTYVALUE - A sequence of property name/value pairs can be given to set defaults while programming.

Currently the following properties can be set:

arduinobinary
     The value should be the name/path of the arduino IDE binary for programming. If not specified, the function will attempt to find the binary itself.

debug
     Set the debug flag when checking the arduino

Outputs
.......

RETVAL - return 1 if everything installed ok

arduino, arduinosetup