Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/nyx/nyx_gui/frontend/gui_options.c
1476 views
1
/*
2
* Copyright (c) 2018-2025 CTCaer
3
*
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms and conditions of the GNU General Public License,
6
* version 2, as published by the Free Software Foundation.
7
*
8
* This program is distributed in the hope it will be useful, but WITHOUT
9
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11
* more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15
*/
16
17
#include <stdlib.h>
18
19
#include <bdk.h>
20
21
#include "gui.h"
22
#include "gui_info.h"
23
#include "../config.h"
24
#include <libs/lvgl/lv_themes/lv_theme_hekate.h>
25
#include <libs/lvgl/lvgl.h>
26
27
#define CLOCK_MIN_YEAR 2025
28
#define CLOCK_MAX_YEAR (CLOCK_MIN_YEAR + 10)
29
#define CLOCK_YEARLIST "2025\n2026\n2027\n2028\n2029\n2030\n2031\n2032\n2033\n2034\n2035"
30
31
extern hekate_config h_cfg;
32
extern nyx_config n_cfg;
33
34
static lv_obj_t *autoboot_btn;
35
static bool autoboot_first_time = true;
36
37
static bool ini_changes_made = false;
38
static bool nyx_changes_made = false;
39
40
void nyx_options_clear_ini_changes_made()
41
{
42
ini_changes_made = false;
43
}
44
45
bool nyx_options_get_ini_changes_made()
46
{
47
return ini_changes_made;
48
}
49
50
static lv_res_t auto_hos_poweroff_toggle(lv_obj_t *btn)
51
{
52
h_cfg.autohosoff = !h_cfg.autohosoff;
53
ini_changes_made = true;
54
55
if (!h_cfg.autohosoff)
56
lv_btn_set_state(btn, LV_BTN_STATE_REL);
57
else
58
lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
59
60
nyx_generic_onoff_toggle(btn);
61
62
return LV_RES_OK;
63
}
64
65
static lv_res_t auto_nogc_toggle(lv_obj_t *btn)
66
{
67
h_cfg.autonogc = !h_cfg.autonogc;
68
ini_changes_made = true;
69
70
if (!h_cfg.autonogc)
71
lv_btn_set_state(btn, LV_BTN_STATE_REL);
72
else
73
lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
74
75
nyx_generic_onoff_toggle(btn);
76
77
return LV_RES_OK;
78
}
79
80
static lv_res_t _update_r2p_action(lv_obj_t *btn)
81
{
82
h_cfg.updater2p = !h_cfg.updater2p;
83
ini_changes_made = true;
84
85
if (!h_cfg.updater2p)
86
lv_btn_set_state(btn, LV_BTN_STATE_REL);
87
else
88
lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
89
90
nyx_generic_onoff_toggle(btn);
91
92
return LV_RES_OK;
93
}
94
95
static lv_res_t _win_autoboot_close_action(lv_obj_t * btn)
96
{
97
if (!h_cfg.autoboot)
98
lv_btn_set_state(autoboot_btn, LV_BTN_STATE_REL);
99
else
100
lv_btn_set_state(autoboot_btn, LV_BTN_STATE_TGL_REL);
101
102
nyx_generic_onoff_toggle(autoboot_btn);
103
104
lv_obj_t * win = lv_win_get_from_btn(btn);
105
106
lv_obj_del(win);
107
108
close_btn = NULL;
109
110
return LV_RES_INV;
111
}
112
113
lv_obj_t *create_window_autoboot(const char *win_title)
114
{
115
static lv_style_t win_bg_style;
116
117
lv_style_copy(&win_bg_style, &lv_style_plain);
118
win_bg_style.body.main_color = LV_COLOR_HEX(theme_bg_color);
119
win_bg_style.body.grad_color = win_bg_style.body.main_color;
120
121
lv_obj_t *win = lv_win_create(lv_scr_act(), NULL);
122
lv_win_set_title(win, win_title);
123
lv_win_set_style(win, LV_WIN_STYLE_BG, &win_bg_style);
124
lv_obj_set_size(win, LV_HOR_RES, LV_VER_RES);
125
126
close_btn = lv_win_add_btn(win, NULL, SYMBOL_CLOSE" Close", _win_autoboot_close_action);
127
128
return win;
129
}
130
131
static lv_res_t _autoboot_disable_action(lv_obj_t *btn)
132
{
133
h_cfg.autoboot = 0;
134
h_cfg.autoboot_list = 0;
135
ini_changes_made = true;
136
137
lv_btn_set_state(autoboot_btn, LV_BTN_STATE_REL);
138
nyx_generic_onoff_toggle(autoboot_btn);
139
140
lv_obj_t * win = lv_win_get_from_btn(btn);
141
142
lv_obj_del(win);
143
144
close_btn = NULL;
145
146
return LV_RES_OK;
147
}
148
149
lv_obj_t *auto_main_list;
150
lv_obj_t *auto_more_list;
151
static lv_res_t _autoboot_enable_main_action(lv_obj_t *btn)
152
{
153
h_cfg.autoboot = lv_list_get_btn_index(auto_main_list, btn) + 1;
154
h_cfg.autoboot_list = 0;
155
ini_changes_made = true;
156
157
lv_btn_set_state(autoboot_btn, LV_BTN_STATE_TGL_REL);
158
nyx_generic_onoff_toggle(autoboot_btn);
159
160
lv_obj_t *obj = lv_obj_get_parent(btn);
161
for (int i = 0; i < 5; i++)
162
obj = lv_obj_get_parent(obj);
163
lv_obj_del(obj);
164
165
close_btn = NULL;
166
167
return LV_RES_INV;
168
}
169
170
static lv_res_t _autoboot_enable_more_action(lv_obj_t *btn)
171
{
172
h_cfg.autoboot = lv_list_get_btn_index(auto_more_list, btn) + 1;
173
h_cfg.autoboot_list = 1;
174
ini_changes_made = true;
175
176
lv_btn_set_state(autoboot_btn, LV_BTN_STATE_TGL_REL);
177
nyx_generic_onoff_toggle(autoboot_btn);
178
179
lv_obj_t *obj = lv_obj_get_parent(btn);
180
for (int i = 0; i < 5; i++)
181
obj = lv_obj_get_parent(obj);
182
lv_obj_del(obj);
183
184
close_btn = NULL;
185
186
return LV_RES_INV;
187
}
188
189
static void _create_autoboot_window()
190
{
191
lv_obj_t *win = create_window_autoboot(SYMBOL_GPS" Auto Boot");
192
lv_win_add_btn(win, NULL, SYMBOL_POWER" Disable", _autoboot_disable_action);
193
194
static lv_style_t h_style;
195
lv_style_copy(&h_style, &lv_style_transp);
196
h_style.body.padding.inner = 0;
197
h_style.body.padding.hor = LV_DPI - (LV_DPI / 4);
198
h_style.body.padding.ver = LV_DPI / 6;
199
200
// Main configurations container.
201
lv_obj_t *h1 = lv_cont_create(win, NULL);
202
lv_cont_set_style(h1, &h_style);
203
lv_cont_set_fit(h1, false, true);
204
lv_obj_set_width(h1, (LV_HOR_RES / 9) * 4);
205
lv_obj_set_click(h1, false);
206
lv_cont_set_layout(h1, LV_LAYOUT_OFF);
207
208
lv_obj_t *label_sep = lv_label_create(h1, NULL);
209
lv_label_set_static_text(label_sep, "");
210
211
lv_obj_t *label_txt = lv_label_create(h1, NULL);
212
lv_label_set_static_text(label_txt, "Main configurations");
213
lv_obj_set_style(label_txt, lv_theme_get_current()->label.prim);
214
lv_obj_align(label_txt, label_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, -(LV_DPI / 4));
215
216
lv_obj_t *line_sep = lv_line_create(h1, NULL);
217
static const lv_point_t line_pp[] = { {0, 0}, { LV_HOR_RES - (LV_DPI - (LV_DPI / 4)) * 2, 0} };
218
lv_line_set_points(line_sep, line_pp, 2);
219
lv_line_set_style(line_sep, lv_theme_get_current()->line.decor);
220
lv_obj_align(line_sep, label_txt, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 8);
221
222
// Create list and populate it with Main boot entries.
223
lv_obj_t *list_main = lv_list_create(h1, NULL);
224
auto_main_list = list_main;
225
lv_obj_align(list_main, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 4);
226
227
lv_obj_set_size(list_main, LV_HOR_RES * 4 / 10, LV_VER_RES * 4 / 7);
228
lv_list_set_single_mode(list_main, true);
229
230
sd_mount();
231
232
// Parse hekate main configuration.
233
LIST_INIT(ini_sections);
234
if (ini_parse(&ini_sections, "bootloader/hekate_ipl.ini", false))
235
{
236
LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, &ini_sections, link)
237
{
238
if (!strcmp(ini_sec->name, "config") || (ini_sec->type != INI_CHOICE))
239
continue;
240
241
lv_list_add(list_main, NULL, ini_sec->name, _autoboot_enable_main_action);
242
}
243
244
ini_free(&ini_sections);
245
}
246
247
// More configuration container.
248
lv_obj_t *h2 = lv_cont_create(win, NULL);
249
lv_cont_set_style(h2, &h_style);
250
lv_cont_set_fit(h2, false, true);
251
lv_obj_set_width(h2, (LV_HOR_RES / 9) * 4);
252
lv_obj_set_click(h2, false);
253
lv_cont_set_layout(h2, LV_LAYOUT_OFF);
254
lv_obj_align(h2, h1, LV_ALIGN_OUT_RIGHT_TOP, LV_DPI * 17 / 29, 0);
255
256
label_sep = lv_label_create(h2, NULL);
257
lv_label_set_static_text(label_sep, "");
258
259
lv_obj_t *label_txt3 = lv_label_create(h2, NULL);
260
lv_label_set_static_text(label_txt3, "Ini folder configurations");
261
lv_obj_set_style(label_txt3, lv_theme_get_current()->label.prim);
262
lv_obj_align(label_txt3, label_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, -LV_DPI / 11);
263
264
line_sep = lv_line_create(h2, line_sep);
265
lv_obj_align(line_sep, label_txt3, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 2), LV_DPI / 8);
266
lv_line_set_style(line_sep, lv_theme_get_current()->line.decor);
267
268
// Create list and populate it with more cfg boot entries.
269
lv_obj_t *list_more_cfg = lv_list_create(h2, NULL);
270
auto_more_list = list_more_cfg;
271
lv_obj_align(list_more_cfg, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 2, LV_DPI / 4);
272
273
lv_obj_set_size(list_more_cfg, LV_HOR_RES * 4 / 10, LV_VER_RES * 4 / 7);
274
lv_list_set_single_mode(list_more_cfg, true);
275
276
// Parse all .ini files in ini folder.
277
LIST_INIT(ini_list_sections);
278
if (ini_parse(&ini_list_sections, "bootloader/ini", true))
279
{
280
LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, &ini_list_sections, link)
281
{
282
if (!strcmp(ini_sec->name, "config") || (ini_sec->type != INI_CHOICE))
283
continue;
284
285
lv_list_add(list_more_cfg, NULL, ini_sec->name, _autoboot_enable_more_action);
286
}
287
288
ini_free(&ini_list_sections);
289
}
290
291
sd_unmount();
292
}
293
294
static lv_res_t _autoboot_hide_delay_action(lv_obj_t *btn)
295
{
296
if (!autoboot_first_time)
297
_create_autoboot_window();
298
299
if (!h_cfg.autoboot && autoboot_first_time)
300
lv_btn_set_state(btn, LV_BTN_STATE_REL);
301
else
302
lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
303
autoboot_first_time = false;
304
305
nyx_generic_onoff_toggle(btn);
306
307
return LV_RES_INV;
308
}
309
310
static lv_res_t _autoboot_delay_action(lv_obj_t *ddlist)
311
{
312
u32 new_selection = lv_ddlist_get_selected(ddlist);
313
if (h_cfg.bootwait != new_selection)
314
{
315
h_cfg.bootwait = new_selection;
316
ini_changes_made = true;
317
}
318
319
return LV_RES_OK;
320
}
321
322
static lv_res_t _slider_brightness_action(lv_obj_t * slider)
323
{
324
display_backlight_brightness(lv_slider_get_value(slider) - 20, 0);
325
h_cfg.backlight = lv_slider_get_value(slider);
326
ini_changes_made = true;
327
328
return LV_RES_OK;
329
}
330
331
static lv_res_t _data_verification_action(lv_obj_t *ddlist)
332
{
333
u32 new_selection = lv_ddlist_get_selected(ddlist);
334
if (n_cfg.verification != new_selection)
335
{
336
n_cfg.verification = new_selection;
337
nyx_changes_made = true;
338
}
339
340
return LV_RES_OK;
341
}
342
343
static lv_res_t _entries_columns_action(lv_obj_t *btn)
344
{
345
n_cfg.entries_5_col = !n_cfg.entries_5_col;
346
nyx_changes_made = true;
347
348
if (!n_cfg.entries_5_col)
349
lv_btn_set_state(btn, LV_BTN_STATE_REL);
350
else
351
lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
352
353
nyx_generic_onoff_toggle(btn);
354
355
return LV_RES_OK;
356
}
357
358
static lv_res_t _save_nyx_options_action(lv_obj_t *btn)
359
{
360
static const char * mbox_btn_map[] = {"\251", "\222OK!", "\251", ""};
361
lv_obj_t * mbox = lv_mbox_create(lv_scr_act(), NULL);
362
lv_mbox_set_recolor_text(mbox, true);
363
364
int res = !create_nyx_config_entry(true);
365
366
nyx_changes_made = false;
367
368
if (res)
369
lv_mbox_set_text(mbox, "#FF8000 Nyx Configuration#\n\n#96FF00 The configuration was saved to sd card!#");
370
else
371
lv_mbox_set_text(mbox, "#FF8000 Nyx Configuration#\n\n#FFDD00 Failed to save the configuration#\n#FFDD00 to sd card!#");
372
lv_mbox_add_btns(mbox, mbox_btn_map, NULL);
373
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
374
lv_obj_set_top(mbox, true);
375
376
return LV_RES_OK;
377
}
378
379
void create_flat_button(lv_obj_t *parent, lv_obj_t *btn, lv_color_t color, lv_action_t action)
380
{
381
lv_style_t *btn_onoff_rel_hos_style = malloc(sizeof(lv_style_t));
382
lv_style_t *btn_onoff_pr_hos_style = malloc(sizeof(lv_style_t));
383
lv_style_copy(btn_onoff_rel_hos_style, lv_theme_get_current()->btn.rel);
384
btn_onoff_rel_hos_style->body.main_color = color;
385
btn_onoff_rel_hos_style->body.grad_color = btn_onoff_rel_hos_style->body.main_color;
386
btn_onoff_rel_hos_style->body.padding.hor = 0;
387
btn_onoff_rel_hos_style->body.radius = 0;
388
389
lv_style_copy(btn_onoff_pr_hos_style, lv_theme_get_current()->btn.pr);
390
btn_onoff_pr_hos_style->body.main_color = color;
391
btn_onoff_pr_hos_style->body.grad_color = btn_onoff_pr_hos_style->body.main_color;
392
btn_onoff_pr_hos_style->body.padding.hor = 0;
393
btn_onoff_pr_hos_style->body.border.color = LV_COLOR_GRAY;
394
btn_onoff_pr_hos_style->body.border.width = 4;
395
btn_onoff_pr_hos_style->body.radius = 0;
396
397
lv_btn_set_style(btn, LV_BTN_STYLE_REL, btn_onoff_rel_hos_style);
398
lv_btn_set_style(btn, LV_BTN_STYLE_PR, btn_onoff_pr_hos_style);
399
lv_btn_set_style(btn, LV_BTN_STYLE_TGL_REL, btn_onoff_rel_hos_style);
400
lv_btn_set_style(btn, LV_BTN_STYLE_TGL_PR, btn_onoff_pr_hos_style);
401
402
lv_btn_set_fit(btn, false, true);
403
lv_obj_set_width(btn, lv_obj_get_height(btn));
404
lv_btn_set_toggle(btn, true);
405
406
if (action)
407
lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, action);
408
}
409
410
typedef struct _color_test_ctxt
411
{
412
u32 bg;
413
u16 hue;
414
lv_obj_t *window;
415
lv_obj_t *header1;
416
lv_obj_t *header2;
417
lv_obj_t *label;
418
lv_obj_t *icons;
419
lv_obj_t *slider;
420
lv_obj_t *button;
421
lv_obj_t *hue_slider;
422
lv_obj_t *hue_label;
423
} color_test_ctxt;
424
425
color_test_ctxt color_test;
426
427
static lv_res_t _save_theme_color_action(lv_obj_t *btn)
428
{
429
n_cfg.theme_bg = color_test.bg;
430
n_cfg.theme_color = color_test.hue;
431
432
// Save nyx config.
433
create_nyx_config_entry(true);
434
435
reload_nyx(NULL, false);
436
437
return LV_RES_OK;
438
}
439
440
static void _show_new_nyx_color(u32 bg, u16 hue, bool update_bg)
441
{
442
lv_color_t bgc = LV_COLOR_HEX(bg);
443
lv_color_t bgc_light = LV_COLOR_HEX(bg ? (bg + 0x101010) : 0x2D2D2D);
444
lv_color_t bg_border = LV_COLOR_HEX(bg ? (bg + 0x202020) : 0x3D3D3D);
445
lv_color_t color = lv_color_hsv_to_rgb(hue, 100, 100);
446
447
if (update_bg)
448
{
449
static lv_style_t win_bg_test;
450
lv_style_copy(&win_bg_test, lv_win_get_style(color_test.window, LV_WIN_STYLE_BG));
451
win_bg_test.body.main_color = bgc;
452
win_bg_test.body.grad_color = win_bg_test.body.main_color;
453
lv_win_set_style(color_test.window, LV_WIN_STYLE_BG, &win_bg_test);
454
455
static lv_style_t win_hdr_test;
456
lv_style_copy(&win_hdr_test, lv_win_get_style(color_test.window, LV_WIN_STYLE_HEADER));
457
win_hdr_test.body.main_color = bgc;
458
win_hdr_test.body.grad_color = win_hdr_test.body.main_color;
459
lv_win_set_style(color_test.window, LV_WIN_STYLE_HEADER, &win_hdr_test);
460
461
static lv_style_t hdr1_bg_test;
462
lv_style_copy(&hdr1_bg_test, lv_cont_get_style(color_test.header1));
463
hdr1_bg_test.body.main_color = bgc;
464
hdr1_bg_test.body.grad_color = hdr1_bg_test.body.main_color;
465
lv_cont_set_style(color_test.header1, &hdr1_bg_test);
466
467
static lv_style_t hdr2_bg_test;
468
lv_style_copy(&hdr2_bg_test, lv_cont_get_style(color_test.header2));
469
hdr2_bg_test.body.main_color = bgc;
470
hdr2_bg_test.body.grad_color = hdr2_bg_test.body.main_color;
471
lv_cont_set_style(color_test.header2, &hdr2_bg_test);
472
}
473
else
474
{
475
static lv_style_t txt_test;
476
lv_style_copy(&txt_test, lv_label_get_style(color_test.label));
477
txt_test.text.color = color;
478
lv_obj_set_style(color_test.label, &txt_test);
479
lv_obj_set_style(color_test.icons, &txt_test);
480
}
481
482
static lv_style_t btn_tgl_pr_test;
483
lv_style_copy(&btn_tgl_pr_test, lv_btn_get_style(color_test.button, LV_BTN_STATE_TGL_PR));
484
btn_tgl_pr_test.body.main_color = bgc_light;
485
btn_tgl_pr_test.body.grad_color = btn_tgl_pr_test.body.main_color;
486
btn_tgl_pr_test.body.border.color = color;
487
btn_tgl_pr_test.text.color = color;
488
lv_btn_set_style(color_test.button, LV_BTN_STATE_TGL_PR, &btn_tgl_pr_test);
489
490
static lv_style_t slider_bg, slider_test, slider_ind;
491
lv_style_copy(&slider_bg, lv_slider_get_style(color_test.slider, LV_SLIDER_STYLE_BG));
492
lv_style_copy(&slider_test, lv_slider_get_style(color_test.slider, LV_SLIDER_STYLE_KNOB));
493
lv_style_copy(&slider_ind, lv_slider_get_style(color_test.slider, LV_SLIDER_STYLE_INDIC));
494
slider_bg.body.main_color = bg_border;
495
slider_bg.body.grad_color = slider_bg.body.main_color;
496
slider_test.body.main_color = color;
497
slider_test.body.grad_color = slider_test.body.main_color;
498
slider_ind.body.main_color = lv_color_hsv_to_rgb(hue, 100, 72);
499
slider_ind.body.grad_color = slider_ind.body.main_color;
500
lv_slider_set_style(color_test.slider, LV_SLIDER_STYLE_BG, &slider_bg);
501
lv_slider_set_style(color_test.slider, LV_SLIDER_STYLE_KNOB, &slider_test);
502
lv_slider_set_style(color_test.slider, LV_SLIDER_STYLE_INDIC, &slider_ind);
503
}
504
505
static lv_res_t _slider_hue_action(lv_obj_t *slider)
506
{
507
if (color_test.hue != lv_slider_get_value(slider))
508
{
509
color_test.hue = lv_slider_get_value(slider);
510
_show_new_nyx_color(color_test.bg, color_test.hue, false);
511
char hue[8];
512
s_printf(hue, "%03d", color_test.hue);
513
lv_label_set_text(color_test.hue_label, hue);
514
}
515
516
return LV_RES_OK;
517
}
518
519
static lv_res_t _preset_bg_action(lv_obj_t *btn)
520
{
521
//! TODO: Support a range?
522
if (color_test.bg)
523
color_test.bg = 0;
524
else
525
color_test.bg = COLOR_HOS_BG;
526
_show_new_nyx_color(color_test.bg, color_test.hue, true);
527
528
return LV_RES_OK;
529
}
530
531
static lv_res_t _preset_hue_action(lv_obj_t *btn)
532
{
533
lv_btn_ext_t *ext = lv_obj_get_ext_attr(btn);
534
535
if (color_test.hue != ext->idx)
536
{
537
color_test.hue = ext->idx;
538
_show_new_nyx_color(color_test.bg, color_test.hue, false);
539
char hue[8];
540
s_printf(hue, "%03d", color_test.hue);
541
lv_label_set_text(color_test.hue_label, hue);
542
lv_bar_set_value(color_test.hue_slider, color_test.hue);
543
}
544
545
return LV_RES_OK;
546
}
547
548
static const u16 theme_colors[17] = {
549
4, 13, 23, 33, 43, 54, 66, 89, 124, 167, 187, 200, 208, 231, 261, 291, 341
550
};
551
552
static lv_res_t _create_window_nyx_colors(lv_obj_t *btn)
553
{
554
lv_obj_t *win = nyx_create_standard_window(SYMBOL_COPY" Nyx Color Theme");
555
lv_win_add_btn(win, NULL, SYMBOL_HINT" Toggle Background", _preset_bg_action);
556
lv_win_add_btn(win, NULL, SYMBOL_SAVE" Save & Reload", _save_theme_color_action);
557
color_test.window = win;
558
559
// Set current theme colors.
560
color_test.bg = n_cfg.theme_bg;
561
color_test.hue = n_cfg.theme_color;
562
563
lv_obj_t *sep = lv_label_create(win, NULL);
564
lv_label_set_static_text(sep, "");
565
lv_obj_align(sep, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
566
567
// Create container to keep content inside.
568
lv_obj_t *h1 = lv_cont_create(win, NULL);
569
lv_obj_set_size(h1, LV_HOR_RES - (LV_DPI * 8 / 10), LV_VER_RES / 7);
570
color_test.header1 = h1;
571
572
// Create color preset buttons.
573
lv_obj_t *color_btn = lv_btn_create(h1, NULL);
574
lv_btn_ext_t *ext = lv_obj_get_ext_attr(color_btn);
575
ext->idx = theme_colors[0];
576
create_flat_button(h1, color_btn, lv_color_hsv_to_rgb(theme_colors[0], 100, 100), _preset_hue_action);
577
lv_obj_t *color_btn2;
578
579
for (u32 i = 1; i < 17; i++)
580
{
581
color_btn2 = lv_btn_create(h1, NULL);
582
ext = lv_obj_get_ext_attr(color_btn2);
583
ext->idx = theme_colors[i];
584
create_flat_button(h1, color_btn2, lv_color_hsv_to_rgb(theme_colors[i], 100, 100), _preset_hue_action);
585
lv_obj_align(color_btn2, color_btn, LV_ALIGN_OUT_RIGHT_MID, 0, 0);
586
color_btn = color_btn2;
587
}
588
589
lv_obj_align(h1, sep, LV_ALIGN_OUT_BOTTOM_MID, 0, LV_DPI / 4);
590
591
// Create hue slider.
592
lv_obj_t * slider = lv_slider_create(win, NULL);
593
lv_obj_set_width(slider, 1070);
594
lv_obj_set_height(slider, LV_DPI * 4 / 10);
595
lv_bar_set_range(slider, 0, 359);
596
lv_bar_set_value(slider, color_test.hue);
597
lv_slider_set_action(slider, _slider_hue_action);
598
lv_obj_align(slider, h1, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
599
color_test.hue_slider = slider;
600
601
// Create hue label.
602
lv_obj_t *hue_text_label = lv_label_create(win, NULL);
603
lv_obj_align(hue_text_label, slider, LV_ALIGN_OUT_RIGHT_MID, LV_DPI * 24 / 100, 0);
604
char hue[8];
605
s_printf(hue, "%03d", color_test.hue);
606
lv_label_set_text(hue_text_label, hue);
607
color_test.hue_label = hue_text_label;
608
609
// Create sample text.
610
lv_obj_t *h2 = lv_cont_create(win, NULL);
611
lv_obj_set_size(h2, LV_HOR_RES - (LV_DPI * 8 / 10), LV_VER_RES / 3);
612
lv_obj_align(h2, slider, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI);
613
color_test.header2 = h2;
614
615
lv_obj_t *lbl_sample = lv_label_create(h2, NULL);
616
lv_label_set_static_text(lbl_sample, "Sample:");
617
618
lv_obj_t *lbl_test = lv_label_create(h2, NULL);
619
lv_label_set_long_mode(lbl_test, LV_LABEL_LONG_BREAK);
620
lv_label_set_static_text(lbl_test,
621
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, "
622
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "
623
"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris "
624
"nisi ut aliquip ex ea commodo consequat.");
625
lv_obj_set_width(lbl_test, lv_obj_get_width(h2) - LV_DPI * 6 / 10);
626
lv_obj_align(lbl_test, lbl_sample, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 5);
627
color_test.label = lbl_test;
628
629
// Create sample icons.
630
lv_obj_t *lbl_icons = lv_label_create(h2, NULL);
631
lv_label_set_static_text(lbl_icons,
632
SYMBOL_BRIGHTNESS SYMBOL_CHARGE SYMBOL_FILE SYMBOL_DRIVE SYMBOL_FILE_CODE
633
SYMBOL_EDIT SYMBOL_HINT SYMBOL_DRIVE SYMBOL_KEYBOARD SYMBOL_POWER);
634
lv_obj_align(lbl_icons, lbl_test, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI * 2 / 5);
635
color_test.icons = lbl_icons;
636
637
// Create sample slider.
638
lv_obj_t *slider_test = lv_slider_create(h2, NULL);
639
lv_obj_align(slider_test, lbl_test, LV_ALIGN_OUT_BOTTOM_MID, 0, LV_DPI * 2 / 5);
640
lv_obj_set_click(slider_test, false);
641
lv_bar_set_value(slider_test, 60);
642
color_test.slider = slider_test;
643
644
// Create sample button.
645
lv_obj_t *btn_test = lv_btn_create(h2, NULL);
646
lv_btn_set_state(btn_test, LV_BTN_STATE_TGL_PR);
647
lv_obj_align(btn_test, lbl_test, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, LV_DPI / 5);
648
lv_label_create(btn_test, NULL);
649
lv_obj_set_click(btn_test, false);
650
color_test.button = btn_test;
651
652
_show_new_nyx_color(color_test.bg, color_test.hue, false);
653
654
return LV_RES_OK;
655
}
656
657
typedef struct _time_edit_obj_t
658
{
659
lv_obj_t *year;
660
lv_obj_t *month;
661
lv_obj_t *day;
662
lv_obj_t *hour;
663
lv_obj_t *min;
664
} time_edit_obj_t;
665
666
time_edit_obj_t clock_ctxt;
667
668
static lv_res_t _action_clock_edit(lv_obj_t *btns, const char * txt)
669
{
670
int btn_idx = lv_btnm_get_pressed(btns);
671
672
if (btn_idx == 1)
673
{
674
rtc_time_t time;
675
max77620_rtc_get_time(&time);
676
u32 epoch = max77620_rtc_date_to_epoch(&time);
677
678
u32 year = lv_roller_get_selected(clock_ctxt.year);
679
u32 month = lv_roller_get_selected(clock_ctxt.month) + 1;
680
u32 day = lv_roller_get_selected(clock_ctxt.day) + 1;
681
u32 hour = lv_roller_get_selected(clock_ctxt.hour);
682
u32 min = lv_roller_get_selected(clock_ctxt.min);
683
684
switch (month)
685
{
686
case 2:
687
if (!(year % 4) && day > 29)
688
day = 29;
689
else if (day > 28)
690
day = 28;
691
break;
692
case 4:
693
case 6:
694
case 9:
695
case 11:
696
if (day > 30)
697
day = 30;
698
break;
699
}
700
701
time.year = year + CLOCK_MIN_YEAR;
702
time.month = month;
703
time.day = day;
704
time.hour = hour;
705
time.min = min;
706
707
u32 new_epoch = max77620_rtc_date_to_epoch(&time);
708
709
// Stored in u32 and allow overflow for integer offset casting.
710
n_cfg.timeoff = new_epoch - epoch;
711
712
// If canceled set 1 for invalidating first boot clock edit.
713
if (!n_cfg.timeoff)
714
n_cfg.timeoff = 1;
715
else
716
max77620_rtc_set_epoch_offset((int)n_cfg.timeoff);
717
718
nyx_changes_made = true;
719
}
720
721
mbox_action(btns, txt);
722
723
return LV_RES_INV;
724
}
725
726
static lv_res_t _action_clock_edit_save(lv_obj_t *btns, const char * txt)
727
{
728
_action_clock_edit(btns, txt);
729
730
// Save if changes were made.
731
if (nyx_changes_made)
732
_save_nyx_options_action(NULL);
733
734
return LV_RES_INV;
735
}
736
737
static lv_res_t _create_mbox_clock_edit(lv_obj_t *btn)
738
{
739
lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL);
740
lv_obj_set_style(dark_bg, &mbox_darken);
741
lv_obj_set_size(dark_bg, LV_HOR_RES, LV_VER_RES);
742
743
static const char *mbox_btn_map[] = { "\251", "\222Done", "\222Cancel", "\251", "" };
744
lv_obj_t *mbox = lv_mbox_create(dark_bg, NULL);
745
lv_mbox_set_recolor_text(mbox, true);
746
lv_obj_set_width(mbox, LV_HOR_RES / 9 * 6);
747
748
lv_mbox_set_text(mbox, "Enter #C7EA46 Date# and #C7EA46 Time# for Nyx\nThis will not alter the actual HW clock!");
749
750
// Get current time.
751
rtc_time_t time;
752
max77620_rtc_get_time_adjusted(&time);
753
754
// Normalize year if out of range.
755
if (time.year < CLOCK_MIN_YEAR)
756
time.year = CLOCK_MIN_YEAR;
757
else if (time.year > CLOCK_MAX_YEAR)
758
time.year = CLOCK_MAX_YEAR;
759
760
time.year -= CLOCK_MIN_YEAR;
761
762
lv_obj_t *h1 = lv_cont_create(mbox, NULL);
763
lv_cont_set_fit(h1, true, true);
764
765
// Create year roller.
766
lv_obj_t *roller_year = lv_roller_create(h1, NULL);
767
lv_roller_set_options(roller_year, CLOCK_YEARLIST);
768
lv_roller_set_selected(roller_year, time.year, false);
769
lv_roller_set_visible_row_count(roller_year, 3);
770
clock_ctxt.year = roller_year;
771
772
// Create month roller.
773
lv_obj_t *roller_month = lv_roller_create(h1, roller_year);
774
lv_roller_set_options(roller_month,
775
"January\n"
776
"February\n"
777
"March\n"
778
"April\n"
779
"May\n"
780
"June\n"
781
"July\n"
782
"August\n"
783
"September\n"
784
"October\n"
785
"November\n"
786
"December");
787
lv_roller_set_selected(roller_month, time.month - 1, false);
788
lv_obj_align(roller_month, roller_year, LV_ALIGN_OUT_RIGHT_MID, 0, 0);
789
clock_ctxt.month = roller_month;
790
791
// Create day roller.
792
static char days[256];
793
days[0] = 0;
794
for (u32 i = 1; i < 32; i++)
795
s_printf(days + strlen(days), " %d \n", i);
796
days[strlen(days) - 1] = 0;
797
lv_obj_t *roller_day = lv_roller_create(h1, roller_year);
798
lv_roller_set_options(roller_day, days);
799
lv_roller_set_selected(roller_day, time.day - 1, false);
800
lv_obj_align(roller_day, roller_month, LV_ALIGN_OUT_RIGHT_MID, 0, 0);
801
clock_ctxt.day = roller_day;
802
803
// Create hours roller.
804
static char hours[256];
805
hours[0] = 0;
806
for (u32 i = 0; i < 24; i++)
807
s_printf(hours + strlen(hours), " %d \n", i);
808
hours[strlen(hours) - 1] = 0;
809
lv_obj_t *roller_hour = lv_roller_create(h1, roller_year);
810
lv_roller_set_options(roller_hour, hours);
811
lv_roller_set_selected(roller_hour, time.hour, false);
812
lv_obj_align(roller_hour, roller_day, LV_ALIGN_OUT_RIGHT_MID, LV_DPI / 2, 0);
813
clock_ctxt.hour = roller_hour;
814
815
// Create minutes roller.
816
static char minutes[512];
817
minutes[0] = 0;
818
for (u32 i = 0; i < 60; i++)
819
s_printf(minutes + strlen(minutes), " %02d \n", i);
820
minutes[strlen(minutes) - 1] = 0;
821
lv_obj_t *roller_minute = lv_roller_create(h1, roller_year);
822
lv_roller_set_options(roller_minute, minutes);
823
lv_roller_set_selected(roller_minute, time.min, false);
824
lv_obj_align(roller_minute, roller_hour, LV_ALIGN_OUT_RIGHT_MID, 0, 0);
825
clock_ctxt.min = roller_minute;
826
827
// If btn is empty, save options also because it was launched from boot.
828
lv_mbox_add_btns(mbox, mbox_btn_map, btn ? _action_clock_edit : _action_clock_edit_save);
829
830
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
831
lv_obj_set_top(mbox, true);
832
833
return LV_RES_OK;
834
}
835
836
void first_time_clock_edit(void *param)
837
{
838
_create_mbox_clock_edit(NULL);
839
}
840
841
static lv_res_t _joycon_info_dump_action(lv_obj_t * btn)
842
{
843
FIL fp;
844
int error = 0;
845
int cal_error = 0;
846
bool is_l_hos = false;
847
bool is_r_hos = false;
848
bool nx_hoag = fuse_read_hw_type() == FUSE_NX_HW_TYPE_HOAG;
849
jc_gamepad_rpt_t *jc_pad = jc_get_bt_pairing_info(&is_l_hos, &is_r_hos);
850
851
char *data = (char *)malloc(SZ_16K);
852
char *txt_buf = (char *)malloc(SZ_4K);
853
854
if (!nx_hoag && !jc_pad)
855
error = 255;
856
857
// Try 2 times to get factory calibration data.
858
for (u32 i = 0; i < 2; i++)
859
{
860
if (!error)
861
cal_error = hos_dump_cal0();
862
if (!cal_error)
863
break;
864
}
865
866
if (cal_error && nx_hoag)
867
error = cal_error;
868
869
if (error)
870
goto disabled_or_cal0_issue;
871
872
if (nx_hoag)
873
goto save_data;
874
875
// Count valid joycon.
876
u32 joycon_found = jc_pad->bt_conn_l.type ? 1 : 0;
877
if (jc_pad->bt_conn_r.type)
878
joycon_found++;
879
880
// Reset PC based for dumping.
881
jc_pad->bt_conn_l.type = is_l_hos ? jc_pad->bt_conn_l.type : 0;
882
jc_pad->bt_conn_r.type = is_r_hos ? jc_pad->bt_conn_r.type : 0;
883
884
save_data:
885
error = !sd_mount() ? 5 : 0;
886
887
if (!error)
888
{
889
nx_emmc_cal0_t *cal0 = (nx_emmc_cal0_t *)cal0_buf;
890
891
f_mkdir("switchroot");
892
893
if (!nx_hoag)
894
{
895
// Save binary dump.
896
memcpy(data, &jc_pad->bt_conn_l, sizeof(jc_bt_conn_t));
897
memcpy(data + sizeof(jc_bt_conn_t), &jc_pad->bt_conn_r, sizeof(jc_bt_conn_t));
898
899
error = sd_save_to_file((u8 *)data, sizeof(jc_bt_conn_t) * 2, "switchroot/joycon_mac.bin") ? 4 : 0;
900
901
// Save readable dump.
902
jc_bt_conn_t *bt = &jc_pad->bt_conn_l;
903
s_printf(data,
904
"[joycon_00]\ntype=%d\nmac=%02X:%02X:%02X:%02X:%02X:%02X\n"
905
"host=%02X:%02X:%02X:%02X:%02X:%02X\n"
906
"ltk=%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\n\n",
907
bt->type, bt->mac[0], bt->mac[1], bt->mac[2], bt->mac[3], bt->mac[4], bt->mac[5],
908
bt->host_mac[0], bt->host_mac[1], bt->host_mac[2], bt->host_mac[3], bt->host_mac[4], bt->host_mac[5],
909
bt->ltk[0], bt->ltk[1], bt->ltk[2], bt->ltk[3], bt->ltk[4], bt->ltk[5], bt->ltk[6], bt->ltk[7],
910
bt->ltk[8], bt->ltk[9], bt->ltk[10], bt->ltk[11], bt->ltk[12], bt->ltk[13], bt->ltk[14], bt->ltk[15]);
911
bt = &jc_pad->bt_conn_r;
912
s_printf(data + strlen(data),
913
"[joycon_01]\ntype=%d\nmac=%02X:%02X:%02X:%02X:%02X:%02X\n"
914
"host=%02X:%02X:%02X:%02X:%02X:%02X\n"
915
"ltk=%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\n",
916
bt->type, bt->mac[0], bt->mac[1], bt->mac[2], bt->mac[3], bt->mac[4], bt->mac[5],
917
bt->host_mac[0], bt->host_mac[1], bt->host_mac[2], bt->host_mac[3], bt->host_mac[4], bt->host_mac[5],
918
bt->ltk[0], bt->ltk[1], bt->ltk[2], bt->ltk[3], bt->ltk[4], bt->ltk[5], bt->ltk[6], bt->ltk[7],
919
bt->ltk[8], bt->ltk[9], bt->ltk[10], bt->ltk[11], bt->ltk[12], bt->ltk[13], bt->ltk[14], bt->ltk[15]);
920
921
if (!error)
922
error = f_open(&fp, "switchroot/joycon_mac.ini", FA_WRITE | FA_CREATE_ALWAYS) ? 4 : 0;
923
if (!error)
924
{
925
f_puts(data, &fp);
926
f_close(&fp);
927
}
928
929
f_mkdir("switchroot");
930
931
// Save IMU Calibration data.
932
if (!error && !cal_error)
933
{
934
s_printf(data,
935
"imu_type=%d\n\n"
936
"acc_cal_off_x=0x%X\n"
937
"acc_cal_off_y=0x%X\n"
938
"acc_cal_off_z=0x%X\n"
939
"acc_cal_scl_x=0x%X\n"
940
"acc_cal_scl_y=0x%X\n"
941
"acc_cal_scl_z=0x%X\n\n"
942
943
"gyr_cal_off_x=0x%X\n"
944
"gyr_cal_off_y=0x%X\n"
945
"gyr_cal_off_z=0x%X\n"
946
"gyr_cal_scl_x=0x%X\n"
947
"gyr_cal_scl_y=0x%X\n"
948
"gyr_cal_scl_z=0x%X\n\n"
949
950
"device_bt_mac=%02X:%02X:%02X:%02X:%02X:%02X\n",
951
cal0->console_6axis_sensor_type,
952
cal0->acc_offset[0], cal0->acc_offset[1], cal0->acc_offset[2],
953
cal0->acc_scale[0], cal0->acc_scale[1], cal0->acc_scale[2],
954
cal0->gyro_offset[0], cal0->gyro_offset[1], cal0->gyro_offset[2],
955
cal0->gyro_scale[0], cal0->gyro_scale[1], cal0->gyro_scale[2],
956
cal0->bd_mac[0], cal0->bd_mac[1], cal0->bd_mac[2], cal0->bd_mac[3], cal0->bd_mac[4], cal0->bd_mac[5]);
957
958
error = f_open(&fp, "switchroot/switch.cal", FA_WRITE | FA_CREATE_ALWAYS) ? 4 : 0;
959
if (!error)
960
{
961
f_puts(data, &fp);
962
f_close(&fp);
963
}
964
}
965
}
966
else
967
{
968
jc_calib_t *stick_cal_l = (jc_calib_t *)cal0->analog_stick_cal_l;
969
jc_calib_t *stick_cal_r = (jc_calib_t *)cal0->analog_stick_cal_r;
970
971
// Save Lite Gamepad and IMU Calibration data.
972
// Actual max/min are right/left and up/down offsets.
973
s_printf(data,
974
"lite_cal_l_type=0x%X\n"
975
"lite_cal_lx_lof=0x%X\n"
976
"lite_cal_lx_cnt=0x%X\n"
977
"lite_cal_lx_rof=0x%X\n"
978
"lite_cal_ly_dof=0x%X\n"
979
"lite_cal_ly_cnt=0x%X\n"
980
"lite_cal_ly_uof=0x%X\n\n"
981
982
"lite_cal_r_type=0x%X\n"
983
"lite_cal_rx_lof=0x%X\n"
984
"lite_cal_rx_cnt=0x%X\n"
985
"lite_cal_rx_rof=0x%X\n"
986
"lite_cal_ry_dof=0x%X\n"
987
"lite_cal_ry_cnt=0x%X\n"
988
"lite_cal_ry_uof=0x%X\n\n"
989
990
"imu_type=%d\n\n"
991
"acc_cal_off_x=0x%X\n"
992
"acc_cal_off_y=0x%X\n"
993
"acc_cal_off_z=0x%X\n"
994
"acc_cal_scl_x=0x%X\n"
995
"acc_cal_scl_y=0x%X\n"
996
"acc_cal_scl_z=0x%X\n\n"
997
998
"gyr_cal_off_x=0x%X\n"
999
"gyr_cal_off_y=0x%X\n"
1000
"gyr_cal_off_z=0x%X\n"
1001
"gyr_cal_scl_x=0x%X\n"
1002
"gyr_cal_scl_y=0x%X\n"
1003
"gyr_cal_scl_z=0x%X\n\n"
1004
1005
"device_bt_mac=%02X:%02X:%02X:%02X:%02X:%02X\n",
1006
cal0->analog_stick_type_l,
1007
stick_cal_l->x_min, stick_cal_l->x_center, stick_cal_l->x_max,
1008
stick_cal_l->y_min, stick_cal_l->y_center, stick_cal_l->y_max,
1009
cal0->analog_stick_type_r,
1010
stick_cal_r->x_min, stick_cal_r->x_center, stick_cal_r->x_max,
1011
stick_cal_r->y_min, stick_cal_r->y_center, stick_cal_r->y_max,
1012
cal0->console_6axis_sensor_type,
1013
cal0->acc_offset[0], cal0->acc_offset[1], cal0->acc_offset[2],
1014
cal0->acc_scale[0], cal0->acc_scale[1], cal0->acc_scale[2],
1015
cal0->gyro_offset[0], cal0->gyro_offset[1], cal0->gyro_offset[2],
1016
cal0->gyro_scale[0], cal0->gyro_scale[1], cal0->gyro_scale[2],
1017
cal0->bd_mac[0], cal0->bd_mac[1], cal0->bd_mac[2], cal0->bd_mac[3], cal0->bd_mac[4], cal0->bd_mac[5]);
1018
if (!error)
1019
error = f_open(&fp, "switchroot/switch.cal", FA_WRITE | FA_CREATE_ALWAYS) ? 4 : 0;
1020
if (!error)
1021
{
1022
f_puts(data, &fp);
1023
f_close(&fp);
1024
}
1025
}
1026
1027
sd_unmount();
1028
}
1029
1030
disabled_or_cal0_issue:;
1031
lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL);
1032
lv_obj_set_style(dark_bg, &mbox_darken);
1033
lv_obj_set_size(dark_bg, LV_HOR_RES, LV_VER_RES);
1034
1035
static const char *mbox_btn_map[] = { "\251", "\222OK", "\251", "" };
1036
lv_obj_t * mbox = lv_mbox_create(dark_bg, NULL);
1037
lv_mbox_set_recolor_text(mbox, true);
1038
lv_obj_set_width(mbox, LV_HOR_RES / 9 * 5);
1039
1040
if (!error)
1041
{
1042
if (!nx_hoag)
1043
{
1044
s_printf(txt_buf,
1045
"Dumping to SD card finished!\n"
1046
"Saved to: #C7EA46 switchroot/joycon_mac.[bin/ini]#\n\n");
1047
1048
bool success = true;
1049
1050
// Check if pairing info was found.
1051
if (joycon_found == 2)
1052
strcat(txt_buf, "#C7EA46 Success!#\n#C7EA46 Found 2 out of 2 Joy-Con pairing data!#\n");
1053
else
1054
{
1055
s_printf(txt_buf + strlen(txt_buf), "#FF8000 Failed!#\n#FF8000 Warning:# Found #FFDD00 %d out of 2# pairing data!\n", joycon_found);
1056
success = false;
1057
}
1058
1059
// Check if pairing was done in HOS.
1060
if (is_l_hos && is_r_hos)
1061
strcat(txt_buf, "#C7EA46 Both pairing data are HOS based!#");
1062
else if (!is_l_hos && is_r_hos)
1063
{
1064
strcat(txt_buf, "#FF8000 Warning:# #FFDD00 Left# pairing data is not HOS based!");
1065
success = false;
1066
}
1067
else if (is_l_hos && !is_r_hos)
1068
{
1069
strcat(txt_buf, "#FF8000 Warning:# #FFDD00 Right# pairing data is not HOS based!");
1070
success = false;
1071
}
1072
else
1073
{
1074
strcat(txt_buf, "#FF8000 Warning:# #FFDD00 No# pairing data is HOS based!");
1075
success = false;
1076
}
1077
1078
if (!success)
1079
strcat(txt_buf,
1080
"\n\n#FFDD00 Make sure that both Joy-Con are connected,#\n"
1081
"#FFDD00 and that you paired them in HOS!#");
1082
1083
if (cal_error)
1084
s_printf(txt_buf + strlen(txt_buf), "\n\n#FF8000 Warning: Failed (%d) to get IMU calibration!#", cal_error);
1085
}
1086
else
1087
{
1088
s_printf(txt_buf,
1089
"Dumping to SD card finished!\n"
1090
"Saved to: #C7EA46 switchroot/switch.cal#\n\n");
1091
strcat(txt_buf, "#C7EA46 Success!#\n#C7EA46 Found Lite Gamepad data!#\n");
1092
}
1093
}
1094
else
1095
{
1096
if (!nx_hoag)
1097
s_printf(txt_buf, "#FFDD00 Failed to dump Joy-Con pairing info!#\n#FFDD00 Error: %d#", error);
1098
else
1099
s_printf(txt_buf, "#FFDD00 Failed to get Lite Gamepad info!#\n#FFDD00 Error: %d#", error);
1100
}
1101
1102
lv_mbox_set_text(mbox, txt_buf);
1103
1104
lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); // Important. After set_text.
1105
1106
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
1107
lv_obj_set_top(mbox, true);
1108
1109
free(txt_buf);
1110
free(data);
1111
1112
return LV_RES_OK;
1113
}
1114
1115
static lv_res_t _home_screen_action(lv_obj_t *ddlist)
1116
{
1117
u32 new_selection = lv_ddlist_get_selected(ddlist);
1118
if (n_cfg.home_screen != new_selection)
1119
{
1120
n_cfg.home_screen = new_selection;
1121
nyx_changes_made = true;
1122
}
1123
1124
return LV_RES_OK;
1125
}
1126
1127
static lv_res_t _action_nyx_options_save(lv_obj_t *btns, const char * txt)
1128
{
1129
int btn_idx = lv_btnm_get_pressed(btns);
1130
1131
mbox_action(btns, txt);
1132
1133
if (!btn_idx)
1134
_save_nyx_options_action(NULL);
1135
1136
return LV_RES_INV;
1137
}
1138
1139
static void _check_nyx_changes()
1140
{
1141
if (nyx_changes_made)
1142
{
1143
lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL);
1144
lv_obj_set_style(dark_bg, &mbox_darken);
1145
lv_obj_set_size(dark_bg, LV_HOR_RES, LV_VER_RES);
1146
1147
static const char * mbox_btn_map[] = { "\222Save", "\222Cancel", "" };
1148
lv_obj_t * mbox = lv_mbox_create(dark_bg, NULL);
1149
lv_mbox_set_recolor_text(mbox, true);
1150
1151
lv_mbox_set_text(mbox,
1152
"#FF8000 Nyx configuration#\n\n"
1153
"You changed the configuration!\n\n"
1154
"Do you want to save it?");
1155
1156
lv_mbox_add_btns(mbox, mbox_btn_map, _action_nyx_options_save);
1157
lv_obj_set_width(mbox, LV_HOR_RES / 9 * 5);
1158
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
1159
lv_obj_set_top(mbox, true);
1160
1161
nyx_changes_made = false;
1162
}
1163
}
1164
1165
static lv_res_t _action_win_nyx_options_close(lv_obj_t *btn)
1166
{
1167
// Hide status bar options save button.
1168
lv_obj_set_opa_scale(status_bar.mid, LV_OPA_0);
1169
lv_obj_set_click(status_bar.mid, false);
1170
1171
lv_res_t res = nyx_win_close_action_custom(btn);
1172
1173
_check_nyx_changes();
1174
1175
return res;
1176
}
1177
1178
lv_res_t create_win_nyx_options(lv_obj_t *parrent_btn)
1179
{
1180
lv_theme_t *th = lv_theme_get_current();
1181
1182
lv_obj_t *win = nyx_create_window_custom_close_btn(SYMBOL_HOME" Nyx Settings", _action_win_nyx_options_close);
1183
1184
static lv_style_t h_style;
1185
lv_style_copy(&h_style, &lv_style_transp);
1186
h_style.body.padding.inner = 0;
1187
h_style.body.padding.hor = LV_DPI - (LV_DPI / 4);
1188
h_style.body.padding.ver = LV_DPI / 6;
1189
1190
// Create containers to keep content inside.
1191
lv_obj_t * sw_h2 = lv_cont_create(win, NULL);
1192
lv_cont_set_style(sw_h2, &h_style);
1193
lv_cont_set_fit(sw_h2, false, true);
1194
lv_obj_set_width(sw_h2, (LV_HOR_RES / 9) * 4);
1195
lv_obj_set_click(sw_h2, false);
1196
lv_cont_set_layout(sw_h2, LV_LAYOUT_OFF);
1197
1198
lv_obj_t * sw_h3 = lv_cont_create(win, NULL);
1199
lv_cont_set_style(sw_h3, &h_style);
1200
lv_cont_set_fit(sw_h3, false, true);
1201
lv_obj_set_width(sw_h3, (LV_HOR_RES / 9) * 4);
1202
lv_obj_set_click(sw_h3, false);
1203
lv_cont_set_layout(sw_h3, LV_LAYOUT_OFF);
1204
lv_obj_align(sw_h3, sw_h2, LV_ALIGN_OUT_RIGHT_TOP, LV_DPI * 11 / 25, 0);
1205
1206
lv_obj_t * l_cont = lv_cont_create(sw_h2, NULL);
1207
lv_cont_set_style(l_cont, &lv_style_transp_tight);
1208
lv_cont_set_fit(l_cont, true, true);
1209
lv_obj_set_click(l_cont, false);
1210
lv_cont_set_layout(l_cont, LV_LAYOUT_OFF);
1211
lv_obj_set_opa_scale(l_cont, LV_OPA_40);
1212
1213
lv_obj_t *label_sep = lv_label_create(sw_h2, NULL);
1214
lv_label_set_static_text(label_sep, "");
1215
1216
// Create theme button.
1217
lv_obj_t *btn = lv_btn_create(sw_h2, NULL);
1218
lv_obj_t *label_btn = lv_label_create(btn, NULL);
1219
lv_btn_set_fit(btn, true, true);
1220
lv_label_set_static_text(label_btn, SYMBOL_COPY" Color Theme");
1221
lv_obj_align(btn, label_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, -LV_DPI / 5 + 3);
1222
lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _create_window_nyx_colors);
1223
1224
lv_obj_t *label_txt2 = lv_label_create(sw_h2, NULL);
1225
lv_label_set_recolor(label_txt2, true);
1226
lv_label_set_static_text(label_txt2, "Select a color for all #00FFC8 highlights# in Nyx.\n");
1227
lv_obj_set_style(label_txt2, &hint_small_style);
1228
lv_obj_align(label_txt2, btn, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3 - 8);
1229
1230
// Create home screen settings list.
1231
lv_obj_t *line_sep = lv_line_create(sw_h2, NULL);
1232
static const lv_point_t line_pp[] = { {0, 0}, { LV_HOR_RES - (LV_DPI - (LV_DPI / 4)) * 2, 0} };
1233
lv_line_set_points(line_sep, line_pp, 2);
1234
lv_line_set_style(line_sep, th->line.decor);
1235
lv_obj_align(line_sep, label_txt2, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 4);
1236
1237
lv_obj_t *label_txt = lv_label_create(l_cont, NULL);
1238
lv_label_set_static_text(label_txt, SYMBOL_HOME" Home Screen");
1239
lv_obj_set_style(label_txt, th->label.prim);
1240
lv_obj_align(label_txt, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 4);
1241
1242
lv_obj_t *ddlist = lv_ddlist_create(l_cont, NULL);
1243
lv_obj_set_top(ddlist, true);
1244
lv_ddlist_set_draw_arrow(ddlist, true);
1245
lv_ddlist_set_options(ddlist,
1246
"Main menu \n"
1247
"All Configs\n"
1248
"Launch\n"
1249
"More Configs");
1250
lv_ddlist_set_selected(ddlist, n_cfg.home_screen);
1251
lv_ddlist_set_action(ddlist, _home_screen_action);
1252
lv_obj_align(ddlist, label_txt, LV_ALIGN_OUT_RIGHT_MID, LV_DPI * 2 / 3, 0);
1253
1254
label_txt2 = lv_label_create(l_cont, NULL);
1255
lv_label_set_recolor(label_txt2, true);
1256
lv_label_set_static_text(label_txt2,
1257
"Select what screen to show on Nyx boot.\n"
1258
"#FF8000 All Configs:# #C7EA46 Combines More configs into Launch empty slots.#\n"
1259
"#FF8000 Launch / More Configs:# #C7EA46 Uses the classic divided view.#");
1260
lv_obj_set_style(label_txt2, &hint_small_style);
1261
lv_obj_align(label_txt2, label_txt, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 4);
1262
1263
line_sep = lv_line_create(sw_h2, line_sep);
1264
lv_obj_align(line_sep, label_txt2, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 4);
1265
1266
// Create entries per line button.
1267
lv_obj_t *btn2 = lv_btn_create(sw_h2, NULL);
1268
nyx_create_onoff_button(th, sw_h2, btn2, SYMBOL_GPS" Extended Boot Entries", _entries_columns_action, true);
1269
lv_obj_align(btn2, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 10);
1270
if (n_cfg.entries_5_col)
1271
lv_btn_set_state(btn2, LV_BTN_STATE_TGL_REL);
1272
nyx_generic_onoff_toggle(btn2);
1273
1274
label_txt2 = lv_label_create(sw_h2, NULL);
1275
lv_label_set_recolor(label_txt2, true);
1276
lv_label_set_static_text(label_txt2,
1277
"Sets the boot entries per line to 5. (Default is 4)\n"
1278
"#C7EA46 This allows a total of 10 boot entries to be shown in Launch#\n"
1279
"#C7EA46 and More Configs sections.#\n\n\n");
1280
lv_obj_set_style(label_txt2, &hint_small_style);
1281
lv_obj_align(label_txt2, btn2, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 12);
1282
1283
// Create the second column.
1284
label_sep = lv_label_create(sw_h3, NULL);
1285
lv_label_set_static_text(label_sep, "");
1286
1287
// Create Dump Joy-Con BT button.
1288
lv_obj_t *btn3 = lv_btn_create(sw_h3, NULL);
1289
lv_obj_t *label_btn3 = lv_label_create(btn3, NULL);
1290
lv_btn_set_fit(btn3, true, true);
1291
lv_label_set_static_text(label_btn3, SYMBOL_DOWNLOAD" Dump Joy-Con BT");
1292
lv_obj_align(btn3, label_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, -LV_DPI / 3);
1293
lv_btn_set_action(btn3, LV_BTN_ACTION_CLICK, _joycon_info_dump_action);
1294
1295
label_txt2 = lv_label_create(sw_h3, NULL);
1296
lv_label_set_recolor(label_txt2, true);
1297
lv_label_set_static_text(label_txt2,
1298
"Allows you to save the Switch and Joy-Con MAC addresses\n"
1299
"and the LTKs associated with them. For #C7EA46 Android# and #C7EA46 Linux#.");
1300
lv_obj_set_style(label_txt2, &hint_small_style);
1301
lv_obj_align(label_txt2, btn3, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 4);
1302
1303
line_sep = lv_line_create(sw_h3, line_sep);
1304
lv_obj_align(line_sep, label_txt2, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 4);
1305
1306
// Create Backup/Restore Verification list.
1307
label_txt = lv_label_create(sw_h3, NULL);
1308
lv_label_set_static_text(label_txt, SYMBOL_MODULES_ALT" Data Verification");
1309
lv_obj_set_style(label_txt, th->label.prim);
1310
lv_obj_align(label_txt, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 4);
1311
1312
lv_obj_t *ddlist2 = lv_ddlist_create(sw_h3, NULL);
1313
lv_obj_set_top(ddlist2, true);
1314
lv_ddlist_set_draw_arrow(ddlist2, true);
1315
lv_ddlist_set_options(ddlist2,
1316
"Off (Fastest)\n"
1317
"Sparse (Fast) \n"
1318
"Full (Slow)\n"
1319
"Full (Hashes)");
1320
lv_ddlist_set_selected(ddlist2, n_cfg.verification);
1321
lv_obj_align(ddlist2, label_txt, LV_ALIGN_OUT_RIGHT_MID, LV_DPI * 3 / 8, 0);
1322
lv_ddlist_set_action(ddlist2, _data_verification_action);
1323
1324
label_txt2 = lv_label_create(sw_h3, NULL);
1325
lv_label_set_static_text(label_txt2, "Set the type of data verification done for backup and restore.\n"
1326
"Can be canceled without losing the backup/restore.\n");
1327
lv_obj_set_style(label_txt2, &hint_small_style);
1328
lv_obj_align(label_txt2, label_txt, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 4);
1329
1330
line_sep = lv_line_create(sw_h3, line_sep);
1331
lv_obj_align(line_sep, label_txt2, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 4);
1332
1333
// Create clock edit button.
1334
lv_obj_t *btn5 = lv_btn_create(sw_h3, NULL);
1335
lv_obj_t *label_btn5 = lv_label_create(btn5, NULL);
1336
lv_btn_set_fit(btn5, true, true);
1337
lv_label_set_static_text(label_btn5, SYMBOL_CLOCK" Clock (Offset)");
1338
lv_obj_align(btn5, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 4);
1339
lv_btn_set_action(btn5, LV_BTN_ACTION_CLICK, _create_mbox_clock_edit);
1340
1341
label_txt2 = lv_label_create(sw_h3, NULL);
1342
lv_label_set_recolor(label_txt2, true);
1343
lv_label_set_static_text(label_txt2,
1344
"Change clock offset manually.\n"
1345
"#C7EA46 The entered Date and Time will be converted to an offset#\n"
1346
"#C7EA46 automatically. This will be also used for FatFS operations.#");
1347
lv_obj_set_style(label_txt2, &hint_small_style);
1348
lv_obj_align(label_txt2, btn5, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 4);
1349
1350
// Enable save options button in status bar and set action.
1351
lv_btn_set_action(status_bar.mid, LV_BTN_ACTION_CLICK, _save_nyx_options_action);
1352
lv_obj_set_opa_scale(status_bar.mid, LV_OPA_COVER);
1353
lv_obj_set_click(status_bar.mid, true);
1354
1355
lv_obj_set_top(l_cont, true); // Set the ddlist container at top.
1356
lv_obj_set_parent(ddlist, l_cont); // Reorder ddlist.
1357
lv_obj_set_top(ddlist, true);
1358
lv_obj_set_top(ddlist2, true);
1359
1360
return LV_RES_OK;
1361
}
1362
1363
void create_tab_options(lv_theme_t *th, lv_obj_t *parent)
1364
{
1365
lv_page_set_scrl_layout(parent, LV_LAYOUT_PRETTY);
1366
1367
static lv_style_t h_style;
1368
lv_style_copy(&h_style, &lv_style_transp);
1369
h_style.body.padding.inner = 0;
1370
h_style.body.padding.hor = LV_DPI - (LV_DPI / 4);
1371
h_style.body.padding.ver = LV_DPI / 6;
1372
1373
// Create containers to keep content inside.
1374
lv_obj_t * sw_h2 = lv_cont_create(parent, NULL);
1375
lv_cont_set_style(sw_h2, &h_style);
1376
lv_cont_set_fit(sw_h2, false, true);
1377
lv_obj_set_width(sw_h2, (LV_HOR_RES / 9) * 4);
1378
lv_obj_set_click(sw_h2, false);
1379
lv_cont_set_layout(sw_h2, LV_LAYOUT_OFF);
1380
1381
lv_obj_t * sw_h3 = lv_cont_create(parent, NULL);
1382
lv_cont_set_style(sw_h3, &h_style);
1383
lv_cont_set_fit(sw_h3, false, true);
1384
lv_obj_set_width(sw_h3, (LV_HOR_RES / 9) * 4);
1385
lv_obj_set_click(sw_h3, false);
1386
lv_cont_set_layout(sw_h3, LV_LAYOUT_OFF);
1387
1388
lv_obj_t * l_cont = lv_cont_create(sw_h2, NULL);
1389
lv_cont_set_style(l_cont, &lv_style_transp_tight);
1390
lv_cont_set_fit(l_cont, true, true);
1391
lv_obj_set_click(l_cont, false);
1392
lv_cont_set_layout(l_cont, LV_LAYOUT_OFF);
1393
lv_obj_set_opa_scale(l_cont, LV_OPA_40);
1394
1395
lv_obj_t *label_sep = lv_label_create(sw_h2, NULL);
1396
lv_label_set_static_text(label_sep, "");
1397
1398
// Create Auto Boot button.
1399
lv_obj_t *btn = lv_btn_create(sw_h2, NULL);
1400
if (hekate_bg)
1401
{
1402
lv_btn_set_style(btn, LV_BTN_STYLE_REL, &btn_transp_rel);
1403
lv_btn_set_style(btn, LV_BTN_STYLE_PR, &btn_transp_pr);
1404
lv_btn_set_style(btn, LV_BTN_STYLE_TGL_REL, &btn_transp_tgl_rel);
1405
lv_btn_set_style(btn, LV_BTN_STYLE_TGL_PR, &btn_transp_tgl_pr);
1406
}
1407
lv_btn_set_layout(btn, LV_LAYOUT_OFF);
1408
lv_obj_t *label_btn = lv_label_create(btn, NULL);
1409
lv_label_set_recolor(label_btn, true);
1410
lv_btn_set_fit(btn, true, true);
1411
lv_btn_set_toggle(btn, true);
1412
lv_label_set_static_text(label_btn, SYMBOL_GPS" Auto Boot #00FFC9 ON #");
1413
lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _autoboot_hide_delay_action);
1414
lv_obj_align(btn, label_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, -LV_DPI / 18 + 6);
1415
lv_btn_set_fit(btn, false, false);
1416
autoboot_btn = btn;
1417
1418
lv_obj_t *label_txt2 = lv_label_create(sw_h2, NULL);
1419
lv_label_set_static_text(label_txt2, "Choose which boot entry or payload to automatically boot\nwhen injecting.");
1420
lv_obj_set_style(label_txt2, &hint_small_style);
1421
lv_obj_align(label_txt2, btn, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3 - 4);
1422
1423
lv_obj_t *line_sep = lv_line_create(sw_h2, NULL);
1424
static const lv_point_t line_pp[] = { {0, 0}, { LV_HOR_RES - (LV_DPI - (LV_DPI / 4)) * 2, 0} };
1425
lv_line_set_points(line_sep, line_pp, 2);
1426
lv_line_set_style(line_sep, th->line.decor);
1427
lv_obj_align(line_sep, label_txt2, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 4);
1428
1429
// Create Boot time delay list.
1430
lv_obj_t *label_txt = lv_label_create(l_cont, NULL);
1431
lv_label_set_static_text(label_txt, SYMBOL_CLOCK" Boot Time Delay ");
1432
lv_obj_set_style(label_txt, th->label.prim);
1433
lv_obj_align(label_txt, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 4);
1434
1435
lv_obj_t *ddlist = lv_ddlist_create(l_cont, NULL);
1436
lv_obj_set_top(ddlist, true);
1437
lv_ddlist_set_draw_arrow(ddlist, true);
1438
lv_ddlist_set_options(ddlist,
1439
"No bootlogo \n"
1440
"1 second\n"
1441
"2 seconds\n"
1442
"3 seconds\n"
1443
"4 seconds\n"
1444
"5 seconds\n"
1445
"6 seconds");
1446
lv_ddlist_set_selected(ddlist, 3);
1447
lv_obj_align(ddlist, label_txt, LV_ALIGN_OUT_RIGHT_MID, LV_DPI / 4, 0);
1448
lv_ddlist_set_action(ddlist, _autoboot_delay_action);
1449
lv_ddlist_set_selected(ddlist, h_cfg.bootwait);
1450
1451
if (hekate_bg)
1452
{
1453
lv_ddlist_set_style(ddlist, LV_DDLIST_STYLE_BG, &ddlist_transp_bg);
1454
lv_ddlist_set_style(ddlist, LV_DDLIST_STYLE_BGO, &ddlist_transp_bg);
1455
lv_ddlist_set_style(ddlist, LV_DDLIST_STYLE_PR, &ddlist_transp_sel);
1456
lv_ddlist_set_style(ddlist, LV_DDLIST_STYLE_SEL, &ddlist_transp_sel);
1457
}
1458
1459
label_txt2 = lv_label_create(l_cont, NULL);
1460
lv_label_set_recolor(label_txt2, true);
1461
lv_label_set_static_text(label_txt2,
1462
"Set how long to show bootlogo when autoboot is enabled.\n"
1463
"#C7EA46 You can press# #FF8000 VOL-# #C7EA46 during that time to enter hekate's menu.#\n");
1464
lv_obj_set_style(label_txt2, &hint_small_style);
1465
lv_obj_align(label_txt2, label_txt, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 4);
1466
1467
line_sep = lv_line_create(sw_h2, line_sep);
1468
lv_obj_align(line_sep, label_txt2, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 4);
1469
1470
// Create Auto NoGC button.
1471
lv_obj_t *btn2 = lv_btn_create(sw_h2, NULL);
1472
nyx_create_onoff_button(th, sw_h2, btn2, SYMBOL_CHIP" Auto NoGC", auto_nogc_toggle, true);
1473
lv_obj_align(btn2, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 10);
1474
1475
label_txt2 = lv_label_create(sw_h2, NULL);
1476
lv_label_set_recolor(label_txt2, true);
1477
lv_label_set_static_text(label_txt2,
1478
"It checks fuses and applies the patch automatically\n"
1479
"if higher firmware. It is now a global config and set\n"
1480
"at auto by default. (ON: Auto)\n\n\n");
1481
lv_obj_set_style(label_txt2, &hint_small_style);
1482
lv_obj_align(label_txt2, btn2, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 12);
1483
1484
label_sep = lv_label_create(sw_h3, NULL);
1485
lv_label_set_static_text(label_sep, "");
1486
1487
// Create Auto HOS Power Off button.
1488
lv_obj_t *btn3 = lv_btn_create(sw_h3, NULL);
1489
nyx_create_onoff_button(th, sw_h3, btn3, SYMBOL_POWER" Auto HOS Power Off", auto_hos_poweroff_toggle, true);
1490
lv_obj_align(btn3, label_sep, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
1491
1492
label_txt2 = lv_label_create(sw_h3, NULL);
1493
lv_label_set_static_text(label_txt2,
1494
"When Shutdown is used from HOS, the device wakes up after\n"
1495
"15s. Enable this to automatically power off on the next\npayload injection.");
1496
lv_obj_set_style(label_txt2, &hint_small_style);
1497
lv_obj_align(label_txt2, btn3, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 12);
1498
1499
line_sep = lv_line_create(sw_h3, line_sep);
1500
lv_obj_align(line_sep, label_txt2, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 4);
1501
1502
// Create Backlight slider.
1503
label_txt = lv_label_create(sw_h3, NULL);
1504
lv_label_set_static_text(label_txt, SYMBOL_BRIGHTNESS" Backlight");
1505
lv_obj_set_style(label_txt, th->label.prim);
1506
lv_obj_align(label_txt, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 4);
1507
1508
lv_obj_t * slider = lv_slider_create(sw_h3, NULL);
1509
lv_obj_set_width(slider, LV_DPI * 80 / 34);
1510
//lv_obj_set_height(slider, LV_DPI * 4 / 10);
1511
lv_bar_set_range(slider, 30, 220);
1512
lv_bar_set_value(slider, h_cfg.backlight);
1513
lv_slider_set_action(slider, _slider_brightness_action);
1514
lv_obj_align(slider, label_txt, LV_ALIGN_OUT_RIGHT_MID, LV_DPI * 20 / 15, 0);
1515
1516
label_txt2 = lv_label_create(sw_h3, NULL);
1517
lv_label_set_static_text(label_txt2, "Set backlight brightness.\n\n");
1518
lv_obj_set_style(label_txt2, &hint_small_style);
1519
lv_obj_align(label_txt2, label_txt, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 4);
1520
1521
line_sep = lv_line_create(sw_h3, line_sep);
1522
lv_obj_align(line_sep, label_txt2, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 4);
1523
1524
// Create Update r2p button.
1525
lv_obj_t *btn4 = lv_btn_create(sw_h3, NULL);
1526
nyx_create_onoff_button(th, sw_h3, btn4, SYMBOL_REFRESH" Update Reboot 2 Payload", _update_r2p_action, true);
1527
lv_obj_align(btn4, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 10);
1528
1529
label_txt2 = lv_label_create(sw_h3, NULL);
1530
lv_label_set_recolor(label_txt2, true);
1531
lv_label_set_static_text(label_txt2,
1532
"If #FF8000 FSS0# is used in the selected boot entry, the reboot 2 payload\n"
1533
"binary will be checked and forced to be updated to hekate.\n\n\n\n");
1534
lv_obj_set_style(label_txt2, &hint_small_style);
1535
lv_obj_align(label_txt2, btn4, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 12);
1536
1537
// Set default loaded states.
1538
if (h_cfg.autohosoff)
1539
lv_btn_set_state(btn3, LV_BTN_STATE_TGL_REL);
1540
if (h_cfg.autonogc)
1541
lv_btn_set_state(btn2, LV_BTN_STATE_TGL_REL);
1542
if (h_cfg.updater2p)
1543
lv_btn_set_state(btn4, LV_BTN_STATE_TGL_REL);
1544
1545
nyx_generic_onoff_toggle(btn2);
1546
nyx_generic_onoff_toggle(btn3);
1547
nyx_generic_onoff_toggle(btn4);
1548
_autoboot_hide_delay_action(btn);
1549
1550
lv_obj_set_top(l_cont, true); // Set the ddlist container at top.
1551
lv_obj_set_parent(ddlist, l_cont); // Reorder ddlist.
1552
lv_obj_set_top(ddlist, true);
1553
}
1554
1555