#pragma once #include /** * @brief Piezo hit detection + WS2812 status LEDs. * * Ported from the Arduino version: * * the legacy ADC DMA driver (`driver/adc.h`, removed in ESP-IDF v6) is * replaced by the `adc_continuous` driver with the same 40 kHz aggregate * sampling rate, 0 dB attenuation and 12-bit results; * * Adafruit_NeoPixel (bit-banged) is replaced by an RMT WS2812 encoder. */ class Hit { public: // Same values as Adafruit_NeoPixel::Color(r, g, b) -> 0x00RRGGBB. static constexpr uint32_t RED = 0xFF0000; static constexpr uint32_t BLUE = 0x0000FF; static constexpr uint32_t GREEN = 0x00FF00; static constexpr uint32_t YELLOW = 0xFFFF00; /** Blink duration after a hit, and the cooldown that suppresses repeats. */ static constexpr uint32_t HIT_BLINK_MS = 50; /** Raw 12-bit ADC level above which a sample counts as a hit. */ static constexpr uint32_t HIT_THRESHOLD = 2000; static volatile uint32_t color; static volatile bool detect_hit; static volatile uint32_t hit_cnt; static volatile uint32_t last_hit_ms; static void begin(); static void onLoop(); };