diff --git a/ESPMegaPRO-OS-SDK/src/main.cpp b/ESPMegaPRO-OS-SDK/src/main.cpp index 4c79918..7385028 100644 --- a/ESPMegaPRO-OS-SDK/src/main.cpp +++ b/ESPMegaPRO-OS-SDK/src/main.cpp @@ -27,6 +27,7 @@ // #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(); @@ -35,6 +36,15 @@ 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(1, 0, 1, 1, 1, 0); +#endif + // Remote Variable #ifdef REMOTE_VARIABLE_ENABLE RemoteVariable testVar = RemoteVariable(); @@ -172,6 +182,10 @@ 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"); @@ -216,6 +230,10 @@ 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);