From 9571088e1b0aa918cce3998845b57dc2f5d7090f Mon Sep 17 00:00:00 2001 From: peteGSX <97784652+peteGSX@users.noreply.github.com> Date: Thu, 6 Apr 2023 07:03:59 +1000 Subject: [PATCH] Added disable logic --- IODevice.cpp | 28 ++++++++++++++++++++++------ version.h | 3 ++- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/IODevice.cpp b/IODevice.cpp index af6efc8..2ed21b6 100644 --- a/IODevice.cpp +++ b/IODevice.cpp @@ -63,15 +63,31 @@ void IODevice::begin() { if (exrailHalSetup) exrailHalSetup(); - // Predefine two PCA9685 modules 0x40-0x41 + // Predefine two PCA9685 modules 0x40-0x41 if no conflicts // Allocates 32 pins 100-131 - PCA9685::create(100, 16, 0x40); - PCA9685::create(116, 16, 0x41); + if (checkNoOverlap(100, 16, 0x40)) { + PCA9685::create(100, 16, 0x40); + } else { + DIAG(F("Default PCA9685 at I2C 0x40 disabled due to configured user device")); + } + if (checkNoOverlap(116, 16, 0x41)) { + PCA9685::create(116, 16, 0x41); + } else { + DIAG(F("Default PCA9685 at I2C 0x41 disabled due to configured user device")); + } - // Predefine two MCP23017 module 0x20/0x21 + // Predefine two MCP23017 module 0x20/0x21 if no conflicts // Allocates 32 pins 164-195 - MCP23017::create(164, 16, 0x20); - MCP23017::create(180, 16, 0x21); + if (checkNoOverlap(164, 16, 0x20)) { + MCP23017::create(164, 16, 0x20); + } else { + DIAG(F("Default MCP23017 at I2C 0x20 disabled due to configured user device")); + } + if (checkNoOverlap(180, 16, 0x21)) { + MCP23017::create(180, 16, 0x21); + } else { + DIAG(F("Default MCP23017 at I2C 0x21 disabled due to configured user device")); + } } // reset() function to reinitialise all devices diff --git a/version.h b/version.h index da95f93..399f68d 100644 --- a/version.h +++ b/version.h @@ -4,7 +4,8 @@ #include "StringFormatter.h" -#define VERSION "4.2.39" +#define VERSION "4.2.40" +// 4.2.40 - Automatically detect conflicting default I2C devices and disable // 4.2.39 - DFplayer driver now polls device to detect failures and errors. // 4.2.38 - Clean up compiler warning when IO_RotaryEncoder.h included // 4.2.37 - Add new FLAGS HAL device for communications to/from EX-RAIL;