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 * @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::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

@ -1,7 +1,7 @@
/** /**
* @file main.cpp * @file main.cpp
* @brief Test firmware for the ESPMegaPRO OOP library * @brief Test firmware for the ESPMegaPRO OOP library
*/ */
#include <ESPMegaProOS.hpp> #include <ESPMegaProOS.hpp>
#include <InternalDisplay.hpp> #include <InternalDisplay.hpp>
#include <ETH.h> #include <ETH.h>
@ -17,20 +17,24 @@
// #define FRAM_DEBUG // #define FRAM_DEBUG
// #define MQTT_DEBUG // #define MQTT_DEBUG
// #define RTC_DEBUG // #define RTC_DEBUG
//#define WRITE_DEFAULT_NETCONF // #define WRITE_DEFAULT_NETCONF
//#define CLIMATE_CARD_ENABLE // #define CLIMATE_CARD_ENABLE
//#define MQTT_CARD_REGISTER #define MQTT_CARD_REGISTER
// #define DISPLAY_ENABLE // #define DISPLAY_ENABLE
//#define WEB_SERVER_ENABLE #define WEB_SERVER_ENABLE
//#define LCD_OTA_ENABLE // #define LCD_OTA_ENABLE
// #define REMOTE_VARIABLE_ENABLE // #define REMOTE_VARIABLE_ENABLE
// #define CT_ENABLE // #define CT_ENABLE
// #define SMART_VARIABLE_ENABLE // #define SMART_VARIABLE_ENABLE
#define EXTERNAL_DIGITAL_OUTPUT_CARD_ENABLE
// Demo PLC firmware using the ESPMegaPRO OOP library // Demo PLC firmware using the ESPMegaPRO OOP library
ESPMegaPRO espmega = ESPMegaPRO(); ESPMegaPRO espmega = ESPMegaPRO();
#ifdef EXTERNAL_DIGITAL_OUTPUT_CARD_ENABLE
DigitalOutputCard externalDigitalOutputCard = DigitalOutputCard(1, 0, 1, 1, 0);
#endif
// Remote Variable // Remote Variable
#ifdef REMOTE_VARIABLE_ENABLE #ifdef REMOTE_VARIABLE_ENABLE
RemoteVariable testVar = RemoteVariable(); RemoteVariable testVar = RemoteVariable();
@ -166,6 +170,9 @@ void setup()
{ {
ESP_LOGI("Initializer", "Starting ESPMegaPRO OOP demo"); ESP_LOGI("Initializer", "Starting ESPMegaPRO OOP demo");
espmega.begin(); espmega.begin();
#ifdef EXTERNAL_DIGITAL_OUTPUT_CARD_ENABLE
espmega.installCard(6, &externalDigitalOutputCard);
#endif
espmega.setTimezone("UTC-7"); espmega.setTimezone("UTC-7");
ESP_LOGI("Initializer", "Enabling IOT module"); ESP_LOGI("Initializer", "Enabling IOT module");
espmega.enableIotModule(); espmega.enableIotModule();
@ -205,6 +212,10 @@ void setup()
espmega.iot->registerCard(0); espmega.iot->registerCard(0);
ESP_LOGI("Initializer", "Registering cards 1"); ESP_LOGI("Initializer", "Registering cards 1");
espmega.iot->registerCard(1); espmega.iot->registerCard(1);
#ifdef EXTERNAL_DIGITAL_OUTPUT_CARD_ENABLE
ESP_LOGI("Initializer", "Registering cards 6");
espmega.iot->registerCard(6);
#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);
@ -240,7 +251,7 @@ void setup()
#endif #endif
#ifdef REMOTE_VARIABLE_ENABLE #ifdef REMOTE_VARIABLE_ENABLE
ESP_LOGI("Initializer", "Initializing testvar"); ESP_LOGI("Initializer", "Initializing testvar");
testVar.begin(32, "/xm/fan_speed", espmega.iot, true,"/pm/request_fan_speed"); testVar.begin(32, "/xm/fan_speed", espmega.iot, true, "/pm/request_fan_speed");
testVar.enableSetValue("/pm/request_switch_state"); testVar.enableSetValue("/pm/request_switch_state");
#endif #endif
#ifdef CT_ENABLE #ifdef CT_ENABLE