@@ -99,7 +99,11 @@ void readAndReportData(byte address, int theRegister, byte numBytes) {
99
99
Wire.send ((byte)theRegister);
100
100
#endif
101
101
Wire.endTransmission ();
102
- delayMicroseconds (i2cReadDelayTime); // delay is necessary for some devices such as WiiNunchuck
102
+ // do not set a value of 0
103
+ if (i2cReadDelayTime > 0 ) {
104
+ // delay is necessary for some devices such as WiiNunchuck
105
+ delayMicroseconds (i2cReadDelayTime);
106
+ }
103
107
} else {
104
108
theRegister = 0 ; // fill the register with a dummy value
105
109
}
@@ -455,57 +459,57 @@ void sysexCallback(byte command, byte argc, byte *argv)
455
459
}
456
460
break ;
457
461
case CAPABILITY_QUERY:
458
- Serial .write (START_SYSEX);
459
- Serial .write (CAPABILITY_RESPONSE);
462
+ Firmata .write (START_SYSEX);
463
+ Firmata .write (CAPABILITY_RESPONSE);
460
464
for (byte pin=0 ; pin < TOTAL_PINS; pin++) {
461
465
if (IS_PIN_DIGITAL (pin)) {
462
- Serial .write ((byte)INPUT);
463
- Serial .write (1 );
464
- Serial .write ((byte)OUTPUT);
465
- Serial .write (1 );
466
+ Firmata .write ((byte)INPUT);
467
+ Firmata .write (1 );
468
+ Firmata .write ((byte)OUTPUT);
469
+ Firmata .write (1 );
466
470
}
467
471
if (IS_PIN_ANALOG (pin)) {
468
- Serial .write (ANALOG);
469
- Serial .write (10 );
472
+ Firmata .write (ANALOG);
473
+ Firmata .write (10 );
470
474
}
471
475
if (IS_PIN_PWM (pin)) {
472
- Serial .write (PWM);
473
- Serial .write (8 );
476
+ Firmata .write (PWM);
477
+ Firmata .write (8 );
474
478
}
475
479
if (IS_PIN_SERVO (pin)) {
476
- Serial .write (SERVO);
477
- Serial .write (14 );
480
+ Firmata .write (SERVO);
481
+ Firmata .write (14 );
478
482
}
479
483
if (IS_PIN_I2C (pin)) {
480
- Serial .write (I2C);
481
- Serial .write (1 ); // to do: determine appropriate value
484
+ Firmata .write (I2C);
485
+ Firmata .write (1 ); // to do: determine appropriate value
482
486
}
483
- Serial .write (127 );
487
+ Firmata .write (127 );
484
488
}
485
- Serial .write (END_SYSEX);
489
+ Firmata .write (END_SYSEX);
486
490
break ;
487
491
case PIN_STATE_QUERY:
488
492
if (argc > 0 ) {
489
493
byte pin=argv[0 ];
490
- Serial .write (START_SYSEX);
491
- Serial .write (PIN_STATE_RESPONSE);
492
- Serial .write (pin);
494
+ Firmata .write (START_SYSEX);
495
+ Firmata .write (PIN_STATE_RESPONSE);
496
+ Firmata .write (pin);
493
497
if (pin < TOTAL_PINS) {
494
- Serial .write ((byte)pinConfig[pin]);
495
- Serial .write ((byte)pinState[pin] & 0x7F );
496
- if (pinState[pin] & 0xFF80 ) Serial .write ((byte)(pinState[pin] >> 7 ) & 0x7F );
497
- if (pinState[pin] & 0xC000 ) Serial .write ((byte)(pinState[pin] >> 14 ) & 0x7F );
498
+ Firmata .write ((byte)pinConfig[pin]);
499
+ Firmata .write ((byte)pinState[pin] & 0x7F );
500
+ if (pinState[pin] & 0xFF80 ) Firmata .write ((byte)(pinState[pin] >> 7 ) & 0x7F );
501
+ if (pinState[pin] & 0xC000 ) Firmata .write ((byte)(pinState[pin] >> 14 ) & 0x7F );
498
502
}
499
- Serial .write (END_SYSEX);
503
+ Firmata .write (END_SYSEX);
500
504
}
501
505
break ;
502
506
case ANALOG_MAPPING_QUERY:
503
- Serial .write (START_SYSEX);
504
- Serial .write (ANALOG_MAPPING_RESPONSE);
507
+ Firmata .write (START_SYSEX);
508
+ Firmata .write (ANALOG_MAPPING_RESPONSE);
505
509
for (byte pin=0 ; pin < TOTAL_PINS; pin++) {
506
- Serial .write (IS_PIN_ANALOG (pin) ? PIN_TO_ANALOG (pin) : 127 );
510
+ Firmata .write (IS_PIN_ANALOG (pin) ? PIN_TO_ANALOG (pin) : 127 );
507
511
}
508
- Serial .write (END_SYSEX);
512
+ Firmata .write (END_SYSEX);
509
513
break ;
510
514
}
511
515
}
0 commit comments