reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofArduino Class Reference

This is a way to control an Arduino that has had the firmata library loaded onto it, from OF. More...

#include <ofArduino.h>

Public Member Functions

Constructor and Destructor
 ofArduino ()
 
virtual ~ofArduino ()
 
Connect
bool connect (const std::string &device, int baud=57600)
 Opens a serial port connection to the arduino.
 
bool isInitialized () const
 Returns true if a succesfull connection has been established and the Arduino has reported a firmware.
 
bool isArduinoReady ()
 
void disconnect ()
 Closes the serial port connection. Does not turn the Arduino off.
 
Update
void update ()
 Polls data from the serial port, this has to be called periodically.
 
Setup
void sendDigitalPinMode (int pin, int mode)
 Setting a pins mode to ARD_INPUT turns on reporting for the port the pin is on.
 
void sendAnalogPinReporting (int pin, int mode)
 
void setUseDelay (bool bDelay)
 
void setDigitalHistoryLength (int length)
 
void setAnalogHistoryLength (int length)
 
void setStringHistoryLength (int length)
 
void setSysExHistoryLength (int nSysEx)
 
Senders
void sendDigital (int pin, int value, bool force=false)
 
void sendPwm (int pin, int value, bool force=false)
 
void sendSysEx (int command, std::vector< unsigned char > data)
 
bool isAttached ()
 
void sendString (std::string str)
 Send a string to the Arduino.
 
void sendProtocolVersionRequest ()
 
void sendFirmwareVersionRequest ()
 
void sendPinCofigurationRequest ()
 
void sendPinCapabilityRequest ()
 
void sendAnalogMappingRequest ()
 
void sendPinStateQuery (int pin)
 
void sendReset ()
 This will cause your Arduino to reset and boot into the program again.
 
void sendSysExBegin ()
 Sends the FIRMATA_START_SYSEX command.
 
void sendSysExEnd ()
 Sends the FIRMATA_END_SYSEX command.
 
void sendByte (unsigned char byte)
 Sends a byte without wrapping it in a firmata message.
 
void sendValueAsTwo7bitBytes (int value)
 Send value as two 7 bit bytes.
 
Getters
int getPwm (int pin) const
 Returns the last set PWM value (0-255) for the given pin.
 
int getDigital (int pin) const
 Returns the last received value (if the pin mode is ARD_INPUT) or the last set value (if the pin mode is ARD_OUTPUT) for the given pin.
 
int getAnalog (int pin) const
 Returns the analog in value that the pin is currently reading. because the Arduino has a 10 bit ADC you get between 0 and 1023 for possible values.
 
std::vector< unsigned char > getSysEx () const
 
std::string getString () const
 
int getMajorFirmwareVersion () const
 
int getMinorFirmwareVersion () const
 
std::string getFirmwareName () const
 
std::list< int > * getDigitalHistory (int pin)
 Returns a pointer to the digital data history list for the given pin.
 
std::list< int > * getAnalogHistory (int pin)
 Returns a pointer to the analog data history list for the given pin.
 
std::list< std::vector< unsigned char > > * getSysExHistory ()
 
std::list< std::string > * getStringHistory ()
 
int getDigitalPinMode (int pin) const
 Get the pin mode of the given pin.
 
int getAnalogPinReporting (int pin) const
 
int getValueFromTwo7bitBytes (unsigned char lsb, unsigned char msb)
 Useful for parsing SysEx messages.
 
int getInvertedValueFromTwo7bitBytes (unsigned char lsb, unsigned char msb)
 
Servos
void sendServo (int pin, int value, bool force=false)
 Send a value to a servo.
 
void sendServoAttach (int pin, int minPulse=544, int maxPulse=2400)
 
int getServo (int pin) const
 Detaches a servo on a pin.
 
Stepper
void sendStepper2Wire (int dirPin, int stepPin, int stepsPerRev=200)
 – stepper
 
void sendStepper4Wire (int pin1, int pin2, int pin3, int pin4, int stepsPerRev=200)
 the pins has to have a stepper attached
 
void sendStepperMove (int stepperID, int direction, int steps, int speed=0, float acceleration=0, float deceleration=0)
 the pins has to have a stepper attached
 
