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
char
*
const
*
labels
;
// Optional string labels indexed by current_value
40
uint16_t
current_value
;
// Current value for numeric types or on/off state for toggles
41
uint16_t
min_value
;
// Minimum value for numeric types
42
uint16_t
max_value
;
// Maximum value for numeric types
43
uint8_t
increment
;
// Increment for numeric types
44
}
menu_element_t
;
45
46
// Page structure
47
typedef
struct
{
48
menu_element_t
*
elements
;
// Array of elements
49
uint8_t
num_elements
;
// Number of elements in array
50
uint8_t
current_index
;
// Currently selected element index
51
bool
is_element_selected
;
// Is an element currently selected?
52
bool
saved
;
// Generic saved state flag
53
}
menu_page_t
;
54
55
// Navigation functions
56
void
MS_moveUp
(
menu_page_t
* page);
57
void
MS_moveDown
(
menu_page_t
* page);
58
void
MS_select
(
menu_page_t
* page);
59
60
// Value modification functions
61
void
MS_incrementValue
(
menu_element_t
* element);
62
void
MS_decrementValue
(
menu_element_t
* element);
63
64
void
MS_refreshPage
(
menu_page_t
* page);
65
int8_t
MS_listGetSelected
(
const
menu_page_t
* page);
66
67
#endif
// MENU_SYSTEM_H
MS_decrementValue
void MS_decrementValue(menu_element_t *element)
Decrements the value of a menu element and updates its display.
Definition
menu_system.c:191
MS_listGetSelected
int8_t MS_listGetSelected(const menu_page_t *page)
Gets the index of the selected element in a menu page.
Definition
menu_system.c:246
element_state_t
element_state_t
Definition
menu_system.h:27
STATE_HOVER
@ STATE_HOVER
Definition
menu_system.h:29
STATE_NORMAL
@ STATE_NORMAL
Definition
menu_system.h:28
STATE_SELECTED
@ STATE_SELECTED
Definition
menu_system.h:30
MS_moveDown
void MS_moveDown(menu_page_t *page)
Moves menu selection down or increments selected element value.
Definition
menu_system.c:82
element_type_t
element_type_t
Definition
menu_system.h:17
ELEMENT_BAR
@ ELEMENT_BAR
Definition
menu_system.h:20
ELEMENT_OPTION
@ ELEMENT_OPTION
Definition
menu_system.h:22
ELEMENT_FLT
@ ELEMENT_FLT
Definition
menu_system.h:19
ELEMENT_LIST
@ ELEMENT_LIST
Definition
menu_system.h:23
ELEMENT_VAL
@ ELEMENT_VAL
Definition
menu_system.h:18
ELEMENT_BUTTON
@ ELEMENT_BUTTON
Definition
menu_system.h:21
MS_select
void MS_select(menu_page_t *page)
Handles menu element selection and actions.
Definition
menu_system.c:103
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:215
MS_moveUp
void MS_moveUp(menu_page_t *page)
Moves menu selection up or increments selected element value.
Definition
menu_system.c:61
MS_incrementValue
void MS_incrementValue(menu_element_t *element)
Increments the value of a menu element and updates its display.
Definition
menu_system.c:164
menu_element_t
Definition
menu_system.h:34
menu_element_t::current_value
uint16_t current_value
Definition
menu_system.h:40
menu_element_t::type
element_type_t type
Definition
menu_system.h:35
menu_element_t::max_value
uint16_t max_value
Definition
menu_system.h:42
menu_element_t::increment
uint8_t increment
Definition
menu_system.h:43
menu_element_t::state
element_state_t state
Definition
menu_system.h:36
menu_element_t::labels
char *const * labels
Definition
menu_system.h:39
menu_element_t::object_name
char * object_name
Definition
menu_system.h:37
menu_element_t::min_value
uint16_t min_value
Definition
menu_system.h:41
menu_page_t
Definition
menu_system.h:47
menu_page_t::elements
menu_element_t * elements
Definition
menu_system.h:48
menu_page_t::current_index
uint8_t current_index
Definition
menu_system.h:50
menu_page_t::is_element_selected
bool is_element_selected
Definition
menu_system.h:51
menu_page_t::saved
bool saved
Definition
menu_system.h:52
menu_page_t::num_elements
uint8_t num_elements
Definition
menu_system.h:49
firmware
source
dashboard
driver_interface
menu_system.h
Generated by
1.12.0