card installation checking

This commit is contained in:
Siwat Sirichai 2023-12-28 02:18:21 +07:00
parent 1862887d30
commit 1481c08d3a
10 changed files with 122 additions and 37 deletions

View file

@ -30,12 +30,18 @@ DigitalInputCard::DigitalInputCard(bool bit0, bool bit1, bool bit2, bool bit3, b
this->address_b += 4;
}
// Initialize the card
void DigitalInputCard::begin()
bool DigitalInputCard::begin()
{
this->inputBankA = PCF8574(this->address_a);
this->inputBankB = PCF8574(this->address_b);
this->inputBankA.begin();
this->inputBankB.begin();
if (!this->inputBankA.begin()) {
Serial.println("Input Card ERROR: Failed to install input bank A");
return false;
}
if (!this->inputBankB.begin()) {
Serial.println("Input Card ERROR: Failed to install input bank B");
return false;
}
// Set the debounce time for all pins to 50ms
for (int i = 0; i < 16; i++)
{
@ -48,6 +54,7 @@ void DigitalInputCard::begin()
this->pinMap[i] = i;
this->virtualPinMap[i] = i;
}
return true;
}
// Refresh and Read the input from the specified pin, always refresh the input buffers
bool DigitalInputCard::digitalRead(uint8_t pin)