Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes

ofStandardFirmata Class Reference

#include <ofStandardFirmata.h>

Inheritance diagram for ofStandardFirmata:
ofArduino

List of all members.

Public Member Functions

 ofStandardFirmata ()
virtual ~ofStandardFirmata ()
int connect (string device, int baud=115200)
void disconnect ()
void update ()
bool isInitialized ()
void setDigitalHistoryLength (int length)
void setAnalogHistoryLength (int length)
void setStringHistoryLength (int length)
void setSysExHistoryLength (int nSysEx)
void sendDigitalPinMode (int pin, int mode)
void sendAnalogPinReporting (int pin, int mode)
void sendDigital (int pin, int value, bool force=false)
void sendPwm (int pin, int value, bool force=false)
void sendSysEx (int command, vector< unsigned char > data)
void sendString (string str)
void sendProtocolVersionRequest ()
void sendFirmwareVersionRequest ()
void sendReset ()
void sendSysExBegin ()
void sendSysExEnd ()
void sendByte (unsigned char byte)
void sendValueAsTwo7bitBytes (int value)
int getPwm (int pin)
int getDigital (int pin)
int getAnalog (int pin)
vector< unsigned char > getSysEx ()
string getString ()
int getMajorProtocolVersion ()
int getMinorProtocolVersion ()
int getMajorFirmwareVersion ()
int getMinorFirmwareVersion ()
string getFirmwareName ()
list< int > * getDigitalHistory (int pin)
list< int > * getAnalogHistory (int pin)
list< vector< unsigned char > > * getSysExHistory ()
list< string > * getStringHistory ()
int getDigitalPinMode (int pin)
int getAnalogPinReporting (int pin)
int getValueFromTwo7bitBytes (unsigned char lsb, unsigned char msb)

Public Attributes

ofEvent< const int > EDigitalPinChanged
ofEvent< const int > EAnalogPinChanged
ofEvent< const vector
< unsigned char > > 
ESysExReceived
ofEvent< const int > EProtocolVersionReceived
ofEvent< const int > EFirmwareVersionReceived
ofEvent< const int > EInitialized
ofEvent< const string > EStringReceived

Protected Member Functions

void sendDigitalPinReporting (int pin, int mode)
void sendDigitalPortReporting (int port, int mode)
void processData (unsigned char inputData)
void processDigitalPort (int port, unsigned char value)
virtual void processSysExData (vector< unsigned char > data)

Protected Attributes

bool _initialized
ofSerial _port
int _portStatus
int _analogHistoryLength
int _digitalHistoryLength
int _stringHistoryLength
int _sysExHistoryLength
int _waitForData
int _executeMultiByteCommand
int _multiByteChannel
unsigned char _storedInputData [FIRMATA_MAX_DATA_BYTES]
vector< unsigned char > _sysExData
int _majorProtocolVersion
int _minorProtocolVersion
int _majorFirmwareVersion
int _minorFirmwareVersion
string _firmwareName
list< vector< unsigned char > > _sysExHistory
list< string > _stringHistory
list< int > _analogHistory [ARD_TOTAL_ANALOG_PINS]
list< int > _digitalHistory [ARD_TOTAL_DIGITAL_PINS]
int _digitalPinMode [ARD_TOTAL_DIGITAL_PINS]
int _digitalPinValue [ARD_TOTAL_DIGITAL_PINS]
int _digitalPortValue [ARD_TOTAL_PORTS]
int _digitalPortReporting [ARD_TOTAL_PORTS]
int _digitalPinReporting [ARD_TOTAL_DIGITAL_PINS]
int _analogPinReporting [ARD_TOTAL_ANALOG_PINS]

Detailed Description

Notes:

Communication problems could be caused by high baud rates, if you are using ofStandardFirmata then try to turn down the baud rate to 57600. I.e. Change Firmata.begin() in setup() in ofStandardFirmata on the Arduino to Firmata.begin(57600) and connect using baud=57600;

ofStandardFirmata on the Arduino will get caught in a while loop if data is sent to it continuosly at high speeds (for example on each update at 100FPS) As a consequence data will not be sent from the Arduino to the computer. This is why most of the sender functions only transmit data if it has been changed. This behavior can be overriden by setting force=true in the senders.

This version of the Arduino class is intended to be used with the Firmata v2 protocol and the ofStandardFirmata firmware, see http://www.arduino.cc/playground/Interfacing/Firmata. It currently supports the Arduino NG and Diecimila boards and other ATmega168 based Arduino compatible boards. The class can be extended to accomodate modified versions of ofStandardFirmata.


Constructor & Destructor Documentation

ofStandardFirmata::ofStandardFirmata (  )
ofStandardFirmata::~ofStandardFirmata (  ) [virtual]

Member Function Documentation

