Skip to content

Commit 35aad7d

Browse files
committed
fix
1 parent fdffde9 commit 35aad7d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

utility/EncoderFirmata.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ void EncoderFirmata::attachEncoder(byte encoderNum, byte pinANum, byte pinBNum)
4545
{
4646
//Firmata.sendString("Encoder Warning: For better performences, you should only use Interrput pins.");
4747
}
48-
if (Firmata.getPinMode(pinANum)==IGNORE || Firmata.getPinMode(pinBNum)==IGNORE)
49-
return false;
5048
Firmata.setPinMode(pinANum, ENCODER);
5149
Firmata.setPinMode(pinBNum, ENCODER);
5250
encoders[encoderNum] = new Encoder(pinANum, pinBNum);
@@ -99,6 +97,10 @@ boolean EncoderFirmata::handleSysex(byte command, byte argc, byte *argv)
9997
encoderNum = argv[1];
10098
pinA = argv[2];
10199
pinB = argv[3];
100+
if (Firmata.getPinMode(pinA)==IGNORE || Firmata.getPinMode(pinB)==IGNORE)
101+
{
102+
return false;
103+
}
102104
attachEncoder(encoderNum, pinA, pinB);
103105
return true;
104106
}

0 commit comments

Comments
 (0)