Reference.Firmata History

Hide minor edits - Show changes to markup

June 01, 2015, at 09:06 AM by Arturo -
Changed lines 5-7 from:

The Firmata library implements the Firmata protocol for communicating with software on the host computer. This allows you to write custom firmware without having to create your own protocol and objects for the programming environment that you are using.

to:

The Firmata library implements the Firmata protocol for communicating with software on the host computer. This allows you to write custom firmware without having to create your own protocol and objects for the programming environment that you are using.

Added line 14:

begin(Stream &s); // start the library using a [Stream](http://www.arduino.cc/en/Reference/Stream) other than Serial (eg Serial1 or EthernetClient)

Changed line 16 from:

blinkVersion(): //blink the protocol version on pin 13

to:

blinkVersion(): //blink the protocol version on the build in LED (typically pin 13)

Changed lines 18-19 from:

setFirmwareVersion(byte major, byte minor); //set the firmware name and version, using the sketch's filename, minus the .pde

to:

setFirmwareVersion(byte major, byte minor); //set the firmware name and version, using the sketch's filename, minus the '.ino' setFirmwareNameAndVersion(const char *name, byte major, byte minor); //set both the name and version of the firmware

Changed lines 25-27 from:

sendDigitalPorts(byte pin, byte firstPort, byte secondPort); //send digital ports as individual bytes sendDigitalPortPair(byte pin, int value); //send digital ports as one int sendSysex(byte command, byte bytec, byte* bytev); //send a command with an arbitrary array of bytes

to:

sendDigitalPort(byte portNumber, int portData); //send an 8-bit port in a single digital message

Changed lines 27-29 from:

sendString(byte command, const char* string); //send a string to the host computer using a custom command type

to:

sendString(byte command, byte bytec, byte *bytev); //send a string to the host computer using a custom command type sendSysex(byte command, byte bytec, byte* bytev); //send a command with an arbitrary array of bytes write(byte c); //write a byte to the Stream

Changed lines 40-44 from:

Callback Functions

In order to attach your function to a message type, your function must match the standard callback function. There are currently three types of callback functions in Firmata: generic, string, and sysex.

generic
to:

Utility methods

Changed lines 42-44 from:

void callbackFunction(byte pin, int value);

to:

sendValueAsTwo7bitBytes(int value); //writes value as 2 bytes startSysex(void); //starts a sysex message endSysex(void); //ends a sysex message

Changed lines 46-52 from:
system_reset
to:

Callback Functions

In order to attach your function to a message type, your function must match the standard callback function. There are currently three types of callback functions in Firmata: generic, string, and sysex.

generic
Changed line 54 from:

void systemResetCallbackFunction(void);

to:

void callbackFunction(byte pin, int value);

Changed line 56 from:
string
to:
system_reset
Changed line 58 from:

void stringCallbackFunction(char *myString);

to:

void systemResetCallbackFunction(void);

Changed line 60 from:
sysex
to:
string
Changed line 62 from:

void sysexCallbackFunction(byte pin, byte byteCount, byte *arrayPointer);

to:

void stringCallbackFunction(char *myString);

Changed lines 64-68 from:
to:
Changed lines 71-72 from:

These are the various message types that you can attach functions to.

to:

There are various message types that you can attach callback functions to.

Changed line 76 from:

REPORT_ANALOG //enable/disable the reporting of analog pin

to:

REPORT_ANALOG //enable/disable the reporting of an analog pin

Changed line 79 from:

FIRMATA_STRING //C-style strings, uses stringCallbackFunction for the function type

to:

STRING_DATA //C-style strings, uses stringCallbackFunction for the function type

Changed lines 95-96 from:
    pinMode(pin,OUTPUT);
    analogWrite(pin, value);
to:
  pinMode(pin, OUTPUT);
  analogWrite(pin, value);
Changed lines 101-103 from:
    Firmata.setFirmwareVersion(0, 1);
    Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
    Firmata.begin();
