From 6b2cd226e2d0a376e4193545cdd3af55ee40b168 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Tue, 2 Aug 2022 15:13:29 +0200 Subject: [PATCH] provide methods to access sentResetsSincePacket --- DCCWaveform.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/DCCWaveform.h b/DCCWaveform.h index 2a55189..cad7861 100644 --- a/DCCWaveform.h +++ b/DCCWaveform.h @@ -53,6 +53,21 @@ class DCCWaveform { static DCCWaveform mainTrack; static DCCWaveform progTrack; inline void clearRepeats() { transmitRepeats=0; } +#ifndef ARDUINO_ARCH_ESP32 + inline void clearResets() { sentResetsSincePacket=0; } + inline byte getResets() { return sentResetsSincePacket; } +#else + inline void clearResets() { resetPacketBase = isMainTrack ? + rmtMainChannel->packetCount() : rmtProgChannel->packetCount(); }; + inline byte getResets() { + uint32_t packetcount = isMainTrack ? + rmtMainChannel->packetCount() : rmtProgChannel->packetCount(); + uint32_t count = packetcount - resetPacketBase; + if ((count & 255) == 0) // no high bits set + return count; + return 255; + }; +#endif void schedulePacket(const byte buffer[], byte byteCount, byte repeats); volatile byte sentResetsSincePacket; bool getPacketPending(); @@ -60,6 +75,8 @@ class DCCWaveform { private: #ifndef ARDUINO_ARCH_ESP32 volatile bool packetPending; +#else + volatile uint32_t resetPacketBase; #endif static void interruptHandler(); void interrupt2();