#pragma once #include // ------------------------- Hardware configuration ------------------------- #if CONFIG_IDF_TARGET_ESP32C3 constexpr bool TARGET_IS_C3 = true; constexpr uint8_t GPIO_PWM = 3; constexpr uint8_t GPIO_RX = 4; constexpr uint8_t GPIO_BUTTON_MODE = 0; constexpr uint8_t GPIO_BUTTON_START = 1; constexpr uint8_t GPIO_SDA = 6; constexpr uint8_t GPIO_SCL = 7; #elif CONFIG_IDF_TARGET_ESP32S3 constexpr bool TARGET_IS_C3 = false; constexpr uint8_t GPIO_PWM = 4; constexpr uint8_t GPIO_RX = 5; constexpr uint8_t GPIO_BUTTON_MODE = 6; constexpr uint8_t GPIO_BUTTON_START = 7; constexpr uint8_t GPIO_SDA = 8; constexpr uint8_t GPIO_SCL = 9; #else #error "Only ESP32-C3 and ESP32-S3 are supported" #endif constexpr uint8_t OLED_ROTATION = 0; constexpr uint8_t OLED_ADDRESS = 0x3C; constexpr uint8_t ESPNOW_WIFI_CHANNEL = 6; constexpr uint32_t SERIAL_BAUD = 115200; constexpr bool SERIAL_ACTION_LOG = true; constexpr bool SERIAL_LOG_TIMESTAMPS = true; constexpr bool SERIAL_MINIMAL_LOG = true; #define BUTTON_ACTIVE_LEVEL LOW #define RX_SIGNAL_INVERTED false #define PWM_SAFE_LEVEL LOW #define PWM_SETTLE_CYCLES 5U constexpr uint32_t BUTTON_DEBOUNCE_MS = 30; constexpr uint32_t BUTTON_LONG_PRESS_MS = 800; constexpr uint32_t BUTTON_REPEAT_DELAY_MS = 600; constexpr uint32_t BUTTON_REPEAT_MS = 180; constexpr uint32_t FACTORY_RESET_HOLD_MS = 1500; constexpr uint32_t LINK_REPLY_TIMEOUT_MS = 1500; constexpr uint8_t LINK_PACKET_RETRIES = 10; constexpr uint32_t LINK_RETRY_INTERVAL_MS = 1000; constexpr uint32_t LINK_HEARTBEAT_INTERVAL_MS = 500; constexpr uint32_t LINK_HEARTBEAT_TIMEOUT_MS = 2500; constexpr uint32_t FINAL_ACK_RETRY_INTERVAL_MS = 50; constexpr uint8_t FINAL_ACK_RETRIES = 2; constexpr uint8_t NO_SIGNAL_TIMEOUT_PERIODS = 8; constexpr uint16_t RMT_MIN_RECEIVE_SYMBOLS = 48; constexpr uint16_t RMT_MAX_RECEIVE_SYMBOLS = 512; constexpr uint32_t RMT_TARGET_CHUNK_US = 5000; constexpr uint8_t RMT_QUEUE_BLOCKS = 8; constexpr uint16_t PERIOD_BATCH_SIZE = 128; constexpr uint8_t MEASUREMENT_PROGRESS_STEPS = 10; constexpr uint32_t C3_STRICT_MAX_HZ = 1000000; constexpr uint32_t S3_STRICT_MAX_HZ = 1000000; // RMT stores each HIGH/LOW duration in 15 bits. At 80 MHz that limits a // single level to about 409 us, so even a 1 kHz signal with 50% duty cannot // be captured. 20 MHz still provides 20 ticks at 1 MHz (5% resolution), // while allowing level durations up to about 1.64 ms for the 1 kHz/90% case. constexpr uint32_t CAPTURE_RESOLUTION_HZ = 20000000; // Arduino-ESP32 uses the 40 MHz crystal as the default LEDC clock on C3/S3. // Keep this explicit so the resolution calculation never asks LEDC for an // impossible frequency/resolution combination. constexpr uint32_t LEDC_SOURCE_CLOCK_HZ = 40000000; constexpr uint8_t LEDC_CHANNEL = 0; constexpr uint8_t LEDC_MAX_BITS = 14; // -------------------------- Menu value arrays ----------------------------- constexpr uint32_t START_FREQ_OPTIONS_HZ[] = {1000, 2000, 5000, 10000, 20000, 50000}; constexpr uint32_t END_FREQ_OPTIONS_HZ[] = {100000, 200000, 500000, 750000, 1000000}; constexpr uint32_t STEP_OPTIONS_HZ[] = {1000, 2000, 5000, 10000, 20000, 50000, 100000}; constexpr float ACCURACY_OPTIONS_PCT[] = {1.0f, 2.0f, 5.0f, 10.0f}; constexpr uint32_t TEST_TIME_OPTIONS_MS[] = {100, 250, 500, 1000, 2000, 5000}; constexpr uint8_t REPEAT_OPTIONS[] = {1, 2, 3, 5, 10}; constexpr uint8_t DUTY_OPTIONS_PCT[] = {10, 25, 50, 75, 90}; template constexpr size_t countOf(const T (&)[N]) { return N; }