Skip to content

Commit 0821d82

Browse files
minor readability updates
1 parent 611e9f8 commit 0821d82

File tree

5 files changed

+28
-30
lines changed

5 files changed

+28
-30
lines changed

Firmata.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,7 @@ void FirmataClass::sendDigital(byte pin, int value)
302302
* track the last digital data sent so that it can be sure to change just
303303
* one bit in the packet. This is complicated by the fact that the
304304
* numbering of the pins will probably differ on Arduino, Wiring, and
305-
* other boards. The DIGITAL_MESSAGE sends 14 bits at a time, but it is
306-
* probably easier to send 8 bit ports for any board with more than 14
307-
* digital pins.
305+
* other boards.
308306
*/
309307

310308
// TODO: the digital message should not be sent on the serial port every

Firmata.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#define MAX_DATA_BYTES 64 // max number of data bytes in incoming messages
2727

2828
// message command bytes (128-255/0x80-0xFF)
29-
#define DIGITAL_MESSAGE 0x90 // send data for a digital pin
29+
#define DIGITAL_MESSAGE 0x90 // send data for a digital port (collection of 8 pins)
3030
#define ANALOG_MESSAGE 0xE0 // send data for an analog pin (or PWM)
3131
#define REPORT_ANALOG 0xC0 // enable analog input by pin #
3232
#define REPORT_DIGITAL 0xD0 // enable digital input by port pair
@@ -69,8 +69,8 @@
6969
#define SYSEX_SAMPLING_INTERVAL 0x7A // same as SAMPLING_INTERVAL
7070

7171
// pin modes
72-
//#define INPUT 0x00 // defined in wiring.h
73-
//#define OUTPUT 0x01 // defined in wiring.h
72+
//#define INPUT 0x00 // defined in Arduino.h
73+
//#define OUTPUT 0x01 // defined in Arduino.h
7474
#define ANALOG 0x02 // analog pin in analogInput mode
7575
#define PWM 0x03 // digital pin in PWM output mode
7676
#define SERVO 0x04 // digital pin in Servo output mode

examples/StandardFirmata/StandardFirmata.ino

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
#define I2C_STOP_READING B00011000
3434
#define I2C_READ_WRITE_MODE_MASK B00011000
3535
#define I2C_10BIT_ADDRESS_MODE_MASK B00100000
36-
#define MAX_QUERIES 8
37-
#define REGISTER_NOT_SPECIFIED -1
36+
#define I2C_MAX_QUERIES 8
37+
#define I2C_REGISTER_NOT_SPECIFIED -1
3838

3939
// the minimum interval for sampling analog input
4040
#define MINIMUM_SAMPLING_INTERVAL 10
@@ -69,7 +69,7 @@ struct i2c_device_info {
6969
};
7070

7171
/* for i2c read continuous more */
72-
i2c_device_info query[MAX_QUERIES];
72+
i2c_device_info query[I2C_MAX_QUERIES];
7373

