#ifndef PANEL_KEYS_H
#define PANEL_KEYS_H
#include <stdint.h>
#include <stdbool.h>
typedef enum { PK_INVALID,PK_NONE,PK_PLUS,PK_MINUS,PK_BOTH } pk_key;
typedef struct { pk_key candidate;uint32_t candidate_since,last_ms;bool initialized; } pk_decoder;
typedef struct { bool valid,plus,minus;pk_key key; } pk_output;
/* Engineering 12-bit ratiometric ADC model, NOT physical calibration.
   External panel: 10k pull-up to CTRL_3V3; plus path 10k to GND, minus
   path 22k to GND, each switched independently. 1% resistors.
   Unknown values immediately invalidate output; valid state needs >=20ms.
   Poll <=100ms, with independently valid fresh ADC data. */
void pk_init(pk_decoder *s);
pk_key pk_classify(uint16_t raw);
pk_output pk_step(pk_decoder*s,uint16_t raw,bool adc_valid,uint32_t now_ms);
#endif
