mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 08:06:13 +01:00
HAL minor simplification
This commit is contained in:
parent
6b7c2ccdf0
commit
3496b99197
|
@ -294,7 +294,7 @@ bool IODevice::checkNoOverlap(VPIN firstPin, uint8_t nPins, uint8_t i2cAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for overlapping I2C address
|
// Check for overlapping I2C address
|
||||||
if (dev->_matchI2CAddress(i2cAddress)) {
|
if (i2cAddress && dev->_I2CAddress==i2cAddress) {
|
||||||
DIAG(F("WARNING HAL Overlap. i2c Addr 0x%x ignored."),i2cAddress);
|
DIAG(F("WARNING HAL Overlap. i2c Addr 0x%x ignored."),i2cAddress);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -302,9 +302,6 @@ bool IODevice::checkNoOverlap(VPIN firstPin, uint8_t nPins, uint8_t i2cAddress)
|
||||||
return true; // no overlaps... OK to go on with constructor
|
return true; // no overlaps... OK to go on with constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IODevice::_matchI2CAddress(uint8_t i2cAddress) {
|
|
||||||
return (i2cAddress && i2cAddress==_I2CAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
//==================================================================================================================
|
//==================================================================================================================
|
||||||
// Static data
|
// Static data
|
||||||
|
|
|
@ -229,9 +229,6 @@ protected:
|
||||||
// pin low if an input changes state.
|
// pin low if an input changes state.
|
||||||
int16_t _gpioInterruptPin = -1;
|
int16_t _gpioInterruptPin = -1;
|
||||||
|
|
||||||
// non-i2c hal drivers return false, i2c drivers override this in IO_GPIOBase
|
|
||||||
bool _matchI2CAddress(uint8_t i2cAddress);
|
|
||||||
|
|
||||||
// Method to check if pins will overlap before creating new device.
|
// Method to check if pins will overlap before creating new device.
|
||||||
static bool checkNoOverlap(VPIN firstPin, uint8_t nPins=1, uint8_t i2cAddress=0);
|
static bool checkNoOverlap(VPIN firstPin, uint8_t nPins=1, uint8_t i2cAddress=0);
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ public:
|
||||||
|
|
||||||
// Static create function provides alternative way to create object
|
// Static create function provides alternative way to create object
|
||||||
static void create(VPIN vpin, int trigPin, int echoPin, uint16_t onThreshold, uint16_t offThreshold) {
|
static void create(VPIN vpin, int trigPin, int echoPin, uint16_t onThreshold, uint16_t offThreshold) {
|
||||||
if (checkNoOverlap(vpin) && checkNoOverlap(trigPin) && checkNoOverlap(echoPin))
|
if (checkNoOverlap(vpin))
|
||||||
new HCSR04(vpin, trigPin, echoPin, onThreshold, offThreshold);
|
new HCSR04(vpin, trigPin, echoPin, onThreshold, offThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user