Kestrel Interface
Loading...
Searching...
No Matches
kest_effect_settings.c
Go to the documentation of this file.
1#include "kest_int.h"
2
3#ifndef PRINTLINES_ALLOWED
4#define PRINTLINES_ALLOWED 0
5#endif
6
7static const char *FNAME = "kest_effect_settings.c";
8
10{
11 if (!page)
12 return ERR_NULL_PTR;
13
14 init_ui_page(page);
15
17
20
21 page->panel = new_panel();
22
23 if (!page->panel)
24 {
25 return ERR_NULL_PTR;
26 }
27
28 KEST_PRINTF("Created a panel; %p\n", page->panel);
29
31
32 if (!page->data_struct)
33 return ERR_ALLOC_FAIL;
34
36
37 str->text = NULL;
38
42
43 str->band_control_cont = NULL;
44
45 return NO_ERROR;
46}
47
49{
50 if (!page)
51 return ERR_NULL_PTR;
52
54
55 kest_effect *effect = (kest_effect*)data;
56
57 if (!data)
58 return ERR_NULL_PTR;
59
60 char title_buf[128];
61
62 snprintf(title_buf, 128, "%s Settings", kest_effect_name(effect));
63
64 char *title = kest_strndup(title_buf, 128);
65 page->panel->text = title;
66
68
69 if (!str)
70 {
71 return ERR_BAD_ARGS;
72 }
73
74 str->effect = effect;
75
78 configure_setting_widget(&str->band_mode, &effect->band_mode, effect->profile, page);
79
80 page->configured = 1;
81
82 return NO_ERROR;
83}
84
86{
87 kest_ui_page *page = lv_event_get_user_data(e);
88
89 if (!page)
90 return;
91
93
94 if (!str)
95 return;
96
97 if (!str->band_mode.setting || !str->band_mode.setting->options || !str->band_mode.obj)
98 return;
99
100 kest_setting *setting = str->band_mode.setting;
101
102 uint16_t value;
103 char dd_value[128];
104
105 lv_dropdown_get_selected_str(str->band_mode.obj, dd_value, 128);
106
107 KEST_PRINTF("Selected band mode: %s\n", dd_value);
108
109 int found = 0;
110 for (int i = 0; i < setting->n_options; i++)
111 {
112 if (strncmp(dd_value, setting->options[i].name, 128) == 0)
113 {
114 found = 1;
115 value = setting->options[i].value;
116 }
117 }
118
119 if (!found)
120 {
121 // something
122 return;
123 }
124
125 KEST_PRINTF("The associated value is %d\n", value);
126 setting->value = value;
127
129
130 #ifdef USE_TEENSY
131 kest_message msg = create_m_message(KEST_MESSAGE_SET_SETTING_VALUE, "ssss", setting->id.profile_id, setting->id.effect_id, setting->id.setting_id, value);
132
133 queue_msg_to_teensy(msg);
134 #endif
135}
136
138{
139 KEST_PRINTF("create_effect_settings_page_ui\n");
140 if (!page)
141 return ERR_NULL_PTR;
142
144
145 lv_obj_set_layout(page->container, LV_LAYOUT_FLEX);
146 lv_obj_set_flex_flow(page->container, LV_FLEX_FLOW_ROW_WRAP);
147 lv_obj_set_flex_align(page->container, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START);
148
150
151 if (!str)
152 return ERR_BAD_ARGS;
153
154 KEST_PRINTF("page->container = %p\n", page->container);
155
156 //parameter_widget_create_ui(&str->cutoff_freq, page->container);
157
159
160 lv_obj_add_event_cb(str->band_mode.obj, band_control_value_changed_cb, LV_EVENT_VALUE_CHANGED, page);
161
162 str->band_control_cont = lv_obj_create(page->container);
163 lv_obj_remove_style_all(str->band_control_cont);
164
165 lv_obj_set_layout(str->band_control_cont, LV_LAYOUT_FLEX);
166 lv_obj_set_flex_flow(str->band_control_cont, LV_FLEX_FLOW_ROW_WRAP);
167 lv_obj_set_flex_align(str->band_control_cont, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_SPACE_EVENLY);
168 //lv_obj_set_flex_grow(str->band_control_cont, 1);
169
172
174
175 page->ui_created = 1;
176
177 KEST_PRINTF("create_effect_settings_page_ui done\n");
178 return NO_ERROR;
179}
180
181
183{
184 if (!page)
185 return ERR_NULL_PTR;
186
188
189 if (!str)
190 return ERR_NULL_PTR;
191
192 if (str->band_mode.setting && str->band_control_cont)
193 {
194 switch (str->band_mode.setting->value)
195 {
197 if (str->band_lp_cutoff.container)
198 {
199 lv_obj_set_parent(str->band_lp_cutoff.container, global_cxt.pages.backstage);
200 }
201
202 if (str->band_hp_cutoff.container)
203 {
204 lv_obj_set_parent(str->band_hp_cutoff.container, global_cxt.pages.backstage);
205 }
206
207 break;
208
210 if (str->band_lp_cutoff.container)
211 {
212 lv_obj_set_parent(str->band_lp_cutoff.container, global_cxt.pages.backstage);
213 }
214
215 if (str->band_hp_cutoff.container)
216 {
217 lv_obj_set_parent(str->band_hp_cutoff.container, str->band_control_cont);
218 }
219
220 break;
221
223 if (str->band_lp_cutoff.container)
224 {
225 lv_obj_set_parent(str->band_lp_cutoff.container, str->band_control_cont);
226 }
227
228 if (str->band_hp_cutoff.container)
229 {
230 lv_obj_set_parent(str->band_hp_cutoff.container, global_cxt.pages.backstage);
231 }
232
233 break;
234
236 if (str->band_hp_cutoff.container)
237 {
238 lv_obj_set_parent(str->band_hp_cutoff.container, str->band_control_cont);
239 }
240
241 if (str->band_lp_cutoff.container)
242 {
243 lv_obj_set_parent(str->band_lp_cutoff.container, str->band_control_cont);
244 }
245
246
247 break;
248
249 default:
250 return ERR_BAD_ARGS;
251
252 }
253
254 lv_obj_set_size(str->band_control_cont, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
255 lv_obj_update_layout(str->band_control_cont);
256 }
257
258 lv_obj_update_layout(page->container);
259 lv_obj_update_layout(page->screen);
260
261 return NO_ERROR;
262}
263
264
266{
267 return ERR_UNIMPLEMENTED;
268
269 if (!page)
270 return ERR_NULL_PTR;
271
272 return NO_ERROR;
273}
274
275
277{
278 return ERR_UNIMPLEMENTED;
279
280 if (!page)
281 return ERR_NULL_PTR;
282
283 return NO_ERROR;
284}
void * kest_alloc(size_t size)
Definition kest_alloc.c:11
char * kest_strndup(const char *str, size_t n)
Definition kest_alloc.c:73
const char * kest_effect_name(kest_effect *effect)
Definition kest_effect.c:17
#define TRANSFORMER_MODE_UPPER_SPECTRUM
Definition kest_effect.h:5
#define TRANSFORMER_MODE_FULL_SPECTRUM
Definition kest_effect.h:4
#define TRANSFORMER_MODE_BAND
Definition kest_effect.h:7
#define TRANSFORMER_MODE_LOWER_SPECTRUM
Definition kest_effect.h:6
void band_control_value_changed_cb(lv_event_t *e)
int configure_effect_settings_page(kest_ui_page *page, void *data)
int init_effect_settings_page(kest_ui_page *page)
int effect_settings_page_free_all(kest_ui_page *page)
int create_effect_settings_page_ui(kest_ui_page *page)
int refresh_effect_settings_page(kest_ui_page *page)
int free_effect_settings_page_ui(kest_ui_page *page)
#define ERR_ALLOC_FAIL
#define ERR_BAD_ARGS
#define NO_ERROR
#define ERR_UNIMPLEMENTED
#define ERR_NULL_PTR
kest_context global_cxt
Definition kest_int.c:12
int setting_widget_create_ui_no_callback(kest_setting_widget *sw, lv_obj_t *parent)
int configure_setting_widget(kest_setting_widget *sw, kest_setting *setting, kest_profile *profile, kest_ui_page *parent)
int nullify_setting_widget(kest_setting_widget *sw)
int configure_parameter_widget(kest_parameter_widget *pw, kest_parameter *param, kest_profile *profile, kest_ui_page *parent)
int nullify_parameter_widget(kest_parameter_widget *pw)
int parameter_widget_create_ui(kest_parameter_widget *pw, lv_obj_t *parent)
#define KEST_PRINTF(...)
Definition kest_printf.h:10
kest_ui_page_panel * new_panel()
Definition kest_ui.c:991
int ui_page_add_back_button(kest_ui_page *page)
Definition kest_ui.c:1129
int ui_page_create_base_ui(kest_ui_page *page)
Definition kest_ui.c:1207
int init_ui_page(kest_ui_page *page)
Definition kest_ui.c:152
#define KEST_UI_PAGE_TRANS_SET
Definition kest_ui.h:82
kest_parameter_widget band_lp_cutoff
kest_setting_widget band_mode
kest_parameter_widget band_hp_cutoff
kest_setting band_mode
Definition kest_effect.h:25
kest_parameter band_lp_cutoff
Definition kest_effect.h:26
kest_parameter band_hp_cutoff
Definition kest_effect.h:27
struct kest_profile * profile
Definition kest_effect.h:37
kest_setting_option * options
kest_setting_id id
int ui_created
Definition kest_ui.h:107
lv_obj_t * screen
Definition kest_ui.h:89
kest_ui_page_panel * panel
Definition kest_ui.h:94
int(* create_ui)(struct kest_ui_page *page)
Definition kest_ui.h:97
lv_obj_t * container
Definition kest_ui.h:92
void * data_struct
Definition kest_ui.h:104
int configured
Definition kest_ui.h:106
int(* configure)(struct kest_ui_page *page, void *data)
Definition kest_ui.h:96