input (not working)

This commit is contained in:
Siwat Sirichai 2024-11-03 21:51:35 +07:00
parent 09aee8d5f8
commit 268218f546
1 changed files with 18 additions and 0 deletions

View File

@ -27,6 +27,7 @@
// #define CT_ENABLE // #define CT_ENABLE
// #define SMART_VARIABLE_ENABLE // #define SMART_VARIABLE_ENABLE
#define EXTERNAL_DIGITAL_OUTPUT_CARD_ENABLE #define EXTERNAL_DIGITAL_OUTPUT_CARD_ENABLE
#define EXTERNAL_DIGITAL_INPUT_CARD_ENABLE
// Demo PLC firmware using the ESPMegaPRO OOP library // Demo PLC firmware using the ESPMegaPRO OOP library
ESPMegaPRO espmega = ESPMegaPRO(); ESPMegaPRO espmega = ESPMegaPRO();
@ -35,6 +36,15 @@ ESPMegaPRO espmega = ESPMegaPRO();
DigitalOutputCard externalDigitalOutputCard = DigitalOutputCard(1, 0, 1, 1, 0); DigitalOutputCard externalDigitalOutputCard = DigitalOutputCard(1, 0, 1, 1, 0);
#endif #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 // Remote Variable
#ifdef REMOTE_VARIABLE_ENABLE #ifdef REMOTE_VARIABLE_ENABLE
RemoteVariable testVar = RemoteVariable(); RemoteVariable testVar = RemoteVariable();
@ -172,6 +182,10 @@ void setup()
espmega.begin(); espmega.begin();
#ifdef EXTERNAL_DIGITAL_OUTPUT_CARD_ENABLE #ifdef EXTERNAL_DIGITAL_OUTPUT_CARD_ENABLE
espmega.installCard(6, &externalDigitalOutputCard); espmega.installCard(6, &externalDigitalOutputCard);
#endif
#ifdef EXTERNAL_DIGITAL_INPUT_CARD_ENABLE
espmega.installCard(7, &externalDigitalInputCard);
externalDigitalInputCard.registerCallback(handleExternalDigitalInput);
#endif #endif
espmega.setTimezone("UTC-7"); espmega.setTimezone("UTC-7");
ESP_LOGI("Initializer", "Enabling IOT module"); ESP_LOGI("Initializer", "Enabling IOT module");
@ -216,6 +230,10 @@ void setup()
ESP_LOGI("Initializer", "Registering cards 6"); ESP_LOGI("Initializer", "Registering cards 6");
espmega.iot->registerCard(6); espmega.iot->registerCard(6);
#endif #endif
#ifdef EXTERNAL_DIGITAL_INPUT_CARD_ENABLE
// ESP_LOGI("Initializer", "Registering cards 7");
// espmega.iot->registerCard(7);
#endif
#endif #endif
ESP_LOGI("Initializer", "Registering Input change callback"); ESP_LOGI("Initializer", "Registering Input change callback");
espmega.inputs.registerCallback(input_change_callback); espmega.inputs.registerCallback(input_change_callback);