Skip to content

Commit d38adba

Browse files
committed
Split marshalling functionality into new lib
1 parent 4ab1e25 commit d38adba

File tree

3 files changed

+501
-0
lines changed

3 files changed

+501
-0
lines changed

FirmataConstants.h

Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
/*
2+
Firmata.h - Firmata library v2.5.4 - 2016-10-23
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 FirmataConstants_h
15+
#define FirmataConstants_h
16+
17+
/* Version numbers for the Firmata library.
18+
* The firmware version will not always equal the protocol version going forward.
19+
* Query using the REPORT_FIRMWARE message.
20+
*/
21+
#define FIRMATA_FIRMWARE_MAJOR_VERSION 2
22+
#define FIRMATA_FIRMWARE_MINOR_VERSION 5
23+
#define FIRMATA_FIRMWARE_BUGFIX_VERSION 4
24+
25+
/* Version numbers for the protocol. The protocol is still changing, so these
26+
* version numbers are important.
27+
* Query using the REPORT_VERSION message.
28+
*/
29+
#define FIRMATA_PROTOCOL_MAJOR_VERSION 2 // for non-compatible changes
30+
#define FIRMATA_PROTOCOL_MINOR_VERSION 5 // for backwards compatible changes
31+
#define FIRMATA_PROTOCOL_BUGFIX_VERSION 1 // for bugfix releases
32+
33+
#ifdef MAX_DATA_BYTES
34+
#undef MAX_DATA_BYTES
35+
#endif
36+
#define MAX_DATA_BYTES 64 // max number of data bytes in incoming messages
37+
38+
// message command bytes (128-255/0x80-0xFF)
39+
40+
#ifdef DIGITAL_MESSAGE
41+
#undef DIGITAL_MESSAGE
42+
#endif
43+
#define DIGITAL_MESSAGE 0x90 // send data for a digital port (collection of 8 pins)
44+
45+
#ifdef ANALOG_MESSAGE
46+
#undef ANALOG_MESSAGE
47+
#endif
48+
#define ANALOG_MESSAGE 0xE0 // send data for an analog pin (or PWM)
49+
50+
#ifdef REPORT_ANALOG
51+
#undef REPORT_ANALOG
52+
#endif
53+
#define REPORT_ANALOG 0xC0 // enable analog input by pin #
54+
55+
#ifdef REPORT_DIGITAL
56+
#undef REPORT_DIGITAL
57+
#endif
58+
#define REPORT_DIGITAL 0xD0 // enable digital input by port pair
59+
60+
//
61+
62+
#ifdef SET_PIN_MODE
63+
#undef SET_PIN_MODE
64+
#endif
65+
#define SET_PIN_MODE 0xF4 // set a pin to INPUT/OUTPUT/PWM/etc
66+
67+
#ifdef SET_DIGITAL_PIN_VALUE
68+
#undef SET_DIGITAL_PIN_VALUE
69+
#endif
70+
#define SET_DIGITAL_PIN_VALUE 0xF5 // set value of an individual digital pin
71+
72+
//
73+
74+
#ifdef REPORT_VERSION
75+
#undef REPORT_VERSION
76+
#endif
77+
#define REPORT_VERSION 0xF9 // report protocol version
78+
79+
#ifdef SYSTEM_RESET
80+
#undef SYSTEM_RESET
81+
#endif
82+
#define SYSTEM_RESET 0xFF // reset from MIDI
83+
84+
//
85+
86+
#ifdef START_SYSEX
87+
#undef START_SYSEX
88+
#endif
89+
#define START_SYSEX 0xF0 // start a MIDI Sysex message
90+
91+
#ifdef END_SYSEX
92+
#undef END_SYSEX
93+
#endif
94+
#define END_SYSEX 0xF7 // end a MIDI Sysex message
95+
96+
// extended command set using sysex (0-127/0x00-0x7F)
97+
/* 0x00-0x0F reserved for user-defined commands */
98+
99+
#ifdef SERIAL_MESSAGE
100+
#undef SERIAL_MESSAGE
101+
#endif
102+
#define SERIAL_MESSAGE 0x60 // communicate with serial devices, including other boards
103+
104+
#ifdef ENCODER_DATA
105+
#undef ENCODER_DATA
106+
#endif
107+
#define ENCODER_DATA 0x61 // reply with encoders current positions
108+
109+
#ifdef SERVO_CONFIG
110+
#undef SERVO_CONFIG
111+
#endif
112+
#define SERVO_CONFIG 0x70 // set max angle, minPulse, maxPulse, freq
113+
114+
#ifdef STRING_DATA
115+
#undef STRING_DATA
116+
#endif
117+
#define STRING_DATA 0x71 // a string message with 14-bits per char
118+
119+
#ifdef STEPPER_DATA
120+
#undef STEPPER_DATA
121+
#endif
122+
#define STEPPER_DATA 0x72 // control a stepper motor
123+
124+
#ifdef ONEWIRE_DATA
125+
#undef ONEWIRE_DATA
126+
#endif
127+
#define ONEWIRE_DATA 0x73 // send an OneWire read/write/reset/select/skip/search request
128+
129+
#ifdef SHIFT_DATA
130+
#undef SHIFT_DATA
131+
#endif
132+
#define SHIFT_DATA 0x75 // a bitstream to/from a shift register
133+
134+
#ifdef I2C_REQUEST
135+
#undef I2C_REQUEST
136+
#endif
137+
#define I2C_REQUEST 0x76 // send an I2C read/write request
138+
139+
#ifdef I2C_REPLY
140+
#undef I2C_REPLY
141+
#endif
142+
#define I2C_REPLY 0x77 // a reply to an I2C read request
143+
144+
#ifdef I2C_CONFIG
145+
#undef I2C_CONFIG
146+
#endif
147+
#define I2C_CONFIG 0x78 // config I2C settings such as delay times and power pins
148+
149+
#ifdef REPORT_FIRMWARE
150+
#undef REPORT_FIRMWARE
151+
#endif
152+
#define REPORT_FIRMWARE 0x79 // report name and version of the firmware
153+
154+
#ifdef EXTENDED_ANALOG
155+
#undef EXTENDED_ANALOG
156+
#endif
157+
#define EXTENDED_ANALOG 0x6F // analog write (PWM, Servo, etc) to any pin
158+
159+
#ifdef PIN_STATE_QUERY
160+
#undef PIN_STATE_QUERY
161+
#endif
162+
#define PIN_STATE_QUERY 0x6D // ask for a pin's current mode and value
163+
164+
#ifdef PIN_STATE_RESPONSE
165+
#undef PIN_STATE_RESPONSE
166+
#endif
167+
#define PIN_STATE_RESPONSE 0x6E // reply with pin's current mode and value
168+
169+
#ifdef CAPABILITY_QUERY
170+
#undef CAPABILITY_QUERY
171+
#endif
172+
#define CAPABILITY_QUERY 0x6B // ask for supported modes and resolution of all pins
173+
174+
#ifdef CAPABILITY_RESPONSE
175+
#undef CAPABILITY_RESPONSE
176+
#endif
177+
#define CAPABILITY_RESPONSE 0x6C // reply with supported modes and resolution
178+
179+
#ifdef ANALOG_MAPPING_QUERY
180+
#undef ANALOG_MAPPING_QUERY
181+
#endif
182+
#define ANALOG_MAPPING_QUERY 0x69 // ask for mapping of analog to pin numbers
183+
184+
#ifdef ANALOG_MAPPING_RESPONSE
185+
#undef ANALOG_MAPPING_RESPONSE
186+
#endif
187+
#define ANALOG_MAPPING_RESPONSE 0x6A // reply with mapping info
188+
189+
#ifdef SAMPLING_INTERVAL
190+
#undef SAMPLING_INTERVAL
191+
#endif
192+
#define SAMPLING_INTERVAL 0x7A // set the poll rate of the main loop
193+
194+
#ifdef SCHEDULER_DATA
195+
#undef SCHEDULER_DATA
196+
#endif
197+
#define SCHEDULER_DATA 0x7B // send a createtask/deletetask/addtotask/schedule/querytasks/querytask request to the scheduler
198+
199+
#ifdef SYSEX_NON_REALTIME
200+
#undef SYSEX_NON_REALTIME
201+
#endif
202+
#define SYSEX_NON_REALTIME 0x7E // MIDI Reserved for non-realtime messages
203+
204+
#ifdef SYSEX_REALTIME
205+
#undef SYSEX_REALTIME
206+
#endif
207+
#define SYSEX_REALTIME 0x7F // MIDI Reserved for realtime messages
208+
209+
// pin modes
210+
211+
#ifdef PIN_MODE_INPUT
212+
#undef PIN_MODE_INPUT
213+
#endif
214+
#define PIN_MODE_INPUT 0x00 // same as INPUT defined in Arduino.h
215+
216+
#ifdef PIN_MODE_OUTPUT
217+
#undef PIN_MODE_OUTPUT
218+
#endif
219+
#define PIN_MODE_OUTPUT 0x01 // same as OUTPUT defined in Arduino.h
220+
221+
#ifdef PIN_MODE_ANALOG
222+
#undef PIN_MODE_ANALOG
223+
#endif
224+
#define PIN_MODE_ANALOG 0x02 // analog pin in analogInput mode
225+
226+
#ifdef PIN_MODE_PWM
227+
#undef PIN_MODE_PWM
228+
#endif
229+
#define PIN_MODE_PWM 0x03 // digital pin in PWM output mode
230+
231+
#ifdef PIN_MODE_SERVO
232+
#undef PIN_MODE_SERVO
233+
#endif
234+
#define PIN_MODE_SERVO 0x04 // digital pin in Servo output mode
235+
236+
#ifdef PIN_MODE_SHIFT
237+
#undef PIN_MODE_SHIFT
238+
#endif
239+
#define PIN_MODE_SHIFT 0x05 // shiftIn/shiftOut mode
240+
241+
#ifdef PIN_MODE_I2C
242+
#undef PIN_MODE_I2C
243+
#endif
244+
#define PIN_MODE_I2C 0x06 // pin included in I2C setup
245+
246+
#ifdef PIN_MODE_ONEWIRE
247+
#undef PIN_MODE_ONEWIRE
248+
#endif
249+
#define PIN_MODE_ONEWIRE 0x07 // pin configured for 1-wire
250+
251+
#ifdef PIN_MODE_STEPPER
252+
#undef PIN_MODE_STEPPER
253+
#endif
254+
#define PIN_MODE_STEPPER 0x08 // pin configured for stepper motor
255+
256+
#ifdef PIN_MODE_ENCODER
257+
#undef PIN_MODE_ENCODER
258+
#endif
259+
#define PIN_MODE_ENCODER 0x09 // pin configured for rotary encoders
260+
261+
#ifdef PIN_MODE_SERIAL
262+
#undef PIN_MODE_SERIAL
263+
#endif
264+
#define PIN_MODE_SERIAL 0x0A // pin configured for serial communication
265+
266+
#ifdef PIN_MODE_PULLUP
267+
#undef PIN_MODE_PULLUP
268+
#endif
269+
#define PIN_MODE_PULLUP 0x0B // enable internal pull-up resistor for pin
270+
271+
#ifdef PIN_MODE_IGNORE
272+
#undef PIN_MODE_IGNORE
273+
#endif
274+
#define PIN_MODE_IGNORE 0x7F // pin configured to be ignored by digitalWrite and capabilityResponse
275+
276+
#ifdef TOTAL_PIN_MODES
277+
#undef TOTAL_PIN_MODES
278+
#endif
279+
#define TOTAL_PIN_MODES 13
280+
281+
#endif // FirmataConstants_h

0 commit comments

Comments
 (0)