From 978cf36e1e1c592543bf1d4cd006fba111f69d88 Mon Sep 17 00:00:00 2001 From: reaw55 <58457329+reaw55@users.noreply.github.com> Date: Mon, 1 Apr 2024 22:20:26 +0700 Subject: [PATCH] debug --- src/main.cpp | 21 +++++++++++++++++++++ src/main.hpp | 3 +-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 769d5b0..3e289c8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -346,6 +346,27 @@ void loop() iseDisplay.updateDateTimeText(time); last_time_updated = millis(); } + + // Send out analog Data every 6 seconds + static uint32_t last_analog_sent = 0; + if (millis() - last_analog_sent > 6000) + { + espmega.iot->publish("/debug/up", "1"); + if (analogCardAvailable || CT_FORCE_ENABLE) + { + espmega.iot->publish("/debug/log", "Sending Analog Card Data"); + char topic_buffer[50]; + char payload_buffer[50]; + // Publish ADC Pin 0-7 + for (uint8_t i = 0; i < 8; i++) + { + sprintf(topic_buffer, "/debug/analog/%d", i); + sprintf(payload_buffer, "%d", analogCard.analogRead(i)); + espmega.iot->publish(topic_buffer, payload_buffer); + } + } + last_analog_sent = millis(); + } } void on_pin_change(uint8_t pin, uint8_t value) diff --git a/src/main.hpp b/src/main.hpp index 99824e8..41dbcd1 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -25,9 +25,8 @@ SET_LOOP_TASK_STACK_SIZE(32*1024); #define AIR_CONDITIONER_YORK_IR_PIN 15 #define AIR_CONDITIONER_RMT_CHANNEL0 RMT_CHANNEL_0 #define AIR_CONDITIONER_RMT_CHANNEL1 RMT_CHANNEL_1 - // CT Configuration -#define CT_FORCE_ENABLE false +#define CT_FORCE_ENABLE true #define CT_RMS_VOLTAGE 1.0 #define CT_PIN_LIGHT_PHASE1 0 #define CT_PIN_LIGHT_PHASE2 1