78 lines
No EOL
3.3 KiB
C++
78 lines
No EOL
3.3 KiB
C++
#include "OmoteUI.hpp"
|
|
|
|
using namespace UI::Basic;
|
|
|
|
void OmoteUI::display_settings(lv_obj_t *parent) {
|
|
|
|
lv_obj_t *menuLabel = lv_label_create(parent);
|
|
lv_label_set_text(menuLabel, "Display");
|
|
|
|
lv_obj_t *menuBox = lv_obj_create(parent);
|
|
lv_obj_set_size(menuBox, lv_pct(100), 109);
|
|
lv_obj_set_style_bg_color(menuBox, color_primary, LV_PART_MAIN);
|
|
lv_obj_set_style_border_width(menuBox, 0, LV_PART_MAIN);
|
|
|
|
lv_obj_t *brightnessIcon = imgs.addLowBrightnessIcon(menuBox);
|
|
lv_obj_align(brightnessIcon, LV_ALIGN_TOP_LEFT, 0, 0);
|
|
lv_obj_t *slider = lv_slider_create(menuBox);
|
|
lv_slider_set_range(slider, 0, 255);
|
|
lv_obj_set_style_bg_color(slider, lv_color_white(), LV_PART_KNOB);
|
|
lv_obj_set_style_bg_opa(slider, LV_OPA_COVER, LV_PART_MAIN);
|
|
lv_obj_set_style_bg_color(slider, lv_color_lighten(color_primary, 50),
|
|
LV_PART_MAIN);
|
|
lv_slider_set_value(slider, mHardware->display()->getBrightness(),
|
|
LV_ANIM_OFF);
|
|
lv_obj_set_size(slider, lv_pct(66), 10);
|
|
lv_obj_align(slider, LV_ALIGN_TOP_MID, 0, 3);
|
|
brightnessIcon = imgs.addHighBrightnessIcon(menuBox);
|
|
lv_obj_align(brightnessIcon, LV_ALIGN_TOP_RIGHT, 0, -1);
|
|
lv_obj_add_event_cb(
|
|
slider, [](lv_event_t *e) { mInstance->bl_slider_event_cb(e); },
|
|
LV_EVENT_VALUE_CHANGED, nullptr);
|
|
|
|
menuLabel = lv_label_create(menuBox);
|
|
lv_label_set_text(menuLabel, "Lift to Wake");
|
|
lv_obj_align(menuLabel, LV_ALIGN_TOP_LEFT, 0, 32);
|
|
lv_obj_t *wakeToggle = lv_switch_create(menuBox);
|
|
lv_obj_set_size(wakeToggle, 40, 22);
|
|
lv_obj_align(wakeToggle, LV_ALIGN_TOP_RIGHT, 0, 29);
|
|
lv_obj_set_style_bg_color(wakeToggle, lv_color_hex(0x505050), LV_PART_MAIN);
|
|
lv_obj_add_event_cb(
|
|
wakeToggle,
|
|
[](lv_event_t *e) { mInstance->WakeEnableSetting_event_cb(e); },
|
|
LV_EVENT_VALUE_CHANGED, NULL);
|
|
if (mHardware->getWakeupByIMUEnabled())
|
|
lv_obj_add_state(wakeToggle, LV_STATE_CHECKED); // set default state
|
|
|
|
menuLabel = lv_label_create(menuBox);
|
|
lv_label_set_text(menuLabel, "Timeout");
|
|
lv_obj_align(menuLabel, LV_ALIGN_TOP_LEFT, 0, 64);
|
|
lv_obj_t *drop = lv_dropdown_create(menuBox);
|
|
lv_dropdown_set_options(drop, "10s\n"
|
|
"30s\n"
|
|
"1m\n"
|
|
"3m");
|
|
lv_obj_align(drop, LV_ALIGN_TOP_RIGHT, 0, 61);
|
|
lv_obj_set_size(drop, 70, 22);
|
|
// lv_obj_set_style_text_font(drop, &lv_font_montserrat_12, LV_PART_MAIN);
|
|
// lv_obj_set_style_text_font(lv_dropdown_get_list(drop),
|
|
// &lv_font_montserrat_12, LV_PART_MAIN);
|
|
lv_obj_set_style_pad_top(drop, 1, LV_PART_MAIN);
|
|
lv_obj_set_style_bg_color(drop, color_primary, LV_PART_MAIN);
|
|
lv_obj_set_style_bg_color(lv_dropdown_get_list(drop), color_primary,
|
|
LV_PART_MAIN);
|
|
lv_obj_set_style_border_width(lv_dropdown_get_list(drop), 1, LV_PART_MAIN);
|
|
lv_obj_set_style_border_color(lv_dropdown_get_list(drop),
|
|
lv_color_hex(0x505050), LV_PART_MAIN);
|
|
|
|
int sleepTimeoutMapSize =
|
|
sizeof(sleepTimeoutMap) / sizeof(sleepTimeoutMap[0]);
|
|
int currentTimeout = mHardware->getSleepTimeout();
|
|
for (int i = 0; i < sleepTimeoutMapSize; i++) {
|
|
if (currentTimeout == sleepTimeoutMap[i])
|
|
lv_dropdown_set_selected(drop, i);
|
|
}
|
|
lv_obj_add_event_cb(
|
|
drop, [](lv_event_t *e) { mInstance->wakeTimeoutSetting_event_cb(e); },
|
|
LV_EVENT_VALUE_CHANGED, NULL);
|
|
} |