I2C
void sendI2CConfig (int delay)
 Sends a I2C config request.
 
bool isI2CConfigured ()
 
void sendI2CWriteRequest (char slaveAddress, unsigned char *bytes, int numOfBytes, int reg=-1)
 Asks the arduino to send an I2C request to a device.
 
void sendI2CWriteRequest (char slaveAddress, const char *bytes, int numOfBytes, int reg=-1)
 
void sendI2CWriteRequest (char slaveAddress, char *bytes, int numOfBytes, int reg=-1)
 
void sendI2CWriteRequest (char slaveAddress, std::vector< char > bytes, int reg=-1)
 
void sendI2CReadRequest (char address, int numBytes, int reg=-1)
 Asks the arduino to request bytes from an I2C device.
 
void sendI2ContinuousReadRequest (char address, int numBytes, int reg=-1)
 Initialize a continuous I2C read.
 
OneWire
void sendOneWireConfig (int pin, bool enableParasiticPower)
 Configure the passed pin as the controller in a 1-wire bus.
 
void sendOneWireSearch (int pin)
 Searches for 1-wire devices on the bus.

 
void sendOneWireAlarmsSearch (int pin)
 Searches for 1-wire devices on the bus in an alarmed state.

 
void sendOneWireSearch (char type, int pin)
 
void sendOneWireRead (int pin, std::vector< unsigned char > devices, int numBytesToRead)
 Reads data from a device on the bus.
 
void sendOneWireReset (int pin)
 Resets all devices on the bus.
 
void sendOneWireWrite (int pin, std::vector< unsigned char > devices, std::vector< unsigned char > data)
 Writes data to the bus to be received by the passed device.

 
void sendOneWireDelay (int pin, unsigned int delay)
 Tells firmata to not do anything for the passed amount of ms.
 
void sendOneWireWriteAndRead (int pin, std::vector< unsigned char > devices, std::vector< unsigned char > data, int numBytesToRead)
 Sends the passed data to the passed device on the bus, reads the specified number of bytes.
 
void sendOneWireRequest (int pin, unsigned char subcommand, std::vector< unsigned char > devices, int numBytesToRead, unsigned char correlationId, unsigned int delay, std::vector< unsigned char > dataToWrite)
 
Encoder
void attachEncoder (int pinA, int pinB)
 
void getEncoderPosition (int encoderNum)
 
void getAllEncoderPositions ()
 
void resetEncoderPosition (int encoderNum)
 
void enableEncoderReporting ()
 
void disableEncoderReporting ()
 
void detachEncoder (int encoderNum)
 

Public Attributes

Events
ofEvent< const int > EDigitalPinChanged
 Triggered when a digital pin changes value, the pin that changed is passed as an argument.
 
ofEvent< const int > EAnalogPinChanged
 Triggered when an analog pin changes value, the pin that changed is passed as an argument.
 
ofEvent< const std::vector< unsigned char > > ESysExReceived
 Triggered when a SysEx message that isn't in the extended command set is received, the SysEx message is passed as an argument.
 
ofEvent< const int > EFirmwareVersionReceived
 Triggered when a firmware version is received, the major version is passed as an argument.
 
ofEvent< const int > EInitialized
 Triggered when the firmware version is received upon connect, the major firmware version is passed as an argument. From this point it's safe to send to the Arduino.
 
ofEvent< const std::string > EStringReceived
 Triggered when a string is received, the string is passed as an argument.
 
ofEvent< const Firmata_Stepper_DataEStepperDataReceived
 triggered when a stepper has finished rotating. Returns which stepper has complted its rotation
 
ofEvent< const Firmata_I2C_DataEI2CDataRecieved
 triggered when the I2C bus returns data after a read request
 
ofEvent< const std::vector< Firmata_Encoder_Data > > EEncoderDataReceived
 triggered when the encoder returns data after a read request
 
ofEvent< const Firmata_Serial_DataESerialDataReceived
 triggered when a Serial message is received. Returns which port and its data
 
ofEvent< const std::pair< int, Firmata_Pin_Modes > > EPinStateResponseReceived
 