to:
  Firmata.setFirmwareVersion(FIRMATA_MAJOR_VERSION, FIRMATA_MINOR_VERSION);
  Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
  Firmata.begin();
Changed lines 108-113 from:
    while(Firmata.available()) {
        Firmata.processInput();
    }
    for(analogPin = 0; analogPin < TOTAL_ANALOG_PINS; analogPin++) {
        Firmata.sendAnalog(analogPin, analogRead(analogPin)); 
    }
to:
  while (Firmata.available()) {
    Firmata.processInput();
  }
  for (analogPin = 0; analogPin < TOTAL_ANALOG_PINS; analogPin++) {
    Firmata.sendAnalog(analogPin, analogRead(analogPin));
  }
April 17, 2015, at 10:54 AM by Arturo -
Changed line 76 from:
to:
April 17, 2015, at 10:53 AM by Arturo -
Changed line 61 from:
to:
Changed lines 103-104 from:

(:sourceend)

to:
April 17, 2015, at 10:52 AM by Arturo -
Changed line 61 from:
to:
Changed line 76 from:
to:
April 17, 2015, at 10:29 AM by Arturo -
Changed line 29 from:
to:
Changed lines 40-57 from:
to:
Changed lines 44-48 from:

Example

This example shows how to send and receive analog messages using Firmata.

to:
Added lines 62-76:
April 17, 2015, at 10:27 AM by Arturo -
Changed lines 19-25 from:
to:
Changed lines 29-33 from:
to:
Changed lines 40-44 from:
to:
Deleted lines 48-60:
Added lines 50-64:
April 17, 2015, at 09:53 AM by Arturo -
Changed lines 16-17 from:

(:sourceend)

to:
April 17, 2015, at 09:52 AM by Arturo -
Changed line 9 from:
to:
April 17, 2015, at 09:51 AM by Arturo -
Changed line 9 from:
to:
April 17, 2015, at 09:51 AM by Arturo -
Changed lines 9-16 from:
to:
April 17, 2015, at 09:48 AM by Arturo -
Changed lines 9-16 from:
to:
Changed lines 18-24 from:
to:
Changed lines 26-30 from:
to:
Changed lines 35-39 from:
to:
Changed lines 44-52 from:
to:
Changed line 57 from:
to:
April 17, 2015, at 09:47 AM by Arturo -
Changed lines 9-16 from:
begin()
start the library
begin(long)
start the library and override the default baud rate
printVersion()
send the protocol version to the host computer
blinkVersion()
blink the protocol version on pin 13
printFirmwareVersion()
send the firmware name and version to the host computer
setFirmwareVersion(byte major, byte minor)
set the firmware name and version, using the sketch's filename, minus the .pde

to:
Changed lines 18-24 from:
sendAnalog(byte pin, int value)
send an analog message
sendDigitalPorts(byte pin, byte firstPort, byte secondPort)
send digital ports as individual bytes
sendDigitalPortPair(byte pin, int value)
send digital ports as one int
sendSysex(byte command, byte bytec, byte* bytev)
send a command with an arbitrary array of bytes
sendString(const char* string)
send a string to the host computer
sendString(byte command, const char* string)
send a string to the host computer using a custom command type
to:
Changed lines 26-30 from:
available()
check to see if there are any incoming messages in the buffer
processInput()
process incoming messages from the buffer, sending the data to any registered callback functions
attach(byte command, callbackFunction myFunction)
attach a function to an incoming message type
detach(byte command)
detach a function from an incoming message type
to:
Changed lines 35-39 from:
generic
void callbackFunction(byte pin, int value);
system_reset
void systemResetCallbackFunction(void);
string
void stringCallbackFunction(char *myString);
sysex
void sysexCallbackFunction(byte pin, byte byteCount, byte *arrayPointer);
to:
Changed lines 44-52 from:
ANALOG_MESSAGE
the analog value for a single pin
DIGITAL_MESSAGE
8-bits of digital pin data (one port)
REPORT_ANALOG
enable/disable the reporting of analog pin
REPORT_DIGITAL
enable/disable the reporting of a digital port
SET_PIN_MODE
change the pin mode between INPUT/OUTPUT/PWM/etc.
FIRMATA_STRING
C-style strings, uses stringCallbackFunction for the function type
SYSEX_START
generic, arbitrary length messages (via MIDI SysEx protocol), uses sysexCallbackFunction for the function type
SYSTEM_RESET
message to reset firmware to its default state, uses systemResetCallbackFunction for the function type
to:
Changed line 57 from:

[@

to:
Changed lines 84-85 from:

@]

to:

(:sourceend)

November 25, 2008, at 08:28 PM by Hans Steiner -
Deleted line 0:
Added lines 2-3:

Firmata - Library - Baud Rate Details - Protocol Details - Protocol Proposals


November 25, 2008, at 08:24 PM by Hans Steiner -
Added lines 1-84:

Firmata? - Library - Baud Rate Details? - Protocol Details? - Protocol Proposals?


Firmata Library

The Firmata library implements the Firmata protocol for communicating with software on the host computer. This allows you to write custom firmware without having to create your own protocol and objects for the programming environment that you are using.

Methods

begin()
start the library
begin(long)
start the library and override the default baud rate
printVersion()
send the protocol version to the host computer
blinkVersion()
blink the protocol version on pin 13
printFirmwareVersion()
send the firmware name and version to the host computer
setFirmwareVersion(byte major, byte minor)
set the firmware name and version, using the sketch's filename, minus the .pde

Sending Messages

sendAnalog(byte pin, int value)
send an analog message
sendDigitalPorts(byte pin, byte firstPort, byte secondPort)
send digital ports as individual bytes
sendDigitalPortPair(byte pin, int value)
send digital ports as one int
sendSysex(byte command, byte bytec, byte* bytev)
send a command with an arbitrary array of bytes
sendString(const char* string)
send a string to the host computer
sendString(byte command, const char* string)
send a string to the host computer using a custom command type

Receiving Messages

available()
check to see if there are any incoming messages in the buffer
processInput()
process incoming messages from the buffer, sending the data to any registered callback functions
attach(byte command, callbackFunction myFunction)
attach a function to an incoming message type
detach(byte command)
detach a function from an incoming message type

Callback Functions

In order to attach your function to a message type, your function must match the standard callback function. There are currently three types of callback functions in Firmata: generic, string, and sysex.

generic
void callbackFunction(byte pin, int value);
system_reset
void systemResetCallbackFunction(void);
string
void stringCallbackFunction(char *myString);
sysex
void sysexCallbackFunction(byte pin, byte byteCount, byte *arrayPointer);

Message Types

These are the various message types that you can attach functions to.

ANALOG_MESSAGE
the analog value for a single pin
DIGITAL_MESSAGE
8-bits of digital pin data (one port)
REPORT_ANALOG
enable/disable the reporting of analog pin
REPORT_DIGITAL
enable/disable the reporting of a digital port
SET_PIN_MODE
change the pin mode between INPUT/OUTPUT/PWM/etc.
FIRMATA_STRING
C-style strings, uses stringCallbackFunction for the function type
SYSEX_START
generic, arbitrary length messages (via MIDI SysEx protocol), uses sysexCallbackFunction for the function type
SYSTEM_RESET
message to reset firmware to its default state, uses systemResetCallbackFunction for the function type

Example

This example shows how to send and receive analog messages using Firmata.

#include <Firmata.h>

byte analogPin;

void analogWriteCallback(byte pin, int value)
{
    pinMode(pin,OUTPUT);
    analogWrite(pin, value);
}

void setup()
{
    Firmata.setFirmwareVersion(0, 1);
    Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
    Firmata.begin();
}

void loop()
{
    while(Firmata.available()) {
        Firmata.processInput();
    }
    for(analogPin = 0; analogPin < TOTAL_ANALOG_PINS; analogPin++) {
        Firmata.sendAnalog(analogPin, analogRead(analogPin)); 
    }
}

Share