Skip to content

Commit 0a1a1e0

Browse files
provide a way to bypass the version blink sequence
1 parent b8fb38e commit 0a1a1e0

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

Firmata.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,19 @@ void FirmataClass::begin(void)
8181
}
8282

8383
/**
84-
* Initialize the default Serial transport and override the default baud.
84+
* Initialize the default Serial transport and override the default baud.
85+
* Sends the protocol version to the host application followed by the firmware version and name.
86+
* blinkVersion is also called. To skip the call to blinkVersion, call Firmata.disableBlinkVersion()
87+
* before calling Firmata.begin(baud).
8588
* @param speed The baud to use. 57600 baud is the default value.
8689
*/
8790
void FirmataClass::begin(long speed)
8891
{
8992
Serial.begin(speed);
9093
FirmataStream = &Serial;
9194
blinkVersion();
92-
printVersion();
93-
printFirmwareVersion();
95+
printVersion(); // send the protocol version
96+
printFirmwareVersion(); // send the firmware name and version
9497
}
9598

9699
/**
@@ -130,6 +133,7 @@ void FirmataClass::printVersion(void)
130133
void FirmataClass::blinkVersion(void)
131134
{
132135
#if defined(VERSION_BLINK_PIN)
136+
if (blinkVersionDisabled) return;
133137
// flash the pin with the protocol version
134138
pinMode(VERSION_BLINK_PIN, OUTPUT);
135139
strobeBlinkPin(VERSION_BLINK_PIN, FIRMATA_FIRMWARE_MAJOR_VERSION, 40, 210);
@@ -139,6 +143,16 @@ void FirmataClass::blinkVersion(void)
139143
#endif
140144
}
141145

146+
/**
147+
* Provides a means to disable the version blink sequence on the onboard LED, trimming startup
148+
* time by a couple of seconds.
149+
* Call this before Firmata.begin(). It only applies when using the default Serial transport.
150+
*/
151+
void FirmataClass::disableBlinkVersion()
152+
{
153+
blinkVersionDisabled = true;
154+
}
155+
142156
/**
143157
* Sends the firmware name and version to the Firmata host application. The major and minor version
144158
* numbers are the first 2 bytes in the message. The following bytes are the characters of the

Firmata.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class FirmataClass
139139
void printFirmwareVersion(void);
140140
//void setFirmwareVersion(byte major, byte minor); // see macro below
141141
void setFirmwareNameAndVersion(const char *name, byte major, byte minor);
142+
void disableBlinkVersion();
142143
/* serial receive handling */
143144
int available(void);
144145
void processInput(void);
@@ -199,6 +200,8 @@ class FirmataClass
199200
stringCallbackFunction currentStringCallback;
200201
sysexCallbackFunction currentSysexCallback;
201202

203+
boolean blinkVersionDisabled = false;
204+
202205
/* private methods ------------------------------ */
203206
void processSysexMessage(void);
204207
void systemReset(void);

examples/StandardFirmataPlus/StandardFirmataPlus.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,9 @@ void setup()
777777
Firmata.attach(START_SYSEX, sysexCallback);
778778
Firmata.attach(SYSTEM_RESET, systemResetCallback);
779779

780+
// Save a couple of seconds by disabling the startup blink sequence.
781+
Firmata.disableBlinkVersion();
782+
780783
// to use a port other than Serial, such as Serial1 on an Arduino Leonardo or Mega,
781784
// Call begin(baud) on the alternate serial port and pass it to Firmata to begin like this:
782785
// Serial1.begin(57600);

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ startSysex KEYWORD2
4343
endSysex KEYWORD2
4444
writePort KEYWORD2
4545
readPort KEYWORD2
46+
disableBlinkVersion KEYWORD2
4647

4748

4849
#######################################

0 commit comments

Comments
 (0)