1515#define Firmata_h
1616
1717#include " Boards.h" /* Hardware Abstraction Layer + Wiring/Arduino */
18+ #include " FirmataConstants.h"
19+ #include " FirmataMarshaller.h"
1820#include " FirmataParser.h"
1921
20- /* Version numbers for the Firmata library.
21- * The firmware version will not always equal the protocol version going forward.
22- * Query using the REPORT_FIRMWARE message.
23- */
24- #define FIRMATA_FIRMWARE_MAJOR_VERSION 2
25- #define FIRMATA_FIRMWARE_MINOR_VERSION 5
26- #define FIRMATA_FIRMWARE_BUGFIX_VERSION 4
27-
2822/* DEPRECATED as of Firmata v2.5.1. As of 2.5.1 there are separate version numbers for
2923 * the protocol version and the firmware version.
3024 */
3428
3529// extended command set using sysex (0-127/0x00-0x7F)
3630/* 0x00-0x0F reserved for user-defined commands */
37- #define SERIAL_MESSAGE 0x60 // communicate with serial devices, including other boards
38- #define ENCODER_DATA 0x61 // reply with encoders current positions
39- #define SERVO_CONFIG 0x70 // set max angle, minPulse, maxPulse, freq
40- #define STEPPER_DATA 0x72 // control a stepper motor
41- #define ONEWIRE_DATA 0x73 // send an OneWire read/write/reset/select/skip/search request
42- #define SHIFT_DATA 0x75 // a bitstream to/from a shift register
43- #define I2C_REQUEST 0x76 // send an I2C read/write request
44- #define I2C_REPLY 0x77 // a reply to an I2C read request
45- #define I2C_CONFIG 0x78 // config I2C settings such as delay times and power pins
46- #define EXTENDED_ANALOG 0x6F // analog write (PWM, Servo, etc) to any pin
47- #define PIN_STATE_QUERY 0x6D // ask for a pin's current mode and value
48- #define PIN_STATE_RESPONSE 0x6E // reply with pin's current mode and value
49- #define CAPABILITY_QUERY 0x6B // ask for supported modes and resolution of all pins
50- #define CAPABILITY_RESPONSE 0x6C // reply with supported modes and resolution
51- #define ANALOG_MAPPING_QUERY 0x69 // ask for mapping of analog to pin numbers
52- #define ANALOG_MAPPING_RESPONSE 0x6A // reply with mapping info
53- #define SAMPLING_INTERVAL 0x7A // set the poll rate of the main loop
54- #define SCHEDULER_DATA 0x7B // send a createtask/deletetask/addtotask/schedule/querytasks/querytask request to the scheduler
55- #define SYSEX_NON_REALTIME 0x7E // MIDI Reserved for non-realtime messages
56- #define SYSEX_REALTIME 0x7F // MIDI Reserved for realtime messages
5731// these are DEPRECATED to make the naming more consistent
5832#define FIRMATA_STRING 0x71 // same as STRING_DATA
5933#define SYSEX_I2C_REQUEST 0x76 // same as I2C_REQUEST
6337// pin modes
6438// #define INPUT 0x00 // defined in Arduino.h
6539// #define OUTPUT 0x01 // defined in Arduino.h
66- #define PIN_MODE_ANALOG 0x02 // analog pin in analogInput mode
67- #define PIN_MODE_PWM 0x03 // digital pin in PWM output mode
68- #define PIN_MODE_SERVO 0x04 // digital pin in Servo output mode
69- #define PIN_MODE_SHIFT 0x05 // shiftIn/shiftOut mode
70- #define PIN_MODE_I2C 0x06 // pin included in I2C setup
71- #define PIN_MODE_ONEWIRE 0x07 // pin configured for 1-wire
72- #define PIN_MODE_STEPPER 0x08 // pin configured for stepper motor
73- #define PIN_MODE_ENCODER 0x09 // pin configured for rotary encoders
74- #define PIN_MODE_SERIAL 0x0A // pin configured for serial communication
75- #define PIN_MODE_PULLUP 0x0B // enable internal pull-up resistor for pin
76- #define PIN_MODE_IGNORE 0x7F // pin configured to be ignored by digitalWrite and capabilityResponse
77- #define TOTAL_PIN_MODES 13
7840// DEPRECATED as of Firmata v2.5
7941#define ANALOG 0x02 // same as PIN_MODE_ANALOG
8042#define PWM 0x03 // same as PIN_MODE_PWM
@@ -135,6 +97,7 @@ class FirmataClass
13597 void endSysex (void );
13698
13799 private:
100+ FirmataMarshaller marshaller;
138101 FirmataParser parser;
139102 Stream *FirmataStream;
140103 /* firmware name and version */
@@ -148,6 +111,7 @@ class FirmataClass
148111
149112 /* private methods ------------------------------ */
150113 void strobeBlinkPin (byte pin, int count, int onInterval, int offInterval);
114+ friend void FirmataMarshaller::sendValueAsTwo7bitBytes (uint16_t value);
151115};
152116
153117extern FirmataClass Firmata;
0 commit comments