Firmata firmware for Arduino
Firmata is a protocol for communicating with microcontrollers from software on a host computer
FirmataDefines.h
1 /*
2  FirmataDefines.h
3  Copyright (c) 2006-2008 Hans-Christoph Steiner. All rights reserved.
4  Copyright (C) 2009-2016 Jeff Hoefs. All rights reserved.
5 
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.
10 
11  See file LICENSE.txt for further informations on licensing terms.
12 */
13 
14 #ifndef FirmataDefines_h
15 #define FirmataDefines_h
16 
17 #include "FirmataConstants.h"
18 
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.
22  */
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
26 
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.
30  */
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
34 
35 #ifdef MAX_DATA_BYTES
36 #undef MAX_DATA_BYTES
37 #endif
38 #define MAX_DATA_BYTES firmata::MAX_DATA_BYTES // max number of data bytes in incoming messages
39 
40 // message command bytes (128-255/0x80-0xFF)
41 
42 #ifdef DIGITAL_MESSAGE
43 #undef DIGITAL_MESSAGE
44 #endif
45 #define DIGITAL_MESSAGE firmata::DIGITAL_MESSAGE // send data for a digital port (collection of 8 pins)
46 
47 #ifdef ANALOG_MESSAGE
48 #undef ANALOG_MESSAGE
49 #endif
50 #define ANALOG_MESSAGE firmata::ANALOG_MESSAGE // send data for an analog pin (or PWM)
51 
52 #ifdef REPORT_ANALOG
53 #undef REPORT_ANALOG
54 #endif
55 #define REPORT_ANALOG firmata::REPORT_ANALOG // enable analog input by pin #
56 
57 #ifdef REPORT_DIGITAL
58 #undef REPORT_DIGITAL
59 #endif
60 #define REPORT_DIGITAL firmata::REPORT_DIGITAL // enable digital input by port pair
61 
62 //
63 
64 #ifdef SET_PIN_MODE
65 #undef SET_PIN_MODE
66 #endif
67 #define SET_PIN_MODE firmata::SET_PIN_MODE // set a pin to INPUT/OUTPUT/PWM/etc
68 
69 #ifdef SET_DIGITAL_PIN_VALUE
70 #undef SET_DIGITAL_PIN_VALUE
71 #endif
72 #define SET_DIGITAL_PIN_VALUE firmata::SET_DIGITAL_PIN_VALUE // set value of an individual digital pin
73 
74 //
75 
76 #ifdef REPORT_VERSION
77 #undef REPORT_VERSION
78 #endif
79 #define REPORT_VERSION firmata::REPORT_VERSION // report protocol version
80 
81 #ifdef SYSTEM_RESET
82 #undef SYSTEM_RESET
83 #endif
84 #define SYSTEM_RESET firmata::SYSTEM_RESET // reset from MIDI
85 
86 //
87 
88 #ifdef START_SYSEX
89 #undef START_SYSEX
90 #endif
91 #define START_SYSEX firmata::START_SYSEX // start a MIDI Sysex message
92 
93 #ifdef END_SYSEX
94 #undef END_SYSEX
95 #endif
96 #define END_SYSEX firmata::END_SYSEX // end a MIDI Sysex message
97 
98 // extended command set using sysex (0-127/0x00-0x7F)
99 /* 0x00-0x0F reserved for user-defined commands */
100 
101 #ifdef SERIAL_MESSAGE
102 #undef SERIAL_MESSAGE
103 #endif
104 #define SERIAL_MESSAGE firmata::SERIAL_DATA // communicate with serial devices, including other boards
105 
106 #ifdef ENCODER_DATA
107 #undef ENCODER_DATA
108 #endif
109 #define ENCODER_DATA firmata::ENCODER_DATA // reply with encoders current positions
110 
111 #ifdef SERVO_CONFIG
112 #undef SERVO_CONFIG
113 #endif
114 #define SERVO_CONFIG firmata::SERVO_CONFIG // set max angle, minPulse, maxPulse, freq
115 
116 #ifdef STRING_DATA
117 #undef STRING_DATA
118 #endif
119 #define STRING_DATA firmata::STRING_DATA // a string message with 14-bits per char
120 
121 #ifdef STEPPER_DATA
122 #undef STEPPER_DATA
123 #endif
124 #define STEPPER_DATA firmata::STEPPER_DATA // control a stepper motor
125 
126 #ifdef ONEWIRE_DATA
127 #undef ONEWIRE_DATA
128 #endif
129 #define ONEWIRE_DATA firmata::ONEWIRE_DATA // send an OneWire read/write/reset/select/skip/search request
130 
131 #ifdef SHIFT_DATA
132 #undef SHIFT_DATA
133 #endif
134 #define SHIFT_DATA firmata::SHIFT_DATA // a bitstream to/from a shift register
135 
136 #ifdef I2C_REQUEST
137 #undef I2C_REQUEST
138 #endif
139 #define I2C_REQUEST firmata::I2C_REQUEST // send an I2C read/write request
140 
141 #ifdef I2C_REPLY
142 #undef I2C_REPLY
143 #endif
144 #define I2C_REPLY firmata::I2C_REPLY // a reply to an I2C read request
145 
146 #ifdef I2C_CONFIG
147 #undef I2C_CONFIG
148 #endif
149 #define I2C_CONFIG firmata::I2C_CONFIG // config I2C settings such as delay times and power pins
150 
151 #ifdef REPORT_FIRMWARE
152 #undef REPORT_FIRMWARE
153 #endif
154 #define REPORT_FIRMWARE firmata::REPORT_FIRMWARE // report name and version of the firmware
155 
156 #ifdef EXTENDED_ANALOG
157 #undef EXTENDED_ANALOG
158 #endif
159 #define EXTENDED_ANALOG firmata::EXTENDED_ANALOG // analog write (PWM, Servo, etc) to any pin
160 
161 #ifdef PIN_STATE_QUERY
162 #undef PIN_STATE_QUERY
163 #endif
164 #define PIN_STATE_QUERY firmata::PIN_STATE_QUERY // ask for a pin's current mode and value
165 
166 #ifdef PIN_STATE_RESPONSE
167 #undef PIN_STATE_RESPONSE
168 #endif
169 #define PIN_STATE_RESPONSE firmata::PIN_STATE_RESPONSE // reply with pin's current mode and value
170 
171 #ifdef CAPABILITY_QUERY
172 #undef CAPABILITY_QUERY
173 #endif
174 #define CAPABILITY_QUERY firmata::CAPABILITY_QUERY // ask for supported modes and resolution of all pins
175 
176 #ifdef CAPABILITY_RESPONSE
177 #undef CAPABILITY_RESPONSE
178 #endif
179 #define CAPABILITY_RESPONSE firmata::CAPABILITY_RESPONSE // reply with supported modes and resolution
180 
181 #ifdef ANALOG_MAPPING_QUERY
182 #undef ANALOG_MAPPING_QUERY
183 #endif
184 #define ANALOG_MAPPING_QUERY firmata::ANALOG_MAPPING_QUERY // ask for mapping of analog to pin numbers
185 
186 #ifdef ANALOG_MAPPING_RESPONSE
187 #undef ANALOG_MAPPING_RESPONSE
188 #endif
189 #define ANALOG_MAPPING_RESPONSE firmata::ANALOG_MAPPING_RESPONSE // reply with mapping info
190 
191 #ifdef SAMPLING_INTERVAL
192 #undef SAMPLING_INTERVAL
193 #endif
194 #define SAMPLING_INTERVAL firmata::SAMPLING_INTERVAL // set the poll rate of the main loop
195 
196 #ifdef SCHEDULER_DATA
197 #undef SCHEDULER_DATA
198 #endif
199 #define SCHEDULER_DATA firmata::SCHEDULER_DATA // send a createtask/deletetask/addtotask/schedule/querytasks/querytask request to the scheduler
200 
201 #ifdef SYSEX_NON_REALTIME
202 #undef SYSEX_NON_REALTIME
203 #endif
204 #define SYSEX_NON_REALTIME firmata::SYSEX_NON_REALTIME // MIDI Reserved for non-realtime messages
205 
206 #ifdef SYSEX_REALTIME
207 #undef SYSEX_REALTIME
208 #endif
209 #define SYSEX_REALTIME firmata::SYSEX_REALTIME // MIDI Reserved for realtime messages
210 
211 // pin modes
212 
213 #ifdef PIN_MODE_INPUT
214 #undef PIN_MODE_INPUT
215 #endif
216 #define PIN_MODE_INPUT firmata::PIN_MODE_INPUT // same as INPUT defined in Arduino.h
217 
218 #ifdef PIN_MODE_OUTPUT
219 #undef PIN_MODE_OUTPUT
220 #endif
221 #define PIN_MODE_OUTPUT firmata::PIN_MODE_OUTPUT // same as OUTPUT defined in Arduino.h
222 
223 #ifdef PIN_MODE_ANALOG
224 #undef PIN_MODE_ANALOG
225 #endif
226 #define PIN_MODE_ANALOG firmata::PIN_MODE_ANALOG // analog pin in analogInput mode
227 
228 #ifdef PIN_MODE_PWM
229 #undef PIN_MODE_PWM
230 #endif
231 #define PIN_MODE_PWM firmata::PIN_MODE_PWM // digital pin in PWM output mode
232 
233 #ifdef PIN_MODE_SERVO
234 #undef PIN_MODE_SERVO
235 #endif
236 #define PIN_MODE_SERVO firmata::PIN_MODE_SERVO // digital pin in Servo output mode
237 
238 #ifdef PIN_MODE_SHIFT
239 #undef PIN_MODE_SHIFT
240 #endif
241 #define PIN_MODE_SHIFT firmata::PIN_MODE_SHIFT // shiftIn/shiftOut mode
242 
243 #ifdef PIN_MODE_I2C
244 #undef PIN_MODE_I2C
245 #endif
246 #define PIN_MODE_I2C firmata::PIN_MODE_I2C // pin included in I2C setup
247 
248 #ifdef PIN_MODE_ONEWIRE
249 #undef PIN_MODE_ONEWIRE
250 #endif
251 #define PIN_MODE_ONEWIRE firmata::PIN_MODE_ONEWIRE // pin configured for 1-wire
252 
253 #ifdef PIN_MODE_STEPPER
254 #undef PIN_MODE_STEPPER
255 #endif
256 #define PIN_MODE_STEPPER firmata::PIN_MODE_STEPPER // pin configured for stepper motor
257 
258 #ifdef PIN_MODE_ENCODER
259 #undef PIN_MODE_ENCODER
260 #endif
261 #define PIN_MODE_ENCODER firmata::PIN_MODE_ENCODER // pin configured for rotary encoders
262 
263 #ifdef PIN_MODE_SERIAL
264 #undef PIN_MODE_SERIAL
265 #endif
266 #define PIN_MODE_SERIAL firmata::PIN_MODE_SERIAL // pin configured for serial communication
267 
268 #ifdef PIN_MODE_PULLUP
269 #undef PIN_MODE_PULLUP
270 #endif
271 #define PIN_MODE_PULLUP firmata::PIN_MODE_PULLUP // enable internal pull-up resistor for pin
272 
273 #ifdef PIN_MODE_IGNORE
274 #undef PIN_MODE_IGNORE
275 #endif
276 #define PIN_MODE_IGNORE firmata::PIN_MODE_IGNORE // pin configured to be ignored by digitalWrite and capabilityResponse
277 
278 #ifdef TOTAL_PIN_MODES
279 #undef TOTAL_PIN_MODES
280 #endif
281 #define TOTAL_PIN_MODES firmata::TOTAL_PIN_MODES
282 
283 #endif // FirmataConstants_h