Skip to content

Commit 5da81d6

Browse files
forward declare some functions to avoid complier errors in old IDE versions
1 parent b75fff7 commit 5da81d6

File tree

6 files changed

+171
-149
lines changed

6 files changed

+171
-149
lines changed

examples/StandardFirmata/StandardFirmata.ino

Lines changed: 28 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,9 @@ byte servoCount = 0;
9191

9292
boolean isResetting = false;
9393

94+
void setPinModeCallback(byte, int);
95+
void reportAnalogCallback(byte analogPin, int value);
96+
void sysexCallback(byte, byte, byte*);
9497

9598
/* utility functions */
9699
void wireWrite(byte data)
@@ -153,6 +156,30 @@ void detachServo(byte pin)
153156
servoPinMap[pin] = 255;
154157
}
155158

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

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-
691694
/*==============================================================================
692695
* SETUP()
693696
*============================================================================*/

examples/StandardFirmataBLE/StandardFirmataBLE.ino

Lines changed: 29 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>
@@ -108,6 +108,10 @@ byte servoCount = 0;
108108

109109
boolean isResetting = false;
110110

111+
void setPinModeCallback(byte, int);
112+
void reportAnalogCallback(byte analogPin, int value);
113+
void sysexCallback(byte, byte, byte*);
114+
111115
/* utility functions */
112116
void wireWrite(byte data)
113117
{
@@ -169,6 +173,30 @@ void detachServo(byte pin)
169173
servoPinMap[pin] = 255;
170174
}
171175

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

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

examples/StandardFirmataChipKIT/StandardFirmataChipKIT.ino

Lines changed: 29 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,10 @@ byte servoCount = 0;
8888

8989
boolean isResetting = false;
9090

91+
void setPinModeCallback(byte, int);
92+
void reportAnalogCallback(byte analogPin, int value);
93+
void sysexCallback(byte, byte, byte*);
94+
9195
/* utility functions */
9296
void wireWrite(byte data)
9397
{
@@ -149,6 +153,30 @@ void detachServo(byte pin)
149153
servoPinMap[pin] = 255;
150154
}
151155

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

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-
683687
/*==============================================================================
684688
* SETUP()
685689
*============================================================================*/

examples/StandardFirmataEthernet/StandardFirmataEthernet.ino

Lines changed: 29 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
/*
@@ -161,6 +161,10 @@ byte servoCount = 0;
161161

162162
boolean isResetting = false;
163163

164+
void setPinModeCallback(byte, int);
165+
void reportAnalogCallback(byte analogPin, int value);
166+
void sysexCallback(byte, byte, byte*);
167+
164168
/* utility functions */
165169
void wireWrite(byte data)
166170
{
@@ -222,6 +226,30 @@ void detachServo(byte pin)
222226
servoPinMap[pin] = 255;
223227
}
224228

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

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

examples/StandardFirmataPlus/StandardFirmataPlus.ino

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ byte servoCount = 0;
116116

117117
boolean isResetting = false;
118118

119+
void setPinModeCallback(byte, int);
120+
void reportAnalogCallback(byte analogPin, int value);
121+
void sysexCallback(byte, byte, byte*);
119122

120123
/* utility functions */
121124
void wireWrite(byte data)
@@ -178,6 +181,30 @@ void detachServo(byte pin)
178181
servoPinMap[pin] = 255;
179182
}
180183

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

692-
void enableI2CPins()
693-
{
694-
byte i;
695-
// is there a faster way to do this? would probaby require importing
696-
// Arduino.h to get SCL and SDA pins
697-
for (i = 0; i < TOTAL_PINS; i++) {
698-
if (IS_PIN_I2C(i)) {
699-
// mark pins as i2c so they are ignore in non i2c data requests
700-
setPinModeCallback(i, PIN_MODE_I2C);
701-
}
702-
}
703-
704-
isI2CEnabled = true;
705-
706-
Wire.begin();
707-
}
708-
709-
/* disable the i2c pins so they can be used for other functions */
710-
void disableI2CPins() {
711-
isI2CEnabled = false;
712-
// disable read continuous mode for all devices
713-
queryIndex = -1;
714-
}
715-
716719
/*==============================================================================
717720
* SETUP()
718721
*============================================================================*/

0 commit comments

Comments
 (0)