Serial

void sendSerialConfig (Firmata_Serial_Ports portID, int baud, int rxPin, int txPin)
 Asks the Arduino to configure a hardware or serial port.
 
void serialWrite (Firmata_Serial_Ports port, unsigned char *bytes, int numOfBytes)
 Write an array of bytes to the specified serial port.
 
void serialRead (Firmata_Serial_Ports port, int maxBytesToRead)
 Start continuous reading of the specified serial port.
 
void serialStop (Firmata_Serial_Ports portID)
 Stop continuous reading of the specified serial port.
 
void serialClose (Firmata_Serial_Ports portID)
 Close the specified serial port.
 
void serialFlush (Firmata_Serial_Ports portID)
 Flush the specified serial port.
 
void serialListen (Firmata_Serial_Ports portID)
 For SoftwareSerial only. Only a single SoftwareSerial instance can read data at a time.
 
std::map< int, supportedPinTypesgetPinCapabilities ()
 
int getTotalPins ()
 
int getNumAnalogPins ()
 

Detailed Description

This is a way to control an Arduino that has had the firmata library loaded onto it, from OF.

To load firmata onto your Arduino, run the Arduino IDE, open the Examples > Firmata > StandardFirmata sketch, and upload it to the Arduino board.

Once the ofArduino instance returns true from isArduinoReady() you can set the mode of the different digital pins using sendDigitalPinMode()

This sets pin 9 to input so that it can read a button press

void sendDigitalPinMode(int pin, int mode)
Setting a pins mode to ARD_INPUT turns on reporting for the port the pin is on.
Definition ofArduino.cpp:412
#define ARD_INPUT
Definition ofArduino.h:84

This sets pin 9 to be a PWM out pin. Note that this only works on pins that are PWM enabled.

#define ARD_PWM
Definition ofArduino.h:87

Constructor & Destructor Documentation

◆ ofArduino()

ofArduino::ofArduino ( )

◆ ~ofArduino()

ofArduino::~ofArduino ( )
virtual

Member Function Documentation

◆ attachEncoder()

void ofArduino::attachEncoder ( int  pinA,
int  pinB 
)

◆ connect()

bool ofArduino::connect ( const std::string &  device,
int  baud = 57600 
)

Opens a serial port connection to the arduino.

Parameters
deviceThe name of the device. You can get the name from the Arduino IDE
baudThe baud rate the connection uses

◆ detachEncoder()

void ofArduino::detachEncoder ( int  encoderNum)

◆ disableEncoderReporting()

void ofArduino::disableEncoderReporting ( )

◆ disconnect()

void ofArduino::disconnect ( )

Closes the serial port connection. Does not turn the Arduino off.

◆ enableEncoderReporting()

void ofArduino::enableEncoderReporting ( )

◆ getAllEncoderPositions()

void ofArduino::getAllEncoderPositions ( )

◆ getAnalog()

int ofArduino::getAnalog ( int  pin) const

Returns the analog in value that the pin is currently reading. because the Arduino has a 10 bit ADC you get between 0 and 1023 for possible values.

Parameters
pinThe pin number (0-5)

◆ getAnalogHistory()

list< int > * ofArduino::getAnalogHistory ( int  pin)

Returns a pointer to the analog data history list for the given pin.

Parameters
pinThe Arduino Uno pin: 0-5

◆ getAnalogPinReporting()

int ofArduino::getAnalogPinReporting ( int  pin) const
Returns
ARD_ON or ARD_OFF

◆ getDigital()

int ofArduino::getDigital ( int  pin) const

Returns the last received value (if the pin mode is ARD_INPUT) or the last set value (if the pin mode is ARD_OUTPUT) for the given pin.

Returns whether the pin is reading high or low, 1 or 0. You can test against this with an if() statement which is handy:

if(arduino.getDigital(pin)){
// do something on high
} else {
// do something on low
}
Note
Pin 16-21 can also be used if analog inputs 0-5 are used as digital pins

◆ getDigitalHistory()

list< int > * ofArduino::getDigitalHistory ( int  pin)

Returns a pointer to the digital data history list for the given pin.

