Skip to content

Commit 0f6c3fc

Browse files
Merge pull request firmata#157 from firmata/reporting
force digital or analog message when enabling digital port or analog pin reporting
2 parents 01f6854 + b759aca commit 0f6c3fc

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

examples/StandardFirmata/StandardFirmata.ino

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,10 @@ void reportAnalogCallback(byte analogPin, int value)
349349
analogInputsToReport = analogInputsToReport &~ (1 << analogPin);
350350
} else {
351351
analogInputsToReport = analogInputsToReport | (1 << analogPin);
352+
// Send pin value immediately. This is helpful when connected via
353+
// ethernet, wi-fi or bluetooth so pin states can be known upon
354+
// reconnecting.
355+
Firmata.sendAnalog(analogPin, analogRead(analogPin));
352356
}
353357
}
354358
// TODO: save status to EEPROM here, if changed
@@ -358,6 +362,10 @@ void reportDigitalCallback(byte port, int value)
358362
{
359363
if (port < TOTAL_PORTS) {
360364
reportPINs[port] = (byte)value;
365+
// Send port value immediately. This is helpful when connected via
366+
// ethernet, wi-fi or bluetooth so pin states can be known upon
367+
// reconnecting.
368+
if (value) outputPort(port, readPort(port, portConfigInputs[port]), true);
361369
}
362370
// do not disable analog reporting on these 8 pins, to allow some
363371
// pins used for digital, others analog. Instead, allow both types

extras/revisions.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
FIRMATA 2.4.0 BETA - not yet released
22

33
[core library]
4-
* Changed the way servo pins are mapped to enable use of servos on
5-
a wider range of pins, including analog pins.
6-
* Updated FirmataServo example to use new pin mapping technique
74
* Changed sendValueAsTwo7bitBytes, startSysex and endSysex from private to
85
public methods.
96
* Added Intel Galileo to Boards.h
@@ -22,6 +19,11 @@ FIRMATA 2.4.0 BETA - not yet released
2219
* Increased input data buffer size from 32 to 64 bytes
2320

2421
[StandardFirmata]
22+
* When a digital port is enabled, its value is now immediately sent to the client
23+
* When an analog pin is enabled, its value is now immediately sent to the client
24+
* Changed the way servo pins are mapped to enable use of servos on
25+
a wider range of pins, including analog pins.
26+
* Updated FirmataServo example to use new pin mapping technique
2527
* Fixed management of unexpected sized I2C replies (Nahuel Greco)
2628
* Fixed a bug when removing a monitored device with I2C_STOP_Reading (Nahuel Greco)
2729
* Fixed conditional expression in I2C_STOP_READING case

0 commit comments

Comments
 (0)