Skip to content

Commit

Permalink
Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Jan 26, 2025
1 parent 4c36f7d commit eb30e20
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions components/tc_bus/tc_bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ namespace esphome
listener->turn_off(&listener->timer_);
}
#endif

this->set_interval("debuglogs", 2000, [this] {
this->rx_pin_->detach_interrupt();
uint8_t index = s.debug_buffer_index;
s.debug_buffer_index = 0;
this->rx_pin_->attach_interrupt(TCBusComponentStore::gpio_intr, &this->store_, gpio::INTERRUPT_ANY_EDGE);

for (uint8_t i = 0; i < index; i++) {
ESP_LOGD(TAG, "Time diff: %i", debug_buffer[i]);
}
});
}

void TCBusComponent::save_settings()
Expand Down Expand Up @@ -185,11 +196,6 @@ namespace esphome

auto &s = this->store_;

if(s.s_time_between_debug != 0 && s.s_time_between_debug < 9000)
{
ESP_LOGD(TAG, "Time between: %i", s.s_time_between_debug);
}

if(s.s_cmdReady) {
if(reading_memory_) {
ESP_LOGD(TAG, "Received 4 memory addresses %i to %i", (reading_memory_count_ * 4), (reading_memory_count_ * 4) + 4);
Expand Down Expand Up @@ -321,7 +327,8 @@ namespace esphome
}
#endif

volatile uint32_t TCBusComponentStore::s_time_between_debug = 0;
volatile uint32_t TCBusComponentStore::debug_buffer[DEBUG_BUFFER_SIZE];
volatile uint8_t TCBusComponentStore::debug_buffer_index = 0;
volatile uint32_t TCBusComponentStore::s_last_bit_change = 0;
volatile uint32_t TCBusComponentStore::s_cmd = 0;
volatile bool TCBusComponentStore::s_cmd_is_long = false;
Expand Down Expand Up @@ -352,7 +359,9 @@ namespace esphome
uint32_t timeInUS = usNow - usLast;
usLast = usNow;

arg->s_time_between_debug = timeInUS;
if (arg->debug_buffer_index < 100) {
arg->debug_buffer[arg->debug_buffer_index++] = timeInUS;
}

// Determine current bit based on time interval
uint8_t curBit = 4; // Default to undefined bit
Expand Down

0 comments on commit eb30e20

Please sign in to comment.