Skip to content

Commit

Permalink
Merge pull request #256 from firmata/optional-blink
Browse files Browse the repository at this point in the history
make VERSION_BLINK_PIN optional
  • Loading branch information
soundanalogous committed Dec 24, 2015
2 parents 768bc84 + e587ce5 commit 59fb214
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
22 changes: 7 additions & 15 deletions Firmata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ void FirmataClass::printVersion(void)

void FirmataClass::blinkVersion(void)
{
#if defined(VERSION_BLINK_PIN)
// flash the pin with the protocol version
pinMode(VERSION_BLINK_PIN, OUTPUT);
strobeBlinkPin(FIRMATA_MAJOR_VERSION, 40, 210);
strobeBlinkPin(VERSION_BLINK_PIN, FIRMATA_MAJOR_VERSION, 40, 210);
delay(250);
strobeBlinkPin(FIRMATA_MINOR_VERSION, 40, 210);
strobeBlinkPin(VERSION_BLINK_PIN, FIRMATA_MINOR_VERSION, 40, 210);
delay(125);
#endif
}

void FirmataClass::printFirmwareVersion(void)
Expand Down Expand Up @@ -161,7 +163,6 @@ int FirmataClass::available(void)
return FirmataStream->available();
}


void FirmataClass::processSysexMessage(void)
{
switch (storedInputData[0]) { //first byte in buffer is command
Expand Down Expand Up @@ -330,7 +331,6 @@ void FirmataClass::sendDigitalPort(byte portNumber, int portData)
FirmataStream->write(portData >> 7); // Tx bits 7-13
}


void FirmataClass::sendSysex(byte command, byte bytec, byte *bytev)
{
byte i;
Expand All @@ -347,7 +347,6 @@ void FirmataClass::sendString(byte command, const char *string)
sendSysex(command, strlen(string), (byte *)string);
}


// send a string as the protocol string type
void FirmataClass::sendString(const char *string)
{
Expand All @@ -360,7 +359,6 @@ void FirmataClass::write(byte c)
FirmataStream->write(c);
}


// Internal Actions/////////////////////////////////////////////////////////////

// generic callbacks
Expand Down Expand Up @@ -428,8 +426,6 @@ void FirmataClass::detach(byte command)
//* Private Methods
//******************************************************************************



// resets the system state upon a SYSTEM_RESET message from the host software
void FirmataClass::systemReset(void)
{
Expand All @@ -450,22 +446,18 @@ void FirmataClass::systemReset(void)
(*currentSystemResetCallback)();
}



// =============================================================================
// used for flashing the pin for the version number
void FirmataClass::strobeBlinkPin(int count, int onInterval, int offInterval)
void FirmataClass::strobeBlinkPin(byte pin, int count, int onInterval, int offInterval)
{
byte i;
pinMode(VERSION_BLINK_PIN, OUTPUT);
for (i = 0; i < count; i++) {
delay(offInterval);
digitalWrite(VERSION_BLINK_PIN, HIGH);
digitalWrite(pin, HIGH);
delay(onInterval);
digitalWrite(VERSION_BLINK_PIN, LOW);
digitalWrite(pin, LOW);
}
}


// make one instance for the user to use
FirmataClass Firmata;
2 changes: 1 addition & 1 deletion Firmata.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class FirmataClass
/* private methods ------------------------------ */
void processSysexMessage(void);
void systemReset(void);
void strobeBlinkPin(int count, int onInterval, int offInterval);
void strobeBlinkPin(byte pin, int count, int onInterval, int offInterval);
};

extern FirmataClass Firmata;
Expand Down

0 comments on commit 59fb214

Please sign in to comment.