Note
Pin 16-21 can also be used if analog inputs 0-5 are used as digital pins
Parameters
pinThe pin number (2-13)

◆ getDigitalPinMode()

int ofArduino::getDigitalPinMode ( int  pin) const

Get the pin mode of the given pin.

Returns
ARD_INPUT, ARD_OUTPUT, ARD_PWM, ARD_SERVO, ARD_ANALOG

◆ getEncoderPosition()

void ofArduino::getEncoderPosition ( int  encoderNum)

◆ getFirmwareName()

string ofArduino::getFirmwareName ( ) const
Returns
the name of the firmware.

◆ getInvertedValueFromTwo7bitBytes()

int ofArduino::getInvertedValueFromTwo7bitBytes ( unsigned char  lsb,
unsigned char  msb 
)

◆ getMajorFirmwareVersion()

int ofArduino::getMajorFirmwareVersion ( ) const
Returns
the major firmware version.

◆ getMinorFirmwareVersion()

int ofArduino::getMinorFirmwareVersion ( ) const
Returns
the minor firmware version.

◆ getNumAnalogPins()

int ofArduino::getNumAnalogPins ( )
inline

◆ getPinCapabilities()

std::map< int, supportedPinTypes > ofArduino::getPinCapabilities ( )
inline

◆ getPwm()

int ofArduino::getPwm ( int  pin) const

Returns the last set PWM value (0-255) for the given pin.

The pins mode has to be ARD_PWM

On the Arduino Uno the following pins are supported: 3, 5, 6, 9, 10 and 11

Note
Pin 16-21 can also be used if analog inputs 0-5 are used as digital pins

◆ getServo()

int ofArduino::getServo ( int  pin) const

Detaches a servo on a pin.

Note
sendServoDetach DEPRECATED as of Firmata 2.2
Returns
the last set servo value for a pin if the pin has a servo attached.

◆ getString()

string ofArduino::getString ( ) const
Returns
the last received string.

◆ getStringHistory()

list< string > * ofArduino::getStringHistory ( )
Returns
a pointer to the string history.

◆ getSysEx()

vector< unsigned char > ofArduino::getSysEx ( ) const
Returns
the last received SysEx message.

◆ getSysExHistory()

list< vector< unsigned char > > * ofArduino::getSysExHistory ( )
Returns
a pointer to the SysEx history.

◆ getTotalPins()

int ofArduino::getTotalPins ( )
inline

◆ getValueFromTwo7bitBytes()

int ofArduino::getValueFromTwo7bitBytes ( unsigned char  lsb,
unsigned char  msb 
)

Useful for parsing SysEx messages.

◆ isArduinoReady()

bool ofArduino::isArduinoReady ( )

◆ isAttached()

bool ofArduino::isAttached ( )

◆ isI2CConfigured()

bool ofArduino::isI2CConfigured ( )

◆ isInitialized()

bool ofArduino::isInitialized ( ) const

Returns true if a succesfull connection has been established and the Arduino has reported a firmware.

◆ resetEncoderPosition()

void ofArduino::resetEncoderPosition ( int  encoderNum)

◆ sendAnalogMappingRequest()

void ofArduino::sendAnalogMappingRequest ( )

◆ sendAnalogPinReporting()

void ofArduino::sendAnalogPinReporting ( int  pin,
int  mode 
)

◆ sendByte()

void ofArduino::sendByte ( unsigned char  byte)

Sends a byte without wrapping it in a firmata message.

Data has to be in the 0-127 range. Values > 127 will be interpreted as commands.

◆ sendDigital()

void ofArduino::sendDigital ( int  pin,
int  value,
bool  force = false 
)

◆ sendDigitalPinMode()

void ofArduino::sendDigitalPinMode ( int  pin,
int  mode 
)

Setting a pins mode to ARD_INPUT turns on reporting for the port the pin is on.

Parameters
pinPin on arduino (2-13)
modeARD_INPUT, ARD_OUTPUT, ARD_PWM
Note
Analog pins 0-5 can be used as digitial pins 16-21 but if the mode of one of these pins is set to ARD_INPUT then all analog pin reporting will be turned off

