3 Copyright (c) 2006-2008 Hans-Christoph Steiner. All rights reserved.
4 Copyright (C) 2009-2016 Jeff Hoefs. All rights reserved.
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 See file LICENSE.txt for further informations on licensing terms.
14 #ifndef FirmataDefines_h
15 #define FirmataDefines_h
17 #include "FirmataConstants.h"
19 /* Version numbers for the Firmata library.
20 * The firmware version will not always equal the protocol version going forward.
21 * Query using the REPORT_FIRMWARE message.
23 #define FIRMATA_FIRMWARE_MAJOR_VERSION firmata::FIRMWARE_MAJOR_VERSION
24 #define FIRMATA_FIRMWARE_MINOR_VERSION firmata::FIRMWARE_MINOR_VERSION
25 #define FIRMATA_FIRMWARE_BUGFIX_VERSION firmata::FIRMWARE_BUGFIX_VERSION
27 /* Version numbers for the protocol. The protocol is still changing, so these
28 * version numbers are important.
29 * Query using the REPORT_VERSION message.
31 #define FIRMATA_PROTOCOL_MAJOR_VERSION firmata::PROTOCOL_MAJOR_VERSION // for non-compatible changes
32 #define FIRMATA_PROTOCOL_MINOR_VERSION firmata::PROTOCOL_MINOR_VERSION // for backwards compatible changes
33 #define FIRMATA_PROTOCOL_BUGFIX_VERSION firmata::PROTOCOL_BUGFIX_VERSION // for bugfix releases
38 #define MAX_DATA_BYTES firmata::MAX_DATA_BYTES // max number of data bytes in incoming messages
40 // message command bytes (128-255/0x80-0xFF)
42 #ifdef DIGITAL_MESSAGE
43 #undef DIGITAL_MESSAGE
45 #define DIGITAL_MESSAGE firmata::DIGITAL_MESSAGE // send data for a digital port (collection of 8 pins)
50 #define ANALOG_MESSAGE firmata::ANALOG_MESSAGE // send data for an analog pin (or PWM)
55 #define REPORT_ANALOG firmata::REPORT_ANALOG // enable analog input by pin #
60 #define REPORT_DIGITAL firmata::REPORT_DIGITAL // enable digital input by port pair
67 #define SET_PIN_MODE firmata::SET_PIN_MODE // set a pin to INPUT/OUTPUT/PWM/etc
69 #ifdef SET_DIGITAL_PIN_VALUE
70 #undef SET_DIGITAL_PIN_VALUE
72 #define SET_DIGITAL_PIN_VALUE firmata::SET_DIGITAL_PIN_VALUE // set value of an individual digital pin
79 #define REPORT_VERSION firmata::REPORT_VERSION // report protocol version
84 #define SYSTEM_RESET firmata::SYSTEM_RESET // reset from MIDI
91 #define START_SYSEX firmata::START_SYSEX // start a MIDI Sysex message
96 #define END_SYSEX firmata::END_SYSEX // end a MIDI Sysex message
98 // extended command set using sysex (0-127/0x00-0x7F)
99 /* 0x00-0x0F reserved for user-defined commands */
101 #ifdef SERIAL_MESSAGE
102 #undef SERIAL_MESSAGE
104 #define SERIAL_MESSAGE firmata::SERIAL_DATA // communicate with serial devices, including other boards
109 #define ENCODER_DATA firmata::ENCODER_DATA // reply with encoders current positions
114 #define SERVO_CONFIG firmata::SERVO_CONFIG // set max angle, minPulse, maxPulse, freq
119 #define STRING_DATA firmata::STRING_DATA // a string message with 14-bits per char
124 #define STEPPER_DATA firmata::STEPPER_DATA // control a stepper motor
129 #define ONEWIRE_DATA firmata::ONEWIRE_DATA // send an OneWire read/write/reset/select/skip/search request
134 #define SHIFT_DATA firmata::SHIFT_DATA // a bitstream to/from a shift register
139 #define I2C_REQUEST firmata::I2C_REQUEST // send an I2C read/write request
144 #define I2C_REPLY firmata::I2C_REPLY // a reply to an I2C read request
149 #define I2C_CONFIG firmata::I2C_CONFIG // config I2C settings such as delay times and power pins
151 #ifdef REPORT_FIRMWARE
152 #undef REPORT_FIRMWARE
154 #define REPORT_FIRMWARE firmata::REPORT_FIRMWARE // report name and version of the firmware
156 #ifdef EXTENDED_ANALOG
157 #undef EXTENDED_ANALOG
159 #define EXTENDED_ANALOG firmata::EXTENDED_ANALOG // analog write (PWM, Servo, etc) to any pin
161 #ifdef PIN_STATE_QUERY
162 #undef PIN_STATE_QUERY
164 #define PIN_STATE_QUERY firmata::PIN_STATE_QUERY // ask for a pin's current mode and value
166 #ifdef PIN_STATE_RESPONSE
167 #undef PIN_STATE_RESPONSE
169 #define PIN_STATE_RESPONSE firmata::PIN_STATE_RESPONSE // reply with pin's current mode and value
171 #ifdef CAPABILITY_QUERY
172 #undef CAPABILITY_QUERY
174 #define CAPABILITY_QUERY firmata::CAPABILITY_QUERY // ask for supported modes and resolution of all pins
176 #ifdef CAPABILITY_RESPONSE
177 #undef CAPABILITY_RESPONSE
179 #define CAPABILITY_RESPONSE firmata::CAPABILITY_RESPONSE // reply with supported modes and resolution
181 #ifdef ANALOG_MAPPING_QUERY
182 #undef ANALOG_MAPPING_QUERY
184 #define ANALOG_MAPPING_QUERY firmata::ANALOG_MAPPING_QUERY // ask for mapping of analog to pin numbers
186 #ifdef ANALOG_MAPPING_RESPONSE
187 #undef ANALOG_MAPPING_RESPONSE
189 #define ANALOG_MAPPING_RESPONSE firmata::ANALOG_MAPPING_RESPONSE // reply with mapping info
191 #ifdef SAMPLING_INTERVAL
192 #undef SAMPLING_INTERVAL
194 #define SAMPLING_INTERVAL firmata::SAMPLING_INTERVAL // set the poll rate of the main loop
196 #ifdef SCHEDULER_DATA
197 #undef SCHEDULER_DATA
199 #define SCHEDULER_DATA firmata::SCHEDULER_DATA // send a createtask/deletetask/addtotask/schedule/querytasks/querytask request to the scheduler
201 #ifdef SYSEX_NON_REALTIME
202 #undef SYSEX_NON_REALTIME
204 #define SYSEX_NON_REALTIME firmata::SYSEX_NON_REALTIME // MIDI Reserved for non-realtime messages
206 #ifdef SYSEX_REALTIME
207 #undef SYSEX_REALTIME
209 #define SYSEX_REALTIME firmata::SYSEX_REALTIME // MIDI Reserved for realtime messages
213 #ifdef PIN_MODE_INPUT
214 #undef PIN_MODE_INPUT
216 #define PIN_MODE_INPUT firmata::PIN_MODE_INPUT // same as INPUT defined in Arduino.h
218 #ifdef PIN_MODE_OUTPUT
219 #undef PIN_MODE_OUTPUT
221 #define PIN_MODE_OUTPUT firmata::PIN_MODE_OUTPUT // same as OUTPUT defined in Arduino.h
223 #ifdef PIN_MODE_ANALOG
224 #undef PIN_MODE_ANALOG
226 #define PIN_MODE_ANALOG firmata::PIN_MODE_ANALOG // analog pin in analogInput mode
231 #define PIN_MODE_PWM firmata::PIN_MODE_PWM // digital pin in PWM output mode
233 #ifdef PIN_MODE_SERVO
234 #undef PIN_MODE_SERVO
236 #define PIN_MODE_SERVO firmata::PIN_MODE_SERVO // digital pin in Servo output mode
238 #ifdef PIN_MODE_SHIFT
239 #undef PIN_MODE_SHIFT
241 #define PIN_MODE_SHIFT firmata::PIN_MODE_SHIFT // shiftIn/shiftOut mode
246 #define PIN_MODE_I2C firmata::PIN_MODE_I2C // pin included in I2C setup
248 #ifdef PIN_MODE_ONEWIRE
249 #undef PIN_MODE_ONEWIRE
251 #define PIN_MODE_ONEWIRE firmata::PIN_MODE_ONEWIRE // pin configured for 1-wire
253 #ifdef PIN_MODE_STEPPER
254 #undef PIN_MODE_STEPPER
256 #define PIN_MODE_STEPPER firmata::PIN_MODE_STEPPER // pin configured for stepper motor
258 #ifdef PIN_MODE_ENCODER
259 #undef PIN_MODE_ENCODER
261 #define PIN_MODE_ENCODER firmata::PIN_MODE_ENCODER // pin configured for rotary encoders
263 #ifdef PIN_MODE_SERIAL
264 #undef PIN_MODE_SERIAL
266 #define PIN_MODE_SERIAL firmata::PIN_MODE_SERIAL // pin configured for serial communication
268 #ifdef PIN_MODE_PULLUP
269 #undef PIN_MODE_PULLUP
271 #define PIN_MODE_PULLUP firmata::PIN_MODE_PULLUP // enable internal pull-up resistor for pin
273 #ifdef PIN_MODE_IGNORE
274 #undef PIN_MODE_IGNORE
276 #define PIN_MODE_IGNORE firmata::PIN_MODE_IGNORE // pin configured to be ignored by digitalWrite and capabilityResponse
278 #ifdef TOTAL_PIN_MODES
279 #undef TOTAL_PIN_MODES
281 #define TOTAL_PIN_MODES firmata::TOTAL_PIN_MODES
283 #endif // FirmataConstants_h