improve debounce
This commit is contained in:
parent
4ea2122f6e
commit
8aeb6ab30a
3 changed files with 119 additions and 58 deletions
|
@ -12,15 +12,17 @@
|
|||
#include <AnalogCard.hpp>
|
||||
#include <SmartVariable.hpp>
|
||||
|
||||
#define INPUT_DEBOUNCE_TIME_MS 1000
|
||||
|
||||
// #define FRAM_DEBUG
|
||||
// #define MQTT_DEBUG
|
||||
// #define RTC_DEBUG
|
||||
#define WRITE_DEFAULT_NETCONF
|
||||
#define CLIMATE_CARD_ENABLE
|
||||
#define MQTT_CARD_REGISTER
|
||||
//#define WRITE_DEFAULT_NETCONF
|
||||
//#define CLIMATE_CARD_ENABLE
|
||||
//#define MQTT_CARD_REGISTER
|
||||
// #define DISPLAY_ENABLE
|
||||
#define WEB_SERVER_ENABLE
|
||||
#define LCD_OTA_ENABLE
|
||||
//#define WEB_SERVER_ENABLE
|
||||
//#define LCD_OTA_ENABLE
|
||||
// #define REMOTE_VARIABLE_ENABLE
|
||||
// #define CT_ENABLE
|
||||
// #define SMART_VARIABLE_ENABLE
|
||||
|
@ -116,6 +118,7 @@ void input_change_callback(uint8_t pin, uint8_t value)
|
|||
Serial.print(pin);
|
||||
Serial.print(" ");
|
||||
Serial.println(value);
|
||||
espmega.outputs.toggleState(pin);
|
||||
}
|
||||
|
||||
void mqtt_callback(char *topic, char *payload)
|
||||
|
@ -187,6 +190,16 @@ void setup()
|
|||
ESP_LOGI("Initializer", "Connecting to MQTT");
|
||||
espmega.iot->connectToMqtt();
|
||||
espmega.iot->registerMqttCallback(mqtt_callback);
|
||||
// Set debounce time
|
||||
for (uint8_t i = 0; i < 16; i++)
|
||||
{
|
||||
espmega.inputs.setDebounceTime(i, INPUT_DEBOUNCE_TIME_MS);
|
||||
}
|
||||
// Set all pin values to 4095
|
||||
for (uint8_t i = 0; i < 16; i++)
|
||||
{
|
||||
espmega.outputs.setValue(i, 4095);
|
||||
}
|
||||
#ifdef MQTT_CARD_REGISTER
|
||||
ESP_LOGI("Initializer", "Registering cards 0");
|
||||
espmega.iot->registerCard(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue