Skip to content

Commit 609341b

Browse files
Merge pull request #310 from firmata/older-ide-fixes
Fix compiler issues for older Arduino IDE versions
2 parents 1de9c19 + 3d9d50a commit 609341b

File tree

10 files changed

+208
-158
lines changed

10 files changed

+208
-158
lines changed

Firmata.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ FirmataClass::FirmataClass()
6565
{
6666
firmwareVersionCount = 0;
6767
firmwareVersionVector = 0;
68+
blinkVersionDisabled = false;
6869
systemReset();
6970
}
7071

Firmata.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
Firmata.h - Firmata library v2.5.3 - 2016-06-18
33
Copyright (c) 2006-2008 Hans-Christoph Steiner. All rights reserved.
4-
Copyright (C) 2009-2015 Jeff Hoefs. All rights reserved.
4+
Copyright (C) 2009-2016 Jeff Hoefs. All rights reserved.
55
66
This library is free software; you can redistribute it and/or
77
modify it under the terms of the GNU Lesser General Public
@@ -201,7 +201,7 @@ class FirmataClass
201201
stringCallbackFunction currentStringCallback;
202202
sysexCallbackFunction currentSysexCallback;
203203

204-
boolean blinkVersionDisabled = false;
204+
boolean blinkVersionDisabled;
205205

206206
/* private methods ------------------------------ */
207207
void processSysexMessage(void);

examples/StandardFirmata/StandardFirmata.ino

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
See file LICENSE.txt for further informations on licensing terms.
2222
23-
Last updated by Jeff Hoefs: January 10th, 2016
23+
Last updated October 16th, 2016
2424
*/
2525

2626
#include <Servo.h>
@@ -91,6 +91,11 @@ byte servoCount = 0;
9191

9292
boolean isResetting = false;
9393

94+
// Forward declare a few functions to avoid compiler errors with older versions
95+
// of the Arduino IDE.
96+
void setPinModeCallback(byte, int);
97+
void reportAnalogCallback(byte analogPin, int value);
98+
void sysexCallback(byte, byte, byte*);
9499

95100
/* utility functions */
96101
void wireWrite(byte data)
@@ -153,6 +158,30 @@ void detachServo(byte pin)
153158
servoPinMap[pin] = 255;
154159
}
155160

161+
void enableI2CPins()
162+
{
163+
byte i;
164+
// is there a faster way to do this? would probaby require importing
165+
// Arduino.h to get SCL and SDA pins
166+
for (i = 0; i < TOTAL_PINS; i++) {
167+
if (IS_PIN_I2C(i)) {
168+
// mark pins as i2c so they are ignore in non i2c data requests
169+
setPinModeCallback(i, PIN_MODE_I2C);
170+
}
171+
}
172+
173+
isI2CEnabled = true;
174+
175+
Wire.begin();
176+
}
177+
178+
/* disable the i2c pins so they can be used for other functions */
179+
void disableI2CPins() {
180+
isI2CEnabled = false;
181+
// disable read continuous mode for all devices
182+
queryIndex = -1;
183+
}
184+
156185
void readAndReportData(byte address, int theRegister, byte numBytes, byte stopTX) {
157186
// allow I2C requests that don't require a register read
158187
// for example, some devices using an interrupt pin to signify new data available
@@ -664,30 +693,6 @@ void sysexCallback(byte command, byte argc, byte *argv)
664693
}
665694
}
666695

667-
void enableI2CPins()
668-
{
669-
byte i;
670-
// is there a faster way to do this? would probaby require importing
671-
// Arduino.h to get SCL and SDA pins
672-
for (i = 0; i < TOTAL_PINS; i++) {
673-
if (IS_PIN_I2C(i)) {
674-
// mark pins as i2c so they are ignore in non i2c data requests
675-
setPinModeCallback(i, PIN_MODE_I2C);
676-
}
677-
}
678-
679-
isI2CEnabled = true;
680-
681-
Wire.begin();
682-
}
683-
684-
/* disable the i2c pins so they can be used for other functions */
685-
void disableI2CPins() {
686-
isI2CEnabled = false;
687-
// disable read continuous mode for all devices
688-
queryIndex = -1;
689-
}
690-
691696
/*==============================================================================
692697
* SETUP()
693698
*============================================================================*/

examples/StandardFirmataBLE/StandardFirmataBLE.ino

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
See file LICENSE.txt for further informations on licensing terms.
2222
23-
Last updated June 15th, 2016
23+
Last updated October 16th, 2016
2424
*/
2525

2626
#include <Servo.h>
@@ -34,6 +34,8 @@
3434
* Uncomment the following include to enable interfacing
3535
* with Serial devices via hardware or software serial.
3636
*/
37+
// In order to use software serial, you will need to compile this sketch with
38+
// Arduino IDE v1.6.6 or higher. Hardware serial should work back to Arduino 1.0.
3739
//#include "utility/SerialFirmata.h"
3840

3941
// follow the instructions in bleConfig.h to configure your BLE hardware
@@ -106,6 +108,12 @@ byte servoCount = 0;
106108

107109
boolean isResetting = false;
108110

111+
// Forward declare a few functions to avoid compiler errors with older versions
112+
// of the Arduino IDE.
113+
void setPinModeCallback(byte, int);
114+
void reportAnalogCallback(byte analogPin, int value);
115+
void sysexCallback(byte, byte, byte*);
116+
109117
/* utility functions */
110118
void wireWrite(byte data)
111119
{
@@ -167,6 +175,30 @@ void detachServo(byte pin)
167175
servoPinMap[pin] = 255;
168176
}
169177

178+
void enableI2CPins()
179+
{
180+
byte i;
181+
// is there a faster way to do this? would probaby require importing
182+
// Arduino.h to get SCL and SDA pins
183+
for (i = 0; i < TOTAL_PINS; i++) {
184+
if (IS_PIN_I2C(i)) {
185+
// mark pins as i2c so they are ignore in non i2c data requests
186+
setPinModeCallback(i, PIN_MODE_I2C);
187+
}
188+
}
189+
190+
isI2CEnabled = true;
191+
192+
Wire.begin();
193+
}
194+
195+
/* disable the i2c pins so they can be used for other functions */
196+
void disableI2CPins() {
197+
isI2CEnabled = false;
198+
// disable read continuous mode for all devices
199+
queryIndex = -1;
200+
}
201+
170202
void readAndReportData(byte address, int theRegister, byte numBytes, byte stopTX) {
171203
// allow I2C requests that don't require a register read
172204
// for example, some devices using an interrupt pin to signify new data available
@@ -678,30 +710,6 @@ void sysexCallback(byte command, byte argc, byte *argv)
678710
}
679711
}
680712

681-
void enableI2CPins()
682-
{
683-
byte i;
684-
// is there a faster way to do this? would probaby require importing
685-
// Arduino.h to get SCL and SDA pins
686-
for (i = 0; i < TOTAL_PINS; i++) {
687-
if (IS_PIN_I2C(i)) {
688-
// mark pins as i2c so they are ignore in non i2c data requests
689-
setPinModeCallback(i, PIN_MODE_I2C);
690-
}
691-
}
692-
693-
isI2CEnabled = true;
694-
695-
Wire.begin();
696-
}
697-
698-
/* disable the i2c pins so they can be used for other functions */
699-
void disableI2CPins() {
700-
isI2CEnabled = false;
701-
// disable read continuous mode for all devices
702-
queryIndex = -1;
703-
}
704-
705713
/*==============================================================================
706714
* SETUP()
707715
*============================================================================*/

examples/StandardFirmataChipKIT/StandardFirmataChipKIT.ino

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
2222
See file LICENSE.txt for further informations on licensing terms.
2323
24-
Last updated by Jeff Hoefs: January 10th, 2016
24+
Last updated October 16th, 2016
2525
*/
2626

2727
#include <SoftPWMServo.h> // Gives us PWM and Servo on every pin
@@ -88,6 +88,12 @@ byte servoCount = 0;
8888

8989
boolean isResetting = false;
9090

91+
// Forward declare a few functions to avoid compiler errors with older versions
92+
// of the Arduino IDE.
93+
void setPinModeCallback(byte, int);
94+
void reportAnalogCallback(byte analogPin, int value);
95+
void sysexCallback(byte, byte, byte*);
96+
9197
/* utility functions */
9298
void wireWrite(byte data)
9399
{
@@ -149,6 +155,30 @@ void detachServo(byte pin)
149155
servoPinMap[pin] = 255;
150156
}
151157

158+
void enableI2CPins()
159+
{
160+
byte i;
161+
// is there a faster way to do this? would probaby require importing
162+
// Arduino.h to get SCL and SDA pins
163+
for (i = 0; i < TOTAL_PINS; i++) {
164+
if (IS_PIN_I2C(i)) {
165+
// mark pins as i2c so they are ignore in non i2c data requests
166+
setPinModeCallback(i, PIN_MODE_I2C);
167+
}
168+
}
169+
170+
isI2CEnabled = true;
171+
172+
Wire.begin();
173+
}
174+
175+
/* disable the i2c pins so they can be used for other functions */
176+
void disableI2CPins() {
177+
isI2CEnabled = false;
178+
// disable read continuous mode for all devices
179+
queryIndex = -1;
180+
}
181+
152182
void readAndReportData(byte address, int theRegister, byte numBytes, byte stopTX) {
153183
// allow I2C requests that don't require a register read
154184
// for example, some devices using an interrupt pin to signify new data available
@@ -656,30 +686,6 @@ void sysexCallback(byte command, byte argc, byte *argv)
656686
}
657687
}
658688

659-
void enableI2CPins()
660-
{
661-
byte i;
662-
// is there a faster way to do this? would probaby require importing
663-
// Arduino.h to get SCL and SDA pins
664-
for (i = 0; i < TOTAL_PINS; i++) {
665-
if (IS_PIN_I2C(i)) {
666-
// mark pins as i2c so they are ignore in non i2c data requests
667-
setPinModeCallback(i, PIN_MODE_I2C);
668-
}
669-
}
670-
671-
isI2CEnabled = true;
672-
673-
Wire.begin();
674-
}
675-
676-
/* disable the i2c pins so they can be used for other functions */
677-
void disableI2CPins() {
678-
isI2CEnabled = false;
679-
// disable read continuous mode for all devices
680-
queryIndex = -1;
681-
}
682-
683689
/*==============================================================================
684690
* SETUP()
685691
*============================================================================*/

examples/StandardFirmataEthernet/StandardFirmataEthernet.ino

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
See file LICENSE.txt for further informations on licensing terms.
2222
23-
Last updated by Jeff Hoefs: June 18th, 2016
23+
Last updated October 16th, 2016
2424
*/
2525

2626
/*
@@ -78,6 +78,8 @@
7878
* remaining to reliably run Firmata. Arduino Yun is okay because it doesn't import the Ethernet
7979
* libraries.
8080
*/
81+
// In order to use software serial, you will need to compile this sketch with
82+
// Arduino IDE v1.6.6 or higher. Hardware serial should work back to Arduino 1.0.
8183
//#include "utility/SerialFirmata.h"
8284

8385
#define I2C_WRITE B00000000
@@ -159,6 +161,12 @@ byte servoCount = 0;
159161

160162
boolean isResetting = false;
161163

164+
// Forward declare a few functions to avoid compiler errors with older versions
165+
// of the Arduino IDE.
166+
void setPinModeCallback(byte, int);
167+
void reportAnalogCallback(byte analogPin, int value);
168+
void sysexCallback(byte, byte, byte*);
169+
162170
/* utility functions */
163171
void wireWrite(byte data)
164172
{
@@ -220,6 +228,30 @@ void detachServo(byte pin)
220228
servoPinMap[pin] = 255;
221229
}
222230

231+
void enableI2CPins()
232+
{
233+
byte i;
234+
// is there a faster way to do this? would probaby require importing
235+
// Arduino.h to get SCL and SDA pins
236+
for (i = 0; i < TOTAL_PINS; i++) {
237+
if (IS_PIN_I2C(i)) {
238+
// mark pins as i2c so they are ignore in non i2c data requests
239+
setPinModeCallback(i, PIN_MODE_I2C);
240+
}
241+
}
242+
243+
isI2CEnabled = true;
244+
245+
Wire.begin();
246+
}
247+
248+
/* disable the i2c pins so they can be used for other functions */
249+
void disableI2CPins() {
250+
isI2CEnabled = false;
251+
// disable read continuous mode for all devices
252+
queryIndex = -1;
253+
}
254+
223255
void readAndReportData(byte address, int theRegister, byte numBytes, byte stopTX) {
224256
// allow I2C requests that don't require a register read
225257
// for example, some devices using an interrupt pin to signify new data available
@@ -732,30 +764,6 @@ void sysexCallback(byte command, byte argc, byte *argv)
732764
}
733765
}
734766

735-
void enableI2CPins()
736-
{
737-
byte i;
738-
// is there a faster way to do this? would probaby require importing
739-
// Arduino.h to get SCL and SDA pins
740-
for (i = 0; i < TOTAL_PINS; i++) {
741-
if (IS_PIN_I2C(i)) {
742-
// mark pins as i2c so they are ignore in non i2c data requests
743-
setPinModeCallback(i, PIN_MODE_I2C);
744-
}
745-
}
746-
747-
isI2CEnabled = true;
748-
749-
Wire.begin();
750-
}
751-
752-
/* disable the i2c pins so they can be used for other functions */
753-
void disableI2CPins() {
754-
isI2CEnabled = false;
755-
// disable read continuous mode for all devices
756-
queryIndex = -1;
757-
}
758-
759767
/*==============================================================================
760768
* SETUP()
761769
*============================================================================*/

0 commit comments

Comments
 (0)