Compare commits
No commits in common. "a22c8ef55c8561a9c5c9e400e1745437b8d145bd" and "09aee8d5f86d0d6b7cc72ef0bab71ccec3035ffd" have entirely different histories.
a22c8ef55c
...
09aee8d5f8
|
@ -60,13 +60,11 @@ bool DigitalInputCard::begin()
|
|||
if (!this->inputBankA.begin())
|
||||
{
|
||||
ESP_LOGE("DigitalInputCard", "Input Card ERROR: Failed to install input bank A");
|
||||
this->initOk = false;
|
||||
return false;
|
||||
}
|
||||
if (!this->inputBankB.begin())
|
||||
{
|
||||
ESP_LOGE("DigitalInputCard", "Input Card ERROR: Failed to install input bank B");
|
||||
this->initOk = false;
|
||||
return false;
|
||||
}
|
||||
// Set the debounce time for all pins to 50ms
|
||||
|
@ -81,7 +79,6 @@ bool DigitalInputCard::begin()
|
|||
this->pinMap[i] = i;
|
||||
this->virtualPinMap[i] = i;
|
||||
}
|
||||
this->initOk = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -105,11 +102,6 @@ bool DigitalInputCard::digitalRead(uint8_t pin)
|
|||
*/
|
||||
bool DigitalInputCard::digitalRead(uint8_t pin, bool refresh)
|
||||
{
|
||||
if(!this->initOk)
|
||||
{
|
||||
ESP_LOGE("DigitalInputCard", "Input Card ERROR: Card not initialized");
|
||||
return false;
|
||||
}
|
||||
pin = pinMap[pin];
|
||||
// First check if the pin is in bank A or B
|
||||
if (pin >= 0 && pin <= 7)
|
||||
|
@ -128,7 +120,7 @@ bool DigitalInputCard::digitalRead(uint8_t pin, bool refresh)
|
|||
// Extract the bit from the buffer
|
||||
return ((inputBufferB >> (15 - pin)) & 1);
|
||||
}
|
||||
return false;
|
||||
return 255;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -299,11 +291,6 @@ uint8_t DigitalInputCard::registerCallback(std::function<void(uint8_t, bool)> ca
|
|||
*/
|
||||
void DigitalInputCard::refreshInputBankA()
|
||||
{
|
||||
if(!this->initOk)
|
||||
{
|
||||
ESP_LOGE("DigitalInputCard", "Input Card ERROR: Card not initialized");
|
||||
return;
|
||||
}
|
||||
inputBufferA = inputBankA.read8();
|
||||
}
|
||||
|
||||
|
@ -312,11 +299,6 @@ void DigitalInputCard::refreshInputBankA()
|
|||
*/
|
||||
void DigitalInputCard::refreshInputBankB()
|
||||
{
|
||||
if(!this->initOk)
|
||||
{
|
||||
ESP_LOGE("DigitalInputCard", "Input Card ERROR: Card not initialized");
|
||||
return;
|
||||
}
|
||||
inputBufferB = inputBankB.read8();
|
||||
}
|
||||
|
||||
|
@ -389,13 +371,3 @@ void DigitalInputCard::preloadInputBuffer()
|
|||
previousInputBufferA = inputBufferA;
|
||||
previousInputBufferB = inputBufferB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the status of the card
|
||||
*
|
||||
* @return True if the card is initialized, false otherwise
|
||||
*/
|
||||
bool DigitalInputCard::getStatus()
|
||||
{
|
||||
return this->initOk;
|
||||
}
|
|
@ -43,12 +43,9 @@ class DigitalInputCard : public ExpansionCard {
|
|||
void loadPinMap(uint8_t pinMap[16]);
|
||||
// Preload previousInputBuffer and inputBuffer
|
||||
void preloadInputBuffer();
|
||||
// Status of card
|
||||
bool getStatus();
|
||||
// Get type of card
|
||||
uint8_t getType();
|
||||
private:
|
||||
bool initOk = false;
|
||||
PCF8574 inputBankA;
|
||||
PCF8574 inputBankB;
|
||||
uint8_t address_a;
|
||||
|
|
|
@ -17,9 +17,6 @@
|
|||
*/
|
||||
bool DigitalInputIoT::begin(uint8_t card_id, ExpansionCard *card, PubSubClient *mqtt, char *base_topic) {
|
||||
this->card = (DigitalInputCard *)card;
|
||||
if(!this->card->getStatus()) {
|
||||
return false;
|
||||
}
|
||||
this->card_id = card_id;
|
||||
this->mqtt = mqtt;
|
||||
this->base_topic = base_topic;
|
||||
|
|
|
@ -144,12 +144,6 @@ void ESPMegaIoT::registerCard(uint8_t card_id)
|
|||
{
|
||||
return;
|
||||
}
|
||||
// Check if the physical card is installed
|
||||
if (cards[card_id] == NULL)
|
||||
{
|
||||
ESP_LOGE("ESPMegaIoT", "Registering card %d failed: Card not installed", card_id);
|
||||
return;
|
||||
}
|
||||
// Get the card type
|
||||
uint8_t card_type = cards[card_id]->getType();
|
||||
// Create the respective IoT component
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
// #define CT_ENABLE
|
||||
// #define SMART_VARIABLE_ENABLE
|
||||
#define EXTERNAL_DIGITAL_OUTPUT_CARD_ENABLE
|
||||
#define EXTERNAL_DIGITAL_INPUT_CARD_ENABLE
|
||||
// Demo PLC firmware using the ESPMegaPRO OOP library
|
||||
|
||||
ESPMegaPRO espmega = ESPMegaPRO();
|
||||
|
@ -36,15 +35,6 @@ ESPMegaPRO espmega = ESPMegaPRO();
|
|||
DigitalOutputCard externalDigitalOutputCard = DigitalOutputCard(1, 0, 1, 1, 0);
|
||||
#endif
|
||||
|
||||
#ifdef EXTERNAL_DIGITAL_INPUT_CARD_ENABLE
|
||||
void handleExternalDigitalInput(uint8_t pin, uint8_t state)
|
||||
{
|
||||
Serial.printf("Digital Input External %d: %d\n", pin, state);
|
||||
}
|
||||
|
||||
DigitalInputCard externalDigitalInputCard = DigitalInputCard(0, 0, 1, 0, 1, 1);
|
||||
#endif
|
||||
|
||||
// Remote Variable
|
||||
#ifdef REMOTE_VARIABLE_ENABLE
|
||||
RemoteVariable testVar = RemoteVariable();
|
||||
|
@ -182,10 +172,6 @@ void setup()
|
|||
espmega.begin();
|
||||
#ifdef EXTERNAL_DIGITAL_OUTPUT_CARD_ENABLE
|
||||
espmega.installCard(6, &externalDigitalOutputCard);
|
||||
#endif
|
||||
#ifdef EXTERNAL_DIGITAL_INPUT_CARD_ENABLE
|
||||
espmega.installCard(7, &externalDigitalInputCard);
|
||||
externalDigitalInputCard.registerCallback(handleExternalDigitalInput);
|
||||
#endif
|
||||
espmega.setTimezone("UTC-7");
|
||||
ESP_LOGI("Initializer", "Enabling IOT module");
|
||||
|
@ -230,10 +216,6 @@ void setup()
|
|||
ESP_LOGI("Initializer", "Registering cards 6");
|
||||
espmega.iot->registerCard(6);
|
||||
#endif
|
||||
#ifdef EXTERNAL_DIGITAL_INPUT_CARD_ENABLE
|
||||
ESP_LOGI("Initializer", "Registering cards 7");
|
||||
espmega.iot->registerCard(7);
|
||||
#endif
|
||||
#endif
|
||||
ESP_LOGI("Initializer", "Registering Input change callback");
|
||||
espmega.inputs.registerCallback(input_change_callback);
|
||||
|
|
Loading…
Reference in New Issue