◆ sendFirmwareVersionRequest()

void ofArduino::sendFirmwareVersionRequest ( )

◆ sendI2CConfig()

void ofArduino::sendI2CConfig ( int  delay)

Sends a I2C config request.

Must be called before an I2C Read or Write

Parameters
{number}delay in microseconds to set for I2C Read

◆ sendI2ContinuousReadRequest()

void ofArduino::sendI2ContinuousReadRequest ( char  address,
int  numBytes,
int  reg = -1 
)

Initialize a continuous I2C read.

Parameters
{number}address The address of the I2C device
{number}register Optionally set the register to read from.
{number}numBytes The number of bytes to receive.

◆ sendI2CReadRequest()

void ofArduino::sendI2CReadRequest ( char  address,
int  numBytes,
int  reg = -1 
)

Asks the arduino to request bytes from an I2C device.

Parameters
{number}slaveAddress The address of the I2C device
{number}numBytes The number of bytes to receive.
{function}callback A function to call when we have received the bytes.

◆ sendI2CWriteRequest() [1/4]

void ofArduino::sendI2CWriteRequest ( char  slaveAddress,
char *  bytes,
int  numOfBytes,
int  reg = -1 
)

◆ sendI2CWriteRequest() [2/4]

void ofArduino::sendI2CWriteRequest ( char  slaveAddress,
const char *  bytes,
int  numOfBytes,
int  reg = -1 
)

◆ sendI2CWriteRequest() [3/4]

void ofArduino::sendI2CWriteRequest ( char  slaveAddress,
std::vector< char >  bytes,
int  reg = -1 
)

◆ sendI2CWriteRequest() [4/4]

void ofArduino::sendI2CWriteRequest ( char  slaveAddress,
unsigned char *  bytes,
int  numOfBytes,
int  reg = -1 
)

Asks the arduino to send an I2C request to a device.

Parameters
{number}slaveAddress The address of the I2C device
{Array}bytes The bytes to send to the device

◆ sendOneWireAlarmsSearch()

void ofArduino::sendOneWireAlarmsSearch ( int  pin)

Searches for 1-wire devices on the bus in an alarmed state.

Parameters
pin

◆ sendOneWireConfig()

void ofArduino::sendOneWireConfig ( int  pin,
bool  enableParasiticPower 
)

Configure the passed pin as the controller in a 1-wire bus.

Pass as enableParasiticPower true if you want the data pin to power the bus.

Parameters
pin
enableParasiticPower

◆ sendOneWireDelay()

void ofArduino::sendOneWireDelay ( int  pin,
unsigned int  delay 
)

Tells firmata to not do anything for the passed amount of ms.

For when you need to give a device attached to the bus time to do a calculation.

Parameters
pin

◆ sendOneWireRead()

void ofArduino::sendOneWireRead ( int  pin,
std::vector< unsigned char >  devices,
int  numBytesToRead 
)

Reads data from a device on the bus.

N.b. ConfigurableFirmata will issue the 1-wire select command internally.

Parameters
pin
device
numBytesToRead
callback

◆ sendOneWireRequest()

void ofArduino::sendOneWireRequest ( int  pin,
unsigned char  subcommand,
std::vector< unsigned char >  devices,
int  numBytesToRead,
unsigned char  correlationId,
unsigned int  delay,
std::vector< unsigned char >  dataToWrite 
)

◆ sendOneWireReset()

void ofArduino::sendOneWireReset ( int  pin)

Resets all devices on the bus.

Parameters
pin

◆ sendOneWireSearch() [1/2]

void ofArduino::sendOneWireSearch ( char  type,
int  pin 
)

◆ sendOneWireSearch() [2/2]

void ofArduino::sendOneWireSearch ( int  pin)

Searches for 1-wire devices on the bus.

Parameters
pin

◆ sendOneWireWrite()

void ofArduino::sendOneWireWrite ( int  pin,
std::vector< unsigned char >  devices,
std::vector< unsigned char >  data 
)

Writes data to the bus to be received by the passed device.

The device should be obtained from a previous call to sendOneWireSearch. ConfigurableFirmata will issue the 1-wire select command internally.

