Skip to content

Commit 10a4241

Browse files
committed
updated Firmata library to version 2.3.5 and moved to the new library format
1 parent 38c3bbb commit 10a4241

File tree

18 files changed

+162
-316
lines changed

18 files changed

+162
-316
lines changed

hardware/arduino/avr/libraries/Firmata/TODO.txt

-14
This file was deleted.

hardware/arduino/avr/libraries/Firmata/examples/I2CFirmata/I2CFirmata.ino

-228
This file was deleted.

hardware/arduino/avr/libraries/Firmata/examples/EchoString/EchoString.ino renamed to libraries/Firmata/examples/EchoString/EchoString.ino

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
#include <Firmata.h>
1717

18-
byte analogPin;
19-
2018
void stringCallback(char *myString)
2119
{
2220
Firmata.sendString(myString);
+33-29
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ void readAndReportData(byte address, int theRegister, byte numBytes) {
9999
Wire.send((byte)theRegister);
100100
#endif
101101
Wire.endTransmission();
102-
delayMicroseconds(i2cReadDelayTime); // delay is necessary for some devices such as WiiNunchuck
102+
// do not set a value of 0
103+
if (i2cReadDelayTime > 0) {
104+
// delay is necessary for some devices such as WiiNunchuck
105+
delayMicroseconds(i2cReadDelayTime);
106+
}
103107
} else {
104108
theRegister = 0; // fill the register with a dummy value
105109
}
@@ -455,57 +459,57 @@ void sysexCallback(byte command, byte argc, byte *argv)
455459
}
456460
break;
457461
case CAPABILITY_QUERY:
458-
Serial.write(START_SYSEX);
459-
Serial.write(CAPABILITY_RESPONSE);
462+
Firmata.write(START_SYSEX);
463+
Firmata.write(CAPABILITY_RESPONSE);
460464
for (byte pin=0; pin < TOTAL_PINS; pin++) {
461465
if (IS_PIN_DIGITAL(pin)) {
462-
Serial.write((byte)INPUT);
463-
Serial.write(1);
464-
Serial.write((byte)OUTPUT);
465-
Serial.write(1);
466+
Firmata.write((byte)INPUT);
467+
Firmata.write(1);
468+
Firmata.write((byte)OUTPUT);
469+
Firmata.write(1);
466470
}
467471
if (IS_PIN_ANALOG(pin)) {
468-
Serial.write(ANALOG);
469-
Serial.write(10);
472+
Firmata.write(ANALOG);
473+
Firmata.write(10);
470474
}
471475
if (IS_PIN_PWM(pin)) {
472-
Serial.write(PWM);
473-
Serial.write(8);
476+
Firmata.write(PWM);
477+
Firmata.write(8);
474478
}
475479
if (IS_PIN_SERVO(pin)) {
476-
Serial.write(SERVO);
477-
Serial.write(14);
480+
Firmata.write(SERVO);
481+
Firmata.write(14);
478482
}
479483
if (IS_PIN_I2C(pin)) {
480-
Serial.write(I2C);
481-
Serial.write(1); // to do: determine appropriate value
484+
Firmata.write(I2C);
485+
Firmata.write(1); // to do: determine appropriate value
482486
}
483-
Serial.write(127);
487+
Firmata.write(127);
484488
}
485-
Serial.write(END_SYSEX);
489+
Firmata.write(END_SYSEX);
486490
break;
487491
case PIN_STATE_QUERY:
488492
if (argc > 0) {
489493
byte pin=argv[0];
490-
Serial.write(START_SYSEX);
491-
Serial.write(PIN_STATE_RESPONSE);
492-
Serial.write(pin);
494+
Firmata.write(START_SYSEX);
495+
Firmata.write(PIN_STATE_RESPONSE);
496+
Firmata.write(pin);
493497
if (pin < TOTAL_PINS) {
494-
Serial.write((byte)pinConfig[pin]);
495-
Serial.write((byte)pinState[pin] & 0x7F);
496-
if (pinState[pin] & 0xFF80) Serial.write((byte)(pinState[pin] >> 7) & 0x7F);
497-
if (pinState[pin] & 0xC000) Serial.write((byte)(pinState[pin] >> 14) & 0x7F);
498+
Firmata.write((byte)pinConfig[pin]);
499+
Firmata.write((byte)pinState[pin] & 0x7F);
500+
if (pinState[pin] & 0xFF80) Firmata.write((byte)(pinState[pin] >> 7) & 0x7F);
501+
if (pinState[pin] & 0xC000) Firmata.write((byte)(pinState[pin] >> 14) & 0x7F);
498502
}
499-
Serial.write(END_SYSEX);
503+
Firmata.write(END_SYSEX);
500504
}
501505
break;
502506
case ANALOG_MAPPING_QUERY:
503-
Serial.write(START_SYSEX);
504-
Serial.write(ANALOG_MAPPING_RESPONSE);
507+
Firmata.write(START_SYSEX);
508+
Firmata.write(ANALOG_MAPPING_RESPONSE);
505509
for (byte pin=0; pin < TOTAL_PINS; pin++) {
506-
Serial.write(IS_PIN_ANALOG(pin) ? PIN_TO_ANALOG(pin) : 127);
510+
Firmata.write(IS_PIN_ANALOG(pin) ? PIN_TO_ANALOG(pin) : 127);
507511
}
508-
Serial.write(END_SYSEX);
512+
Firmata.write(END_SYSEX);
509513
break;
510514
}
511515
}

libraries/Firmata/library.properties

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name=Firmata
2+
author=Hans-Christoph Steiner
3+
email=Hans-Christoph Steiner <hans@at.or.at> (author), Paul Stoffregen <paul@pjrc.com> (maintainer)
4+
sentence=This library implements the Firmata protocol and allows you to control the Arduino board from the an application on the computer.
5+
paragraph=The Firmata library implements the Firmata protocol for communicating with software on the host computer. This allows you to write custom firmware without having to create your own protocol and objects for the programming environment that you are using.
6+
url=http://arduino.cc/en/Reference/Firmata</br>http://firmata.org
7+
architectures=avr, sam
8+
version=1.0
9+
dependencies= SoftwareSerial
10+
core-dependencies=arduino (>=1.5.0)

0 commit comments

Comments
 (0)