#pragma once

// ── Test / Production mode ────────────────────────────────────
// Comment out TEST_MODE before final installation (3–5 min experience)
#define TEST_MODE

// ── Auto-start (Hall sensor bypass) ──────────────────────────
// Define AUTO_START to skip Hall sensor counting and enter the
// experience automatically 5 s after boot. Use to isolate Hall
// sensor issues — all other outputs (LED, motor, audio, haptic)
// run normally. Comment out to restore normal Hall-triggered behaviour.
#define AUTO_START

#ifdef TEST_MODE
  #define EXP_MIN_MS   30000UL   // 30 s
  #define EXP_MAX_MS   60000UL   // 60 s
#else
  #define EXP_MIN_MS  180000UL   // 3 min
  #define EXP_MAX_MS  300000UL   // 5 min
#endif

// ── Pin definitions ──────────────────────────────────────────
#define PIN_I2S_DIN     1
#define PIN_I2S_LRC     2
#define PIN_I2S_BCLK    3
#define PIN_LED_PWM     4
#define PIN_I2C_SDA     5
#define PIN_I2C_SCL     6
#define PIN_MOTOR_PWM   7
#define PIN_HALL        8

// ── PWM ──────────────────────────────────────────────────────
#define PWM_FREQ_MOTOR  20000    // 20 kHz — inaudible motor whine
#define PWM_FREQ_LED    24989    // prime, above camera flicker
#define PWM_RES         8        // 8-bit → 0–255

// ── Trigger ──────────────────────────────────────────────────
#define TRIGGER_PULSES          16
#define IDLE_RESET_MS         5000UL   // [fix #2] was 2000 — more forgiving gap

// ── LED (Idle) ───────────────────────────────────────────────
#define LED_IDLE_FLASH          40     // peak brightness of soft idle pulse
#define IDLE_FLASH_DURATION_MS  500UL  // [fix #1] total duration of sine fade-in/out

// ── LED (Experience) ─────────────────────────────────────────
#define LED_BREATHE_MIN         3      // breathing low end (normal)
#define LED_BREATHE_MAX         40     // breathing high end (normal)
#define LED_HELD_MIN            15     // breathing low end (dial held)
#define LED_HELD_MAX            110    // breathing high end (dial held)
#define BREATHE_PERIOD_MS       7000UL // full breath cycle, normal — slower
#define BREATHE_HELD_MS         3500UL // full breath cycle, dial held (faster)
#define HELD_TRANSITION_MS      800.0f // ms to fully blend held↔normal

// ── Motor ────────────────────────────────────────────────────
#define MOTOR_DUTY              140    // ~55%

// ── Hall sensor ──────────────────────────────────────────────
#define DEBOUNCE_MS             5      // debounce in ms (converted to µs in ISR)
#define DIAL_HELD_TIMEOUT       2000UL // ms with no Hall pulse → dial is held

// ── Audio ────────────────────────────────────────────────────
#define SAMPLE_RATE             44100
#define CHANNELS                1
#define BITS                    16
#define AUDIO_AMBIENT_HZ        200    // ambient tone during experience
#define AUDIO_END_HZ            432    // soothing ending tone
#define AUDIO_END_AMP           7000   // amplitude for ending tone

// Audio amplitude envelope — blended with heldBlend same as LED
#define AUDIO_NORMAL_FLOOR      1000   // quiet floor when dial spinning freely
#define AUDIO_NORMAL_RANGE      5000   // amplitude swing when not held (ceiling = 6000)
#define AUDIO_HELD_FLOOR        2000   // floor when dial held
#define AUDIO_HELD_RANGE        15000  // amplitude swing when held (ceiling = 17000)

// ── Haptic ───────────────────────────────────────────────────
// Effects are chained sequences coded in enterExperience() / enterEnding().
// Available names: eShortSlowBoostTransition2, eMediumSlowBoostTransition2,
//   eLongSlowBoostTransition1, eLongSlowFadeTransition1,
//   eMediumSlowFadeTransition2, eShortSlowFadeTransition2
