PER Firmware
Loading...
Searching...
No Matches
menu_system.h
Go to the documentation of this file.
1
11
#ifndef MENU_SYSTEM_H
12
#define MENU_SYSTEM_H
13
14
#include <stdint.h>
15
16
// Element types
17
typedef
enum
{
18
ELEMENT_VAL = 0,
// Numeric value
19
ELEMENT_FLT = 1,
// Float value
20
ELEMENT_BAR = 2,
// (not supported but easy to implement)
21
ELEMENT_BUTTON = 3,
// Button type
22
ELEMENT_OPTION = 4,
// On/off toggle
23
ELEMENT_LIST = 5
// Item in a list
24
} element_type_t;
25
26
// Element states
27
typedef
enum
{
28
STATE_NORMAL = 0,
29
STATE_HOVER = 1,
30
STATE_SELECTED = 2
31
} element_state_t;
32
33
// Element structure
34
typedef
struct
{
35
element_type_t type;
36
element_state_t state;
37
char
* object_name;
// Nextion object name
38
void (*on_change)(void);
// Callback when value changes
39
uint16_t current_value;
// Current value for numeric types or on/off state for toggles
40
uint16_t min_value;
// Minimum value for numeric types
41
uint16_t max_value;
// Maximum value for numeric types
42
uint8_t increment;
// Increment for numeric types
43
}
menu_element_t
;
44
45
// Page structure
46
typedef
struct
{
47
menu_element_t
* elements;
// Array of elements
48
uint8_t num_elements;
// Number of elements in array
49
uint8_t current_index;
// Currently selected element index
50
bool
is_element_selected;
// Is an element currently selected?
51
bool
saved;
// Generic saved state flag
52
}
menu_page_t
;
53
54
// Navigation functions
55
void
MS_moveUp
(
menu_page_t
* page);
56
void
MS_moveDown
(
menu_page_t
* page);
57
void
MS_select
(
menu_page_t
* page);
58
59
// Value modification functions
60
void
MS_incrementValue
(
menu_element_t
* element);
61
void
MS_decrementValue
(
menu_element_t
* element);
62
63
void
MS_refreshPage
(
menu_page_t
* page);
64
int8_t
MS_listGetSelected
(
menu_page_t
* page);
65
66
#endif
// MENU_SYSTEM_H
MS_listGetSelected
int8_t MS_listGetSelected(menu_page_t *page)
Gets the index of the selected element in a menu page.
Definition
menu_system.c:234
MS_decrementValue
void MS_decrementValue(menu_element_t *element)
Decrements the value of a menu element and updates its display.
Definition
menu_system.c:179
MS_moveDown
void MS_moveDown(menu_page_t *page)
Moves menu selection down or increments selected element value.
Definition
menu_system.c:70
MS_select
void MS_select(menu_page_t *page)
Handles menu element selection and actions.
Definition
menu_system.c:91
MS_refreshPage
void MS_refreshPage(menu_page_t *page)
Refreshes the menu page by resetting selection state and updating all elements.
Definition
menu_system.c:203
MS_moveUp
void MS_moveUp(menu_page_t *page)
Moves menu selection up or increments selected element value.
Definition
menu_system.c:49
MS_incrementValue
void MS_incrementValue(menu_element_t *element)
Increments the value of a menu element and updates its display.
Definition
menu_system.c:152
menu_element_t
Definition
menu_system.h:34
menu_page_t
Definition
menu_system.h:46
source
dashboard
lcd
menu_system.h
Generated by
1.12.0