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>
55 lines
1.1 KiB
C++
55 lines
1.1 KiB
C++
/*
|
|
* HeisserDraht - ESP32-C3 Buzz Wire Game
|
|
*
|
|
* Hardware:
|
|
* - ESP32-C3 (RISC-V)
|
|
* - 16x WS2812B LEDs on GPIO 8
|
|
* - SSD1306 128x64 OLED on I2C (SDA=4, SCL=5)
|
|
* - Wire touch sensor on GPIO 2 (INPUT_PULLUP, touch = GND)
|
|
* - Start button on GPIO 3 (INPUT_PULLUP, press = GND)
|
|
* - Optional passive buzzer on GPIO 10
|
|
*
|
|
* Game flow: IDLE → COUNTDOWN → PLAYING → GAME_OVER → IDLE
|
|
*/
|
|
|
|
#include "config.h"
|
|
#include "game_logic.h"
|
|
#include "led_effects.h"
|
|
#include "display.h"
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
delay(500);
|
|
Serial.println();
|
|
Serial.println("=== HEISSER DRAHT " VERSION_STR " ===");
|
|
Serial.println("[INIT] Starting...");
|
|
|
|
// Initialize subsystems
|
|
gameInit();
|
|
Serial.println("[INIT] Game logic OK");
|
|
|
|
ledsInit();
|
|
Serial.println("[INIT] LEDs OK");
|
|
|
|
displayInit();
|
|
Serial.println("[INIT] Display OK");
|
|
|
|
Serial.println("[INIT] Ready! Press START to begin.");
|
|
}
|
|
|
|
void loop() {
|
|
// Check inputs
|
|
gameCheckStartButton();
|
|
gameCheckTouch();
|
|
|
|
// Update game state
|
|
gameUpdate();
|
|
|
|
// Update outputs
|
|
ledsUpdate();
|
|
displayUpdate();
|
|
|
|
// Small delay for watchdog
|
|
delay(LOOP_DELAY_MS);
|
|
}
|