7474
byte i2cRxData[32];
7575
boolean isI2CEnabled = false;
@@ -150,7 +150,7 @@ void readAndReportData(byte address, int theRegister, byte numBytes) {
150150
// allow I2C requests that don't require a register read
151151
// for example, some devices using an interrupt pin to signify new data available
152152
// do not always require the register read so upon interrupt you call Wire.requestFrom()
153-
if (theRegister != REGISTER_NOT_SPECIFIED) {
153+
if (theRegister != I2C_REGISTER_NOT_SPECIFIED) {
154154
Wire.beginTransmission(address);
155155
wireWrite((byte)theRegister);
156156
Wire.endTransmission();
@@ -430,13 +430,13 @@ void sysexCallback(byte command, byte argc, byte *argv)
430430
}
431431
else {
432432
// a slave register is NOT specified
433-
slaveRegister = REGISTER_NOT_SPECIFIED;
433+
slaveRegister = I2C_REGISTER_NOT_SPECIFIED;
434434
data = argv[2] + (argv[3] << 7); // bytes to read
435435
}
436436
readAndReportData(slaveAddress, (int)slaveRegister, data);
437437
break;
438438
case I2C_READ_CONTINUOUSLY:
439-
if ((queryIndex + 1) >= MAX_QUERIES) {
439+
if ((queryIndex + 1) >= I2C_MAX_QUERIES) {
440440
// too many queries, just ignore
441441
Firmata.sendString("too many queries");
442442
break;
@@ -448,7 +448,7 @@ void sysexCallback(byte command, byte argc, byte *argv)
448448
}
449449
else {
450450
// a slave register is NOT specified
451-
slaveRegister = (int)REGISTER_NOT_SPECIFIED;
451+
slaveRegister = (int)I2C_REGISTER_NOT_SPECIFIED;
452452
data = argv[2] + (argv[3] << 7); // bytes to read
453453
}
454454
queryIndex++;
@@ -474,7 +474,7 @@ void sysexCallback(byte command, byte argc, byte *argv)
474474
}
475475

476476
for (byte i = queryIndexToSkip; i < queryIndex + 1; i++) {
477-
if (i < MAX_QUERIES) {
477+
if (i < I2C_MAX_QUERIES) {
478478
query[i].addr = query[i + 1].addr;
479479
query[i].reg = query[i + 1].reg;
480480
query[i].bytes = query[i + 1].bytes;

examples/StandardFirmataChipKIT/StandardFirmataChipKIT.ino

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
#define I2C_STOP_READING B00011000
3535
#define I2C_READ_WRITE_MODE_MASK B00011000
3636
#define I2C_10BIT_ADDRESS_MODE_MASK B00100000
37-
#define MAX_QUERIES 8
38-
#define REGISTER_NOT_SPECIFIED -1
37+
#define I2C_MAX_QUERIES 8
38+
#define I2C_REGISTER_NOT_SPECIFIED -1
3939

4040
// the minimum interval for sampling analog input
4141
#define MINIMUM_SAMPLING_INTERVAL 10
@@ -70,7 +70,7 @@ struct i2c_device_info {
7070
};
7171

7272
/* for i2c read continuous more */
73-
i2c_device_info query[MAX_QUERIES];
73+
i2c_device_info query[I2C_MAX_QUERIES];
7474

7575
byte i2cRxData[32];
7676
boolean isI2CEnabled = false;
@@ -151,7 +151,7 @@ void readAndReportData(byte address, int theRegister, byte numBytes) {
151151
// allow I2C requests that don't require a register read
152152
// for example, some devices using an interrupt pin to signify new data available
153153
// do not always require the register read so upon interrupt you call Wire.requestFrom()
154-
if (theRegister != REGISTER_NOT_SPECIFIED) {
154+
if (theRegister != I2C_REGISTER_NOT_SPECIFIED) {
155155
Wire.beginTransmission(address);
156156
wireWrite((byte)theRegister);
157157
Wire.endTransmission();
@@ -441,13 +441,13 @@ void sysexCallback(byte command, byte argc, byte *argv)
441441
}
442442
else {
443443
// a slave register is NOT specified
444-
slaveRegister = REGISTER_NOT_SPECIFIED;
444+
slaveRegister = I2C_REGISTER_NOT_SPECIFIED;
445445
data = argv[2] + (argv[3] << 7); // bytes to read
446446
}
447447
readAndReportData(slaveAddress, (int)slaveRegister, data);
448448
break;
449449
case I2C_READ_CONTINUOUSLY:
450-
if ((queryIndex + 1) >= MAX_QUERIES) {
450+
if ((queryIndex + 1) >= I2C_MAX_QUERIES) {
451451
// too many queries, just ignore
452452
Firmata.sendString("too many queries");
453453
break;
@@ -459,7 +459,7 @@ void sysexCallback(byte command, byte argc, byte *argv)
459459
}
460460
else {
461461
// a slave register is NOT specified
462-
slaveRegister = (int)REGISTER_NOT_SPECIFIED;
462+
slaveRegister = (int)I2C_REGISTER_NOT_SPECIFIED;
463463
data = argv[2] + (argv[3] << 7); // bytes to read
464464
}
465465
queryIndex++;
@@ -485,7 +485,7 @@ void sysexCallback(byte command, byte argc, byte *argv)
485485
}
486486

487487
for (byte i = queryIndexToSkip; i < queryIndex + 1; i++) {
488-
if (i < MAX_QUERIES) {
488+
if (i < I2C_MAX_QUERIES) {
489489
query[i].addr = query[i + 1].addr;
490490
query[i].reg = query[i + 1].reg;
491491
query[i].bytes = query[i + 1].bytes;

examples/StandardFirmataYun/StandardFirmataYun.ino

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
#define I2C_STOP_READING B00011000
4646
#define I2C_READ_WRITE_MODE_MASK B00011000
4747
#define I2C_10BIT_ADDRESS_MODE_MASK B00100000
48-
#define MAX_QUERIES 8
49-
#define REGISTER_NOT_SPECIFIED -1
48+
#define I2C_MAX_QUERIES 8
49+
#define I2C_REGISTER_NOT_SPECIFIED -1
5050

5151
// the minimum interval for sampling analog input
5252
#define MINIMUM_SAMPLING_INTERVAL 10
@@ -81,7 +81,7 @@ struct i2c_device_info {
8181
};
8282

8383
/* for i2c read continuous more */
84-
i2c_device_info query[MAX_QUERIES];
84+
i2c_device_info query[I2C_MAX_QUERIES];
8585

8686
byte i2cRxData[32];
8787
boolean isI2CEnabled = false;
@@ -162,7 +162,7 @@ void readAndReportData(byte address, int theRegister, byte numBytes) {
162162
// allow I2C requests that don't require a register read
163163
// for example, some devices using an interrupt pin to signify new data available
164164
// do not always require the register read so upon interrupt you call Wire.requestFrom()
165-
if (theRegister != REGISTER_NOT_SPECIFIED) {
165+
if (theRegister != I2C_REGISTER_NOT_SPECIFIED) {
166166
Wire.beginTransmission(address);
167167
wireWrite((byte)theRegister);
168168
Wire.endTransmission();
@@ -442,13 +442,13 @@ void sysexCallback(byte command, byte argc, byte *argv)
442442
}
443443
else {
444444
// a slave register is NOT specified
445-
slaveRegister = REGISTER_NOT_SPECIFIED;
445+
slaveRegister = I2C_REGISTER_NOT_SPECIFIED;
446446
data = argv[2] + (argv[3] << 7); // bytes to read
447447
}
448448
readAndReportData(slaveAddress, (int)slaveRegister, data);
449449
break;
450450
case I2C_READ_CONTINUOUSLY:
451-
if ((queryIndex + 1) >= MAX_QUERIES) {
451+
if ((queryIndex + 1) >= I2C_MAX_QUERIES) {
452452
// too many queries, just ignore
453453
Firmata.sendString("too many queries");
454454
break;
@@ -460,7 +460,7 @@ void sysexCallback(byte command, byte argc, byte *argv)
460460
}
461461
else {
462462
// a slave register is NOT specified
463-
slaveRegister = (int)REGISTER_NOT_SPECIFIED;
463+
slaveRegister = (int)I2C_REGISTER_NOT_SPECIFIED;
464464
data = argv[2] + (argv[3] << 7); // bytes to read
465465
}
466466
queryIndex++;
@@ -486,7 +486,7 @@ void sysexCallback(byte command, byte argc, byte *argv)
486486
}
487487

488488
for (byte i = queryIndexToSkip; i < queryIndex + 1; i++) {
489-
if (i < MAX_QUERIES) {
489+
if (i < I2C_MAX_QUERIES) {
490490
query[i].addr = query[i + 1].addr;
491491
query[i].reg = query[i + 1].reg;
492492
query[i].bytes = query[i + 1].bytes;

0 commit comments

Comments
 (0)