#ifndef DRILL_UI_H
#define DRILL_UI_H
#include "drill_click.h"
#include "speed_supervisor.h"
#define DUI_MAIN_RELEASE 1u
#define DUI_HANDPIECE_RELEASE 2u
typedef struct {
 dc_decoder clicks;
 ds_supervisor speed;
 uint32_t knob_rpm;
 int8_t requested_direction;
 bool configured;
} dui_control;
typedef struct {
 ds_output speed;
 dc_command main_command, handpiece_command;
 bool command_accepted, command_rejected;
} dui_report;
/* Initial beginner mode and direction +1 are provisional engineering choices. */
bool dui_init(dui_control *u, const ds_config *cfg, uint32_t click_ms, uint32_t now);
/* release_mask contains debounced release EDGES, not key levels. Poll regularly.
   startup_ready is an explicit handoff from a separately validated startup
   controller; this module does not align/start the rotor or drive hardware.
   Process expired sequences BEFORE current edges so late edges are preserved. */
dui_report dui_tick(dui_control *u, uint32_t now, uint8_t release_mask,
                    uint32_t knob_rpm, const ds_inputs *in, bool startup_ready);
/* Immediate user/power stop: cancels pending clicks. Does not clear faults. */
void dui_stop(dui_control *u);
#endif
