|
@@ -473,7 +473,7 @@ void I2CPositionEncoder::calibrate_steps_mm(const uint8_t iter) {
|
473
|
473
|
}
|
474
|
474
|
|
475
|
475
|
void I2CPositionEncoder::reset() {
|
476
|
|
- Wire.beginTransmission(i2cAddress);
|
|
476
|
+ Wire.beginTransmission(I2C_ADDRESS(i2cAddress));
|
477
|
477
|
Wire.write(I2CPE_RESET_COUNT);
|
478
|
478
|
Wire.endTransmission();
|
479
|
479
|
|
|
@@ -703,7 +703,7 @@ void I2CPositionEncodersMgr::report_position(const int8_t idx, const bool units,
|
703
|
703
|
|
704
|
704
|
void I2CPositionEncodersMgr::change_module_address(const uint8_t oldaddr, const uint8_t newaddr) {
|
705
|
705
|
// First check 'new' address is not in use
|
706
|
|
- Wire.beginTransmission(newaddr);
|
|
706
|
+ Wire.beginTransmission(I2C_ADDRESS(newaddr));
|
707
|
707
|
if (!Wire.endTransmission()) {
|
708
|
708
|
SERIAL_ECHOPAIR("?There is already a device with that address on the I2C bus! (", newaddr);
|
709
|
709
|
SERIAL_ECHOLNPGM(")");
|
|
@@ -711,7 +711,7 @@ void I2CPositionEncodersMgr::change_module_address(const uint8_t oldaddr, const
|
711
|
711
|
}
|
712
|
712
|
|
713
|
713
|
// Now check that we can find the module on the oldaddr address
|
714
|
|
- Wire.beginTransmission(oldaddr);
|
|
714
|
+ Wire.beginTransmission(I2C_ADDRESS(oldaddr));
|
715
|
715
|
if (Wire.endTransmission()) {
|
716
|
716
|
SERIAL_ECHOPAIR("?No module detected at this address! (", oldaddr);
|
717
|
717
|
SERIAL_ECHOLNPGM(")");
|
|
@@ -722,7 +722,7 @@ void I2CPositionEncodersMgr::change_module_address(const uint8_t oldaddr, const
|
722
|
722
|
SERIAL_ECHOLNPAIR(", changing address to ", newaddr);
|
723
|
723
|
|
724
|
724
|
// Change the modules address
|
725
|
|
- Wire.beginTransmission(oldaddr);
|
|
725
|
+ Wire.beginTransmission(I2C_ADDRESS(oldaddr));
|
726
|
726
|
Wire.write(I2CPE_SET_ADDR);
|
727
|
727
|
Wire.write(newaddr);
|
728
|
728
|
Wire.endTransmission();
|
|
@@ -733,7 +733,7 @@ void I2CPositionEncodersMgr::change_module_address(const uint8_t oldaddr, const
|
733
|
733
|
safe_delay(I2CPE_REBOOT_TIME);
|
734
|
734
|
|
735
|
735
|
// Look for the module at the new address.
|
736
|
|
- Wire.beginTransmission(newaddr);
|
|
736
|
+ Wire.beginTransmission(I2C_ADDRESS(newaddr));
|
737
|
737
|
if (Wire.endTransmission()) {
|
738
|
738
|
SERIAL_ECHOLNPGM("Address change failed! Check encoder module.");
|
739
|
739
|
return;
|
|
@@ -753,7 +753,7 @@ void I2CPositionEncodersMgr::change_module_address(const uint8_t oldaddr, const
|
753
|
753
|
|
754
|
754
|
void I2CPositionEncodersMgr::report_module_firmware(const uint8_t address) {
|
755
|
755
|
// First check there is a module
|
756
|
|
- Wire.beginTransmission(address);
|
|
756
|
+ Wire.beginTransmission(I2C_ADDRESS(address));
|
757
|
757
|
if (Wire.endTransmission()) {
|
758
|
758
|
SERIAL_ECHOPAIR("?No module detected at this address! (", address);
|
759
|
759
|
SERIAL_ECHOLNPGM(")");
|
|
@@ -763,7 +763,7 @@ void I2CPositionEncodersMgr::report_module_firmware(const uint8_t address) {
|
763
|
763
|
SERIAL_ECHOPAIR("Requesting version info from module at address ", address);
|
764
|
764
|
SERIAL_ECHOLNPGM(":");
|
765
|
765
|
|
766
|
|
- Wire.beginTransmission(address);
|
|
766
|
+ Wire.beginTransmission(I2C_ADDRESS(address));
|
767
|
767
|
Wire.write(I2CPE_SET_REPORT_MODE);
|
768
|
768
|
Wire.write(I2CPE_REPORT_VERSION);
|
769
|
769
|
Wire.endTransmission();
|
|
@@ -777,7 +777,7 @@ void I2CPositionEncodersMgr::report_module_firmware(const uint8_t address) {
|
777
|
777
|
}
|
778
|
778
|
|
779
|
779
|
// Set module back to normal (distance) mode
|
780
|
|
- Wire.beginTransmission(address);
|
|
780
|
+ Wire.beginTransmission(I2C_ADDRESS(address));
|
781
|
781
|
Wire.write(I2CPE_SET_REPORT_MODE);
|
782
|
782
|
Wire.write(I2CPE_REPORT_DISTANCE);
|
783
|
783
|
Wire.endTransmission();
|