Parameters
pin
device
data

◆ sendOneWireWriteAndRead()

void ofArduino::sendOneWireWriteAndRead ( int  pin,
std::vector< unsigned char >  devices,
std::vector< unsigned char >  data,
int  numBytesToRead 
)

Sends the passed data to the passed device on the bus, reads the specified number of bytes.

ConfigurableFirmata will issue the 1-wire select command internally.

Parameters
pin
device
data
numBytesToRead
callback

◆ sendPinCapabilityRequest()

void ofArduino::sendPinCapabilityRequest ( )

◆ sendPinCofigurationRequest()

void ofArduino::sendPinCofigurationRequest ( )

◆ sendPinStateQuery()

void ofArduino::sendPinStateQuery ( int  pin)

◆ sendProtocolVersionRequest()

void ofArduino::sendProtocolVersionRequest ( )

◆ sendPwm()

void ofArduino::sendPwm ( int  pin,
int  value,
bool  force = false 
)

◆ sendReset()

void ofArduino::sendReset ( )

This will cause your Arduino to reset and boot into the program again.

◆ sendSerialConfig()

void ofArduino::sendSerialConfig ( Firmata_Serial_Ports  portID,
int  baud,
int  rxPin,
int  txPin 
)

Asks the Arduino to configure a hardware or serial port.

Parameters
portIDThe serial port to use (HW_SERIAL1, HW_SERIAL2, HW_SERIAL3, SW_SERIAL0, SW_SERIAL1, SW_SERIAL2, SW_SERIAL3)
baudThe baud rate of the serial port
rxPin[SW Serial only] The RX pin of the SoftwareSerial instance
txPin[SW Serial only] The TX pin of the SoftwareSerial instance

◆ sendServo()

void ofArduino::sendServo ( int  pin,
int  value,
bool  force = false 
)

Send a value to a servo.

A servo has to be atached to the pin prior

Parameters
pin9 or 10
valueThe value to send

◆ sendServoAttach()

void ofArduino::sendServoAttach ( int  pin,
int  minPulse = 544,
int  maxPulse = 2400 
)
Parameters
angleparameter DEPRECATED as of Firmata 2.2

◆ sendStepper2Wire()

void ofArduino::sendStepper2Wire ( int  dirPin,
int  stepPin,
int  stepsPerRev = 200 
)

– stepper

◆ sendStepper4Wire()

void ofArduino::sendStepper4Wire ( int  pin1,
int  pin2,
int  pin3,
int  pin4,
int  stepsPerRev = 200 
)

the pins has to have a stepper attached

◆ sendStepperMove()

void ofArduino::sendStepperMove ( int  stepperID,
int  direction,
int  steps,
int  speed = 0,
float  acceleration = 0,
float  deceleration = 0 
)

the pins has to have a stepper attached

◆ sendString()

void ofArduino::sendString ( std::string  str)

Send a string to the Arduino.

Note
Firmata can not handle strings longer than 12 characters.

◆ sendSysEx()

void ofArduino::sendSysEx ( int  command,
std::vector< unsigned char >  data 
)

◆ sendSysExBegin()

void ofArduino::sendSysExBegin ( )

Sends the FIRMATA_START_SYSEX command.

◆ sendSysExEnd()

void ofArduino::sendSysExEnd ( )

Sends the FIRMATA_END_SYSEX command.

◆ sendValueAsTwo7bitBytes()

void ofArduino::sendValueAsTwo7bitBytes ( int  value)

Send value as two 7 bit bytes.

Sends a value as two 7-bit bytes without wrapping it in a firmata message. Values in the range 0 - 16384 will be sent as two bytes within the 0-127 data range.

Parameters
valueThe value to send.

◆ serialClose()

void ofArduino::serialClose ( Firmata_Serial_Ports  portID)

Close the specified serial port.

Parameters
portIdThe serial port to close.

◆ serialFlush()

void ofArduino::serialFlush ( Firmata_Serial_Ports  portID)

Flush the specified serial port.

For hardware serial, this waits for the transmission of outgoing serial data to complete.For software serial, this removed any buffered incoming serial data.

Parameters
portIdThe serial port to listen on.

◆ serialListen()

void ofArduino::serialListen ( Firmata_Serial_Ports  portID)

For SoftwareSerial only. Only a single SoftwareSerial instance can read data at a time.

Call this method to set this port to be the reading port in the case there are multiple SoftwareSerial instances.

Parameters
portIdThe serial port to flush.

◆ serialRead()

void ofArduino::serialRead ( Firmata_Serial_Ports  port,
int  maxBytesToRead 
)

Start continuous reading of the specified serial port.

The port is checked for data each iteration of the main Arduino loop.

Parameters
portIdThe serial port to start reading continuously.
maxBytesToRead[Optional] The maximum number of bytes to read per iteration.
Note
If there are less bytes in the buffer, the lesser number of bytes will be returned. A value of 0 indicates that all available bytes in the buffer should be read.

◆ serialStop()

void ofArduino::serialStop ( Firmata_Serial_Ports  portID)

Stop continuous reading of the specified serial port.

This does not close the port, it stops reading it but keeps the port open.

Parameters
portIdThe serial port to stop reading.

◆ serialWrite()

void ofArduino::serialWrite ( Firmata_Serial_Ports  port,
unsigned char *  bytes,
int  numOfBytes 
)

Write an array of bytes to the specified serial port.

Parameters
portIdThe serial port to write to.
bytesAn array of bytes to write to the serial port.
numOfByteslength of the array of bytes.

◆ setAnalogHistoryLength()

void ofArduino::setAnalogHistoryLength ( int  length)

◆ setDigitalHistoryLength()

void ofArduino::setDigitalHistoryLength ( int  length)

◆ setStringHistoryLength()

void ofArduino::setStringHistoryLength ( int  length)

◆ setSysExHistoryLength()

void ofArduino::setSysExHistoryLength ( int  nSysEx)

◆ setUseDelay()

void ofArduino::setUseDelay ( bool  bDelay)

◆ update()

void ofArduino::update ( )

Polls data from the serial port, this has to be called periodically.

Member Data Documentation

◆ EAnalogPinChanged

ofEvent<const int> ofArduino::EAnalogPinChanged

Triggered when an analog pin changes value, the pin that changed is passed as an argument.

◆ EDigitalPinChanged

ofEvent<const int> ofArduino::EDigitalPinChanged

Triggered when a digital pin changes value, the pin that changed is passed as an argument.

◆ EEncoderDataReceived

ofEvent<const std::vector<Firmata_Encoder_Data> > ofArduino::EEncoderDataReceived

triggered when the encoder returns data after a read request

◆ EFirmwareVersionReceived

ofEvent<const int> ofArduino::EFirmwareVersionReceived

Triggered when a firmware version is received, the major version is passed as an argument.

◆ EI2CDataRecieved

ofEvent<const Firmata_I2C_Data> ofArduino::EI2CDataRecieved

triggered when the I2C bus returns data after a read request

◆ EInitialized

ofEvent<const int> ofArduino::EInitialized

Triggered when the firmware version is received upon connect, the major firmware version is passed as an argument. From this point it's safe to send to the Arduino.

◆ EPinStateResponseReceived

ofEvent<const std::pair<int, Firmata_Pin_Modes> > ofArduino::EPinStateResponseReceived

◆ ESerialDataReceived

ofEvent<const Firmata_Serial_Data> ofArduino::ESerialDataReceived

triggered when a Serial message is received. Returns which port and its data

◆ EStepperDataReceived

ofEvent<const Firmata_Stepper_Data> ofArduino::EStepperDataReceived

triggered when a stepper has finished rotating. Returns which stepper has complted its rotation

◆ EStringReceived

ofEvent<const std::string> ofArduino::EStringReceived

Triggered when a string is received, the string is passed as an argument.

◆ ESysExReceived

ofEvent<const std::vector <unsigned char> > ofArduino::ESysExReceived

Triggered when a SysEx message that isn't in the extended command set is received, the SysEx message is passed as an argument.


The documentation for this class was generated from the following files:
  • /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/communication/ofArduino.h
  • /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/communication/ofArduino.cpp