int ofStandardFirmata::connect ( string  device,
int  baud = 115200 
)

Reimplemented in ofArduino.

void ofStandardFirmata::disconnect (  )
int ofStandardFirmata::getAnalog ( int  pin )
list< int > * ofStandardFirmata::getAnalogHistory ( int  pin )
int ofStandardFirmata::getAnalogPinReporting ( int  pin )
int ofStandardFirmata::getDigital ( int  pin )
list< int > * ofStandardFirmata::getDigitalHistory ( int  pin )
int ofStandardFirmata::getDigitalPinMode ( int  pin )
string ofStandardFirmata::getFirmwareName (  )
int ofStandardFirmata::getMajorFirmwareVersion (  )
int ofStandardFirmata::getMajorProtocolVersion (  )
int ofStandardFirmata::getMinorFirmwareVersion (  )
int ofStandardFirmata::getMinorProtocolVersion (  )
int ofStandardFirmata::getPwm ( int  pin )
string ofStandardFirmata::getString (  )
list< string > * ofStandardFirmata::getStringHistory (  )
vector< unsigned char > ofStandardFirmata::getSysEx (  )
list< vector< unsigned char > > * ofStandardFirmata::getSysExHistory (  )
int ofStandardFirmata::getValueFromTwo7bitBytes ( unsigned char  lsb,
unsigned char  msb 
)
bool ofStandardFirmata::isInitialized (  )
void ofStandardFirmata::processData ( unsigned char  inputData ) [protected]
void ofStandardFirmata::processDigitalPort ( int  port,
unsigned char  value 
) [protected]
void ofStandardFirmata::processSysExData ( vector< unsigned char >  data ) [protected, virtual]

Reimplemented in ofArduino.

void ofStandardFirmata::sendAnalogPinReporting ( int  pin,
int  mode 
)
void ofStandardFirmata::sendByte ( unsigned char  byte )
void ofStandardFirmata::sendDigital ( int  pin,
int  value,
bool  force = false 
)
void ofStandardFirmata::sendDigitalPinMode ( int  pin,
int  mode 
)
void ofStandardFirmata::sendDigitalPinReporting ( int  pin,
int  mode 
) [protected]
void ofStandardFirmata::sendDigitalPortReporting ( int  port,
int  mode 
) [protected]
void ofStandardFirmata::sendFirmwareVersionRequest (  )
void ofStandardFirmata::sendProtocolVersionRequest (  )
void ofStandardFirmata::sendPwm ( int  pin,
int  value,
bool  force = false 
)
void ofStandardFirmata::sendReset (  )
void ofStandardFirmata::sendString ( string  str )
void ofStandardFirmata::sendSysEx ( int  command,
vector< unsigned char >  data 
)
void ofStandardFirmata::sendSysExBegin (  )
void ofStandardFirmata::sendSysExEnd (  )
void ofStandardFirmata::sendValueAsTwo7bitBytes ( int  value )
void ofStandardFirmata::setAnalogHistoryLength ( int  length )
void ofStandardFirmata::setDigitalHistoryLength ( int  length )
void ofStandardFirmata::setStringHistoryLength ( int  length )
void ofStandardFirmata::setSysExHistoryLength ( int  nSysEx )
void ofStandardFirmata::update (  )

Member Data Documentation

list<int> ofStandardFirmata::_analogHistory[ARD_TOTAL_ANALOG_PINS] [protected]
int ofStandardFirmata::_analogPinReporting[ARD_TOTAL_ANALOG_PINS] [protected]
list<int> ofStandardFirmata::_digitalHistory[ARD_TOTAL_DIGITAL_PINS] [protected]
int ofStandardFirmata::_digitalPinMode[ARD_TOTAL_DIGITAL_PINS] [protected]
int ofStandardFirmata::_digitalPinReporting[ARD_TOTAL_DIGITAL_PINS] [protected]
int ofStandardFirmata::_digitalPinValue[ARD_TOTAL_DIGITAL_PINS] [protected]
int ofStandardFirmata::_digitalPortReporting[ARD_TOTAL_PORTS] [protected]
int ofStandardFirmata::_digitalPortValue[ARD_TOTAL_PORTS] [protected]
unsigned char ofStandardFirmata::_storedInputData[FIRMATA_MAX_DATA_BYTES] [protected]
list<string> ofStandardFirmata::_stringHistory [protected]
vector<unsigned char> ofStandardFirmata::_sysExData [protected]
list<vector<unsigned char> > ofStandardFirmata::_sysExHistory [protected]
ofEvent<const int> ofStandardFirmata::EInitialized
ofEvent<const string> ofStandardFirmata::EStringReceived
ofEvent<const vector<unsigned char> > ofStandardFirmata::ESysExReceived

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines