File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -147,7 +147,11 @@ void EncoderFirmata::report()
147147{
148148 if (autoReport)
149149 {
150- reportPositions ();
150+ byte encoder;
151+ for (encoder=0 ; encoder<MAX_ENCODERS; encoder++)
152+ {
153+ reportPosition (encoder);
154+ }
151155 }
152156}
153157
@@ -199,7 +203,17 @@ void EncoderFirmata::reportPositions()
199203 byte encoder;
200204 for (encoder=0 ; encoder<MAX_ENCODERS; encoder++)
201205 {
202- reportPosition (encoder);
206+ if (isEncoderAttached (encoderNum))
207+ {
208+ signed long position = encoders[encoder]->read ();
209+ long absValue = abs (position);
210+ Firmata.write (encoder);
211+ Firmata.write (position >= 0 ? 0x00 : 0x01 );
212+ Firmata.write ((byte)absValue & 0x7F );
213+ Firmata.write ((byte)(absValue >> 7 ) & 0x7F );
214+ Firmata.write ((byte)(absValue >> 14 ) & 0x7F );
215+ Firmata.write ((byte)(absValue >> 21 ) & 0x7F );
216+ }
203217 }
204218 Firmata.write (END_SYSEX);
205219}
You can’t perform that action at this time.
0 commit comments