ESP32-C3 based hot wire game with WS2812B LED effects, SSD1306 OLED display, debounced touch detection, and full game state machine (IDLE → COUNTDOWN → PLAYING → GAME_OVER). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
3.1 KiB
C
51 lines
3.1 KiB
C
#ifndef CONFIG_H
|
|
#define CONFIG_H
|
|
|
|
// ── Pin Assignments ─────────────────────────────────────────────────
|
|
#define PIN_NEOPIXEL 8 // WS2812B data (330Ω series resistor recommended)
|
|
#define PIN_SDA 4 // I2C SDA (OLED)
|
|
#define PIN_SCL 5 // I2C SCL (OLED)
|
|
#define PIN_WIRE_TOUCH 2 // Wire touch detect (INPUT_PULLUP, loop-to-GND)
|
|
#define PIN_START_BTN 3 // Start button (INPUT_PULLUP, button-to-GND)
|
|
#define PIN_BUZZER 10 // Optional passive piezo buzzer
|
|
|
|
// ── LED Configuration ───────────────────────────────────────────────
|
|
#define NUM_LEDS 16 // Number of WS2812B LEDs (adjustable 10-20)
|
|
#define LED_BRIGHTNESS 60 // Default brightness (0-255)
|
|
|
|
// ── OLED Configuration ──────────────────────────────────────────────
|
|
#define SCREEN_WIDTH 128
|
|
#define SCREEN_HEIGHT 64
|
|
#define OLED_ADDR 0x3C
|
|
#define DISPLAY_UPDATE_MS 150 // Throttle display updates to avoid I2C flicker
|
|
|
|
// ── Game Timing ─────────────────────────────────────────────────────
|
|
#define GAME_DURATION_S 60 // Game duration in seconds
|
|
#define COUNTDOWN_SECS 3 // Countdown before game starts
|
|
#define MAX_STRIKES 10 // Maximum strikes before game over
|
|
|
|
// ── Debounce ────────────────────────────────────────────────────────
|
|
#define TOUCH_DEBOUNCE_MS 200 // Touch detection debounce
|
|
#define BUTTON_DEBOUNCE_MS 50 // Start button debounce
|
|
|
|
// ── Scoring ─────────────────────────────────────────────────────────
|
|
#define SCORE_BASE 1000 // Starting score
|
|
#define SCORE_STRIKE_PENALTY 50 // Points lost per strike
|
|
#define SCORE_TIME_DIVISOR 100 // elapsed_ms / divisor = time penalty
|
|
|
|
// ── Buzzer Tones ────────────────────────────────────────────────────
|
|
#define TONE_COUNTDOWN_HZ 800
|
|
#define TONE_GO_HZ 1200
|
|
#define TONE_TOUCH_HZ 1000
|
|
#define TONE_WIN_HZ 1500
|
|
#define TONE_LOSE_HZ 400
|
|
#define TONE_DURATION_MS 150
|
|
|
|
// ── Loop Timing ─────────────────────────────────────────────────────
|
|
#define LOOP_DELAY_MS 10 // Main loop delay for watchdog
|
|
|
|
// ── Version ─────────────────────────────────────────────────────────
|
|
#define VERSION_STR "v1.0"
|
|
|
|
#endif // CONFIG_H
|