digital output card

This commit is contained in:
Siwat Sirichai 2024-11-03 13:33:10 +07:00
parent 85f789e216
commit 09aee8d5f8
2 changed files with 23 additions and 12 deletions

View File

@ -32,7 +32,7 @@ DigitalOutputCard::DigitalOutputCard(uint8_t address) : change_callbacks(){
* @param bit4 The position of the fifth switch on the dip switch
*/
DigitalOutputCard::DigitalOutputCard(bool bit0, bool bit1, bool bit2, bool bit3, bool bit4) :
DigitalOutputCard(0x20+bit0+bit1*2+bit2*4+bit3*8+bit4*16)
DigitalOutputCard(0x40+bit0+bit1*2+bit2*4+bit3*8+bit4*16)
{

View File

@ -19,18 +19,22 @@
// #define RTC_DEBUG
// #define WRITE_DEFAULT_NETCONF
// #define CLIMATE_CARD_ENABLE
//#define MQTT_CARD_REGISTER
#define MQTT_CARD_REGISTER
// #define DISPLAY_ENABLE
//#define WEB_SERVER_ENABLE
#define WEB_SERVER_ENABLE
// #define LCD_OTA_ENABLE
// #define REMOTE_VARIABLE_ENABLE
// #define CT_ENABLE
// #define SMART_VARIABLE_ENABLE
#define EXTERNAL_DIGITAL_OUTPUT_CARD_ENABLE
// Demo PLC firmware using the ESPMegaPRO OOP library
ESPMegaPRO espmega = ESPMegaPRO();
#ifdef EXTERNAL_DIGITAL_OUTPUT_CARD_ENABLE
DigitalOutputCard externalDigitalOutputCard = DigitalOutputCard(1, 0, 1, 1, 0);
#endif
// Remote Variable
#ifdef REMOTE_VARIABLE_ENABLE
RemoteVariable testVar = RemoteVariable();
@ -166,6 +170,9 @@ void setup()
{
ESP_LOGI("Initializer", "Starting ESPMegaPRO OOP demo");
espmega.begin();
#ifdef EXTERNAL_DIGITAL_OUTPUT_CARD_ENABLE
espmega.installCard(6, &externalDigitalOutputCard);
#endif
espmega.setTimezone("UTC-7");
ESP_LOGI("Initializer", "Enabling IOT module");
espmega.enableIotModule();
@ -205,6 +212,10 @@ void setup()
espmega.iot->registerCard(0);
ESP_LOGI("Initializer", "Registering cards 1");
espmega.iot->registerCard(1);
#ifdef EXTERNAL_DIGITAL_OUTPUT_CARD_ENABLE
ESP_LOGI("Initializer", "Registering cards 6");
espmega.iot->registerCard(6);
#endif
#endif
ESP_LOGI("Initializer", "Registering Input change callback");
espmega.inputs.registerCallback(input_change_callback);