menu "Zacus Game Hardware"

    config ZACUS_P7_COFFRE_ENABLE
        bool "Enable P7 coffre actuator (servo or relay)"
        default n
        help
            Drives the unlocking actuator for the final chest (P7) when
            STEP_FINAL_WIN is reached. When disabled all p7_coffre_*()
            functions are empty stubs so callers compile without #ifdef.
            Enable once the actuator (9g servo or 5V relay) is wired up.

    if ZACUS_P7_COFFRE_ENABLE

        choice ZACUS_P7_ACTUATOR_TYPE
            prompt "Actuator type"
            default ZACUS_P7_ACTUATOR_SERVO
            help
                Select the hardware wired to CONFIG_ZACUS_P7_GPIO.
                SERVO  – 50 Hz PWM via LEDC (TIMER_2 / CHANNEL_2).
                RELAY  – logic-level GPIO output (active-high or active-low).

            config ZACUS_P7_ACTUATOR_SERVO
                bool "Servo PWM (9g, 50 Hz LEDC)"
            config ZACUS_P7_ACTUATOR_RELAY
                bool "Relay / solid-state switch (GPIO)"
        endchoice

        config ZACUS_P7_GPIO
            int "GPIO pin for the actuator"
            default 13
            range 0 48
            help
                GPIO number for the servo signal wire or the relay control
                input. Default 13 is free on the Freenove Media Kit board.

        if ZACUS_P7_ACTUATOR_SERVO
            config ZACUS_P7_SERVO_LOCK_DEG
                int "Servo lock angle (degrees, 0-180)"
                default 0
                range 0 180
                help
                    Angle at which the servo holds the coffre locked.
                    Corresponds to a 500-2500 µs pulse on a 20 ms period.

            config ZACUS_P7_SERVO_UNLOCK_DEG
                int "Servo unlock angle (degrees, 0-180)"
                default 90
                range 0 180
                help
                    Angle driven on STEP_FINAL_WIN to open the coffre.
        endif

        if ZACUS_P7_ACTUATOR_RELAY
            config ZACUS_P7_RELAY_ACTIVE_HIGH
                bool "Relay active-HIGH (coil energised when GPIO=1)"
                default y
                help
                    Set y for most 5V relay modules with active-high inputs.
                    Set n for active-low modules (e.g. opto-coupled boards
                    where the relay fires when the pin is pulled LOW).

            config ZACUS_P7_RELAY_PULSE_MS
                int "Relay pulse duration (ms, 0 = hold permanently)"
                default 800
                range 0 10000
                help
                    If > 0 the relay is energised for this many milliseconds
                    then returned to rest (one-shot electronic latch).
                    Set 0 to keep the relay energised until p7_coffre_lock()
                    is called (e.g. when a magnetic solenoid holds the bolt).
        endif

    endif # ZACUS_P7_COFFRE_ENABLE

    # ─── P5 Morse / telegraph key ───────────────────────────────────────────────

    config ZACUS_P5_MORSE_ENABLE
        bool "Enable P5 Morse puzzle (telegraph key input)"
        default n
        help
            Drives the P5 code-Morse puzzle: player taps a telegraph key and
            the firmware decodes dot/dash sequences. When disabled all
            p5_morse_*() functions are empty stubs so callers compile without
            #ifdef guards.
            Enable once the telegraph key (or push button) is wired up.

    if ZACUS_P5_MORSE_ENABLE

        config ZACUS_P5_GPIO
            int "GPIO pin for the telegraph key / button"
            default 14
            range 0 48
            help
                Input GPIO. The key connects this pin to GND when pressed.
                An internal pull-up is enabled by the driver.

        config ZACUS_P5_ACTIVE_LOW
            bool "Key active-LOW (pressed = GPIO reads 0)"
            default y
            help
                Set y when using a standard normally-open button to GND
                (internal pull-up enabled). Set n for active-high sensors.

        config ZACUS_P5_DOT_MS
            int "Maximum dot press duration (ms)"
            default 200
            range 10 2000
            help
                A key press shorter than or equal to this value is decoded
                as a dot. Presses above this threshold become dashes.

        config ZACUS_P5_DASH_MS
            int "Minimum dash press duration (ms)"
            default 600
            range 50 5000
            help
                A key press must last at least this long to be decoded as a
                dash. Presses between DOT_MS+1 and DASH_MS-1 are discarded
                as noise or accidental touches.

        config ZACUS_P5_GAP_MS
            int "Letter-gap silence duration (ms)"
            default 800
            range 100 5000
            help
                Silence between key presses longer than this value triggers
                decoding of the accumulated symbol (letter boundary).

    endif # ZACUS_P5_MORSE_ENABLE

    # ─── P6 NFC / alchemical symbols ────────────────────────────────────────────

    config ZACUS_P6_NFC_ENABLE
        bool "Enable P6 NFC puzzle (alchemical symbol tags)"
        default n
        help
            Drives the P6 alchemical-symbols puzzle: the player places NFC
            tags (NTAG213) on a wooden tablet; the firmware reads the UIDs
            and checks the placement order. When disabled all p6_nfc_*()
            functions are empty stubs so callers compile without #ifdef guards.
            Enable once the NFC reader module is wired up.

    if ZACUS_P6_NFC_ENABLE

        choice ZACUS_P6_READER_TYPE
            prompt "NFC reader IC"
            default ZACUS_P6_READER_PN532
            help
                Select the NFC reader module on the board.
                PN532  – NXP PN532 (common breakout, SPI or I2C).
                PN7150 – NXP PN7150 (NCI-based, I2C only).

            config ZACUS_P6_READER_PN532
                bool "PN532 (NXP)"
            config ZACUS_P6_READER_PN7150
                bool "PN7150 (NXP NCI)"
        endchoice

        choice ZACUS_P6_BUS_TYPE
            prompt "Communication bus"
            default ZACUS_P6_BUS_I2C
            help
                Select the bus connecting the ESP32 to the NFC reader.
                I2C – two-wire, uses SDA/SCL. PN7150 only supports I2C.
                SPI – four-wire, faster. PN532 only.

            config ZACUS_P6_BUS_I2C
                bool "I2C"
            config ZACUS_P6_BUS_SPI
                bool "SPI (PN532 only)"
        endchoice

        config ZACUS_P6_I2C_SDA
            int "I2C SDA GPIO"
            default 8
            range 0 48
            depends on ZACUS_P6_BUS_I2C
            help
                GPIO number for the I2C data line (SDA).
                Default 8 is free on the Freenove Media Kit board.

        config ZACUS_P6_I2C_SCL
            int "I2C SCL GPIO"
            default 9
            range 0 48
            depends on ZACUS_P6_BUS_I2C
            help
                GPIO number for the I2C clock line (SCL).
                Default 9 is free on the Freenove Media Kit board.

        config ZACUS_P6_I2C_ADDR
            hex "NFC reader I2C address"
            default 0x24
            range 0x08 0x77
            depends on ZACUS_P6_BUS_I2C
            help
                7-bit I2C address of the NFC reader.
                PN532 default: 0x24. PN7150 default: 0x28.

        config ZACUS_P6_IRQ_GPIO
            int "IRQ / data-ready GPIO (-1 = polling mode)"
            default -1
            range -1 48
            help
                Optional interrupt / data-ready pin from the NFC reader.
                Set -1 to use polling mode (5 Hz by default).
                When wired, the driver waits for a falling edge before
                reading, which reduces SPI/I2C bus traffic.

    endif # ZACUS_P6_NFC_ENABLE

endmenu
