/*
 * File: UI_Control.h
 * Created: Created: Friday August 2025 10:21:04
 * Author: Chris
 */
#ifndef UI_CONTROL_H
#define UI_CONTROL_H

// ============================================================================================
// Includes
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>

#include "pico/stdlib.h"


// ============================================================================================
// Defines
#define CURRENT_TIME_ms     (uint32_t)(time_us_64() / 1000)


// ============================================================================================
// Datatypes
typedef struct {
    uint8_t Base_Step;          // Basic Step width, without any multiplier         
    uint8_t Base_Threshold;     // Steps needed to trigger level 1 acceleration
    uint8_t Level_Step;         // Additional steps per acceleration level
    uint8_t Max_Level;          // Maximum acceleration level (1-10)
    uint16_t Timeout_ms;        // Inactivity timeout to reset acceleration (ms)
    uint8_t Multipliers[10];    // Multiplier for each acceleration level
} Encoder_Acceleration_Config;


// ============================================================================================
// Function Declarations
void UI_Control_Init(void);

void UI_Control_Selector_Inc(int32_t* selector, int32_t minimum, int32_t maximum, bool circle_around);
void UI_Control_Selector_Dec(int32_t* selector, int32_t minimum, int32_t maximum, bool circle_around);


void UI_Control_Acceleration_Init_Custom(const Encoder_Acceleration_Config* config);
void UI_Control_Acceleration_Set_Enabled(bool enable);
void UI_Control_Acceleration_Reset(void);
void UI_Control_Acceleration_Update(uint32_t current_time_ms);

uint8_t UI_Control_Acceleration_Get_Level(void);
bool UI_Control_Acceleration_Is_Active(void);
void UI_Control_Acceleration_Get_Stats(uint32_t* total_steps, uint32_t* accelerated_steps);

#endif // UI_CONTROL_H