-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathlv_settings.h
109 lines (89 loc) · 2.75 KB
/
lv_settings.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
* @file lv_settings.h
*
*/
#ifndef LV_SETTINGS_H
#define LV_SETTINGS_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef enum {
LV_SETTINGS_TYPE_LIST_BTN,
LV_SETTINGS_TYPE_BTN,
LV_SETTINGS_TYPE_SW,
LV_SETTINGS_TYPE_DDLIST,
LV_SETTINGS_TYPE_NUMSET,
LV_SETTINGS_TYPE_SLIDER,
LV_SETTINGS_TYPE_INV = 0xff,
}lv_settings_type_t;
typedef struct lv_settings_item{
lv_settings_type_t type;
char * name; /*Name or title of the item*/
char * value; /*The current value as string*/
int32_t state; /*The current state, e.g. slider's value, switch state as a number */
lv_obj_t * cont;
lv_obj_user_data_t * data;
}lv_settings_item_t;
typedef struct slider_config{
uint16_t min_step;
uint16_t max_step;
}slider_config_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a settings application
* @param root_item descriptor of the settings button. For example:
* `lv_settings_menu_item_t root_item = {.name = "Settings", .event_cb = root_event_cb};`
* @return the created settings button
*/
void lv_settings_create(lv_settings_item_t * root_item, lv_obj_t * parent, uint8_t original_tab, lv_event_cb_t event_cb);
/**
* Automatically add the item to a group to allow navigation with keypad or encoder.
* Should be called before `lv_settings_create`
* The group can be change at any time.
* @param g the group to use. `NULL` to not use this feature.
*/
void lv_settings_set_group(lv_group_t * g);
/**
* Change the maximum width of settings dialog object
* @param max_width maximum width of the settings container page
*/
void lv_settings_set_max_width(lv_coord_t max_width);
/**
* Create a new page ask `event_cb` to add the item with `LV_EVENT_REFRESH`
* @param parent_item pointer to an item which open the the new page. Its `name` will be the title
* @param event_cb event handler of the menu page
*/
void lv_settings_open_page(lv_settings_item_t * parent_item, lv_event_cb_t event_cb);
/**
* Add a list element to the page. With `item->name` and `item->value` texts.
* @param page pointer to a menu page created by `lv_settings_create_page`
*/
lv_obj_t * lv_settings_add(lv_settings_item_t * item);
/**
* Refresh an item's name value and state.
* @param item pointer to a an `lv_settings_item _t` item.
*/
void lv_settings_refr(lv_settings_item_t * item);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_TEMPL_H*/