From a61a0cc64c08e3ec2e1577dd8bea6b3f3a0df45f Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Thu, 8 Oct 2026 10:32:17 +0200 Subject: [PATCH] rgb-led timing: more exact --- src/core/led.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/led.cpp b/src/core/led.cpp index abf649756..cbe068c3a 100644 --- a/src/core/led.cpp +++ b/src/core/led.cpp @@ -31,17 +31,17 @@ namespace rgb_led { namespace { -// durations in 100 ns ticks -constexpr uint16_t T0H = 3; // 300 ns -constexpr uint16_t T0L = 9; // 900 ns -constexpr uint16_t T1H = 8; // 800 ns -constexpr uint16_t T1L = 6; // 600 ns +// durations in 12.5 ns ticks +constexpr uint16_t T0H = 3.5 * 8; // 350 ns +constexpr uint16_t T0L = 9 * 8; // 900 ns +constexpr uint16_t T1H = 8 * 8; // 800 ns +constexpr uint16_t T1L = 6 * 8; // 600 ns // rmt_data_t.val layout: duration0:15, level0:1, duration1:15, level1:1 (high then low) constexpr uint32_t SYMBOL_0 = T0H | (1UL << 15) | (static_cast(T0L) << 16); constexpr uint32_t SYMBOL_1 = T1H | (1UL << 15) | (static_cast(T1L) << 16); -constexpr uint32_t RMT_FREQ_HZ = 10000000; // 10 MHz +constexpr uint32_t RMT_FREQ_HZ = 80000000; // 80 MHz constexpr uint32_t RESET_US = 300; constexpr uint8_t NO_PIN = 0xFF; constexpr uint8_t MAX_PINS = 2; // status LED + an RGB analog sensor; the ESP32-C3 only has 2 RMT TX channels