3 Copyright (c) 2006-2008 Hans-Christoph Steiner. All rights reserved.
4 Copyright (C) 2009-2017 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 FirmataConstants_h
15 #define FirmataConstants_h
18 /* Version numbers for the Firmata library.
19 * The firmware version will not always equal the protocol version going forward.
20 * Query using the REPORT_FIRMWARE message.
22 static const int FIRMWARE_MAJOR_VERSION = 2;
23 static const int FIRMWARE_MINOR_VERSION = 5;
24 static const int FIRMWARE_BUGFIX_VERSION = 7;
26 /* Version numbers for the protocol. The protocol is still changing, so these
27 * version numbers are important.
28 * Query using the REPORT_VERSION message.
30 static const int PROTOCOL_MAJOR_VERSION = 2; // for non-compatible changes
31 static const int PROTOCOL_MINOR_VERSION = 5; // for backwards compatible changes
32 static const int PROTOCOL_BUGFIX_VERSION = 1; // for bugfix releases
34 static const int MAX_DATA_BYTES = 64; // max number of data bytes in incoming messages
36 // message command bytes (128-255/0x80-0xFF)
38 static const int DIGITAL_MESSAGE = 0x90; // send data for a digital port (collection of 8 pins)
39 static const int ANALOG_MESSAGE = 0xE0; // send data for an analog pin (or PWM)
40 static const int REPORT_ANALOG = 0xC0; // enable analog input by pin #
41 static const int REPORT_DIGITAL = 0xD0; // enable digital input by port pair
43 static const int SET_PIN_MODE = 0xF4; // set a pin to INPUT/OUTPUT/PWM/etc
44 static const int SET_DIGITAL_PIN_VALUE = 0xF5; // set value of an individual digital pin
46 static const int REPORT_VERSION = 0xF9; // report protocol version
47 static const int SYSTEM_RESET = 0xFF; // reset from MIDI
49 static const int START_SYSEX = 0xF0; // start a MIDI Sysex message
50 static const int END_SYSEX = 0xF7; // end a MIDI Sysex message
52 // extended command set using sysex (0-127/0x00-0x7F)
53 /* 0x00-0x0F reserved for user-defined commands */
55 static const int SERIAL_DATA = 0x60; // communicate with serial devices, including other boards
56 static const int ENCODER_DATA = 0x61; // reply with encoders current positions
57 static const int SERVO_CONFIG = 0x70; // set max angle, minPulse, maxPulse, freq
58 static const int STRING_DATA = 0x71; // a string message with 14-bits per char
59 static const int STEPPER_DATA = 0x72; // control a stepper motor
60 static const int ONEWIRE_DATA = 0x73; // send an OneWire read/write/reset/select/skip/search request
61 static const int SHIFT_DATA = 0x75; // a bitstream to/from a shift register
62 static const int I2C_REQUEST = 0x76; // send an I2C read/write request
63 static const int I2C_REPLY = 0x77; // a reply to an I2C read request
64 static const int I2C_CONFIG = 0x78; // config I2C settings such as delay times and power pins
65 static const int REPORT_FIRMWARE = 0x79; // report name and version of the firmware
66 static const int EXTENDED_ANALOG = 0x6F; // analog write (PWM, Servo, etc) to any pin
67 static const int PIN_STATE_QUERY = 0x6D; // ask for a pin's current mode and value
68 static const int PIN_STATE_RESPONSE = 0x6E; // reply with pin's current mode and value
69 static const int CAPABILITY_QUERY = 0x6B; // ask for supported modes and resolution of all pins
70 static const int CAPABILITY_RESPONSE = 0x6C; // reply with supported modes and resolution
71 static const int ANALOG_MAPPING_QUERY = 0x69; // ask for mapping of analog to pin numbers
72 static const int ANALOG_MAPPING_RESPONSE = 0x6A; // reply with mapping info
73 static const int SAMPLING_INTERVAL = 0x7A; // set the poll rate of the main loop
74 static const int SCHEDULER_DATA = 0x7B; // send a createtask/deletetask/addtotask/schedule/querytasks/querytask request to the scheduler
75 static const int SYSEX_NON_REALTIME = 0x7E; // MIDI Reserved for non-realtime messages
76 static const int SYSEX_REALTIME = 0x7F; // MIDI Reserved for realtime messages
79 static const int PIN_MODE_INPUT = 0x00; // same as INPUT defined in Arduino.h
80 static const int PIN_MODE_OUTPUT = 0x01; // same as OUTPUT defined in Arduino.h
81 static const int PIN_MODE_ANALOG = 0x02; // analog pin in analogInput mode
82 static const int PIN_MODE_PWM = 0x03; // digital pin in PWM output mode
83 static const int PIN_MODE_SERVO = 0x04; // digital pin in Servo output mode
84 static const int PIN_MODE_SHIFT = 0x05; // shiftIn/shiftOut mode
85 static const int PIN_MODE_I2C = 0x06; // pin included in I2C setup
86 static const int PIN_MODE_ONEWIRE = 0x07; // pin configured for 1-wire
87 static const int PIN_MODE_STEPPER = 0x08; // pin configured for stepper motor
88 static const int PIN_MODE_ENCODER = 0x09; // pin configured for rotary encoders
89 static const int PIN_MODE_SERIAL = 0x0A; // pin configured for serial communication
90 static const int PIN_MODE_PULLUP = 0x0B; // enable internal pull-up resistor for pin
91 static const int PIN_MODE_IGNORE = 0x7F; // pin configured to be ignored by digitalWrite and capabilityResponse
93 static const int TOTAL_PIN_MODES = 13;
95 } // namespace firmata
97 #endif // FirmataConstants_h