- Added initial version of Hierarchical Menu
- Beautified the Message Box a bit
This commit is contained in:
@@ -15,14 +15,33 @@
|
||||
|
||||
// ============================================================================================
|
||||
// Defines
|
||||
#define SELECTOR_INC(__SELECTOR__, __MIN__, __MAX__, __CIRCLE__) if((*__SELECTOR__) < __MAX__) { (*__SELECTOR__)++; } else if(__CIRCLE__) { (*__SELECTOR__) = __MIN__; break; } else { break; }
|
||||
#define SELECTOR_DEC(__SELECTOR__, __MIN__, __MAX__, __CIRCLE__) if((*__SELECTOR__) > __MIN__) { (*__SELECTOR__)--; } else if(__CIRCLE__) { (*__SELECTOR__) = __MAX__; break; } else { break; }
|
||||
#define SELECTOR_INC(__SELECTOR__, __STEP__, __MIN__, __MAX__, __CIRCLE__) if((*__SELECTOR__) <= (__MAX__ - __STEP__)) { (*__SELECTOR__)+=__STEP__; } else if(__CIRCLE__) { (*__SELECTOR__) = __MIN__; break; } else { break; }
|
||||
#define SELECTOR_DEC(__SELECTOR__, __STEP__, __MIN__, __MAX__, __CIRCLE__) if((*__SELECTOR__) >= (__MIN__ + __STEP__)) { (*__SELECTOR__)-=__STEP__; } else if(__CIRCLE__) { (*__SELECTOR__) = __MAX__; break; } else { break; }
|
||||
|
||||
|
||||
// ============================================================================================
|
||||
// Datatypes
|
||||
typedef struct {
|
||||
// Configuration
|
||||
const Encoder_Acceleration_Config* config;
|
||||
|
||||
// State tracking
|
||||
uint8_t Speed_Counter; // Current speed counter
|
||||
uint8_t Acceleration_Level; // Current acceleration level (0 = no accel)
|
||||
uint32_t Last_Activity_Time; // Last encoder activity timestamp (ms)
|
||||
|
||||
// Statistics (for debugging)
|
||||
uint32_t Total_Steps; // Total encoder steps processed
|
||||
uint32_t Accelerated_Steps; // Steps that used acceleration
|
||||
} Encoder_Acceleration_Instance;
|
||||
|
||||
|
||||
// ============================================================================================
|
||||
// Variables
|
||||
|
||||
// Default configuration
|
||||
static const Encoder_Acceleration_Config _Default_Acceleration_Config = {
|
||||
.Base_Step = 1,
|
||||
.Base_Threshold = 5, // Requires more steps to trigger
|
||||
.Level_Step = 3, // Bigger jumps between levels
|
||||
.Max_Level = 3, // Fewer levels
|
||||
@@ -30,6 +49,7 @@ static const Encoder_Acceleration_Config _Default_Acceleration_Config = {
|
||||
.Multipliers = {1, 2, 3, 5, 7, 10, 13, 16, 20, 25}
|
||||
};
|
||||
|
||||
|
||||
static Encoder_Acceleration_Instance _Acceleration_Instance;
|
||||
static bool _Acceleration_Initialized = false;
|
||||
static bool _Acceleration_Enabled = false;
|
||||
@@ -65,9 +85,9 @@ void UI_Control_Selector_Inc(int32_t* selector, int32_t minimum, int32_t maximum
|
||||
{
|
||||
// if(_EEPROM_Content.Device_Configuration.Reverse_List_Scrolling == 0) {
|
||||
if(true) {
|
||||
SELECTOR_INC(selector, minimum, maximum, circle_around);
|
||||
SELECTOR_INC(selector, _Acceleration_Instance.config->Base_Step, minimum, maximum, circle_around);
|
||||
} else {
|
||||
SELECTOR_DEC(selector, minimum, maximum, circle_around);
|
||||
SELECTOR_DEC(selector, _Acceleration_Instance.config->Base_Step, minimum, maximum, circle_around);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,9 +108,9 @@ void UI_Control_Selector_Dec(int32_t* selector, int32_t minimum, int32_t maximum
|
||||
{
|
||||
// if(_EEPROM_Content.Device_Configuration.Reverse_List_Scrolling == 0) {
|
||||
if(true) {
|
||||
SELECTOR_DEC(selector, minimum, maximum, circle_around);
|
||||
SELECTOR_DEC(selector, _Acceleration_Instance.config->Base_Step, minimum, maximum, circle_around);
|
||||
} else {
|
||||
SELECTOR_INC(selector, minimum, maximum, circle_around);
|
||||
SELECTOR_INC(selector, _Acceleration_Instance.config->Base_Step, minimum, maximum, circle_around);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user