theme runtime config

This commit is contained in:
mverch67
2024-09-01 11:10:32 +02:00
parent c297993b7c
commit 14b9bb76b9
7 changed files with 1521 additions and 631 deletions
File diff suppressed because it is too large Load Diff
+8
View File
@@ -98,6 +98,8 @@ typedef struct _objects_t {
lv_obj_t *basic_settings_role_label;
lv_obj_t *basic_settings_screen_lock_button;
lv_obj_t *basic_settings_screen_lock_label;
lv_obj_t *basic_settings_theme_button;
lv_obj_t *basic_settings_theme_label;
lv_obj_t *basic_settings_timeout_button;
lv_obj_t *basic_settings_timeout_label;
lv_obj_t *basic_settings_timezone_button;
@@ -243,6 +245,10 @@ typedef struct _objects_t {
lv_obj_t *obj13__cancel_button_w;
lv_obj_t *obj13__ok_button_w;
lv_obj_t *obj13__ok_cancel_panel_w;
lv_obj_t *obj14;
lv_obj_t *obj14__cancel_button_w;
lv_obj_t *obj14__ok_button_w;
lv_obj_t *obj14__ok_cancel_panel_w;
lv_obj_t *obj2;
lv_obj_t *obj2__cancel_button_w;
lv_obj_t *obj2__ok_button_w;
@@ -328,6 +334,8 @@ typedef struct _objects_t {
lv_obj_t *settings_screen_lock_switch;
lv_obj_t *settings_screen_timeout_label;
lv_obj_t *settings_screen_timeout_panel;
lv_obj_t *settings_theme_dropdown;
lv_obj_t *settings_theme_panel;
lv_obj_t *settings_timezone;
lv_obj_t *settings_tzcity;
lv_obj_t *settings_tzzone;
File diff suppressed because it is too large Load Diff
+117 -23
View File
@@ -12,29 +12,123 @@ extern lv_style_t style_btn_pressed;
extern "C" {
#endif
extern void apply_style_top_panel_style(lv_obj_t *obj);
extern void apply_style_panel_style(lv_obj_t *obj);
extern void apply_style_settings_panel_style(lv_obj_t *obj);
extern void apply_style_node_panel_style(lv_obj_t *obj);
extern void apply_style_home_button_style(lv_obj_t *obj);
extern void apply_style_settings_button_style(lv_obj_t *obj);
extern void apply_style_main_button_style(lv_obj_t *obj);
extern void apply_style_new_message_style(lv_obj_t *obj);
extern void apply_style_chat_message_style(lv_obj_t *obj);
extern void apply_style_tab_view_style(lv_obj_t *obj);
extern void apply_style_drop_down_style(lv_obj_t *obj);
extern void apply_style_bw_label_style(lv_obj_t *obj);
extern void apply_style_color_label_style(lv_obj_t *obj);
extern void apply_style_top_image_style(lv_obj_t *obj);
extern void apply_style_home_container_style(lv_obj_t *obj);
extern void apply_style_button_panel_style(lv_obj_t *obj);
extern void apply_style_alert_panel_style(lv_obj_t *obj);
extern void apply_style_main_screen_style(lv_obj_t *obj);
extern void apply_style_node_button_style(lv_obj_t *obj);
extern void apply_style_channel_button_style(lv_obj_t *obj);
extern void apply_style_button_matrix_style(lv_obj_t *obj);
extern void apply_style_spinner_style(lv_obj_t *obj);
extern void apply_style_settings_label_style(lv_obj_t *obj);
// Style: TopPanelStyle
lv_style_t *get_style_top_panel_style_MAIN_DEFAULT();
void add_style_top_panel_style(lv_obj_t *obj);
void remove_style_top_panel_style(lv_obj_t *obj);
// Style: PanelStyle
lv_style_t *get_style_panel_style_MAIN_DEFAULT();
lv_style_t *get_style_panel_style_MAIN_PRESSED();
void add_style_panel_style(lv_obj_t *obj);
void remove_style_panel_style(lv_obj_t *obj);
// Style: SettingsPanelStyle
lv_style_t *get_style_settings_panel_style_MAIN_DEFAULT();
void add_style_settings_panel_style(lv_obj_t *obj);
void remove_style_settings_panel_style(lv_obj_t *obj);
// Style: NodePanelStyle
lv_style_t *get_style_node_panel_style_MAIN_DEFAULT();
void add_style_node_panel_style(lv_obj_t *obj);
void remove_style_node_panel_style(lv_obj_t *obj);
// Style: HomeButtonStyle
lv_style_t *get_style_home_button_style_MAIN_DEFAULT();
void add_style_home_button_style(lv_obj_t *obj);
void remove_style_home_button_style(lv_obj_t *obj);
// Style: SettingsButtonStyle
lv_style_t *get_style_settings_button_style_MAIN_DEFAULT();
void add_style_settings_button_style(lv_obj_t *obj);
void remove_style_settings_button_style(lv_obj_t *obj);
// Style: MainButtonStyle
lv_style_t *get_style_main_button_style_MAIN_DEFAULT();
void add_style_main_button_style(lv_obj_t *obj);
void remove_style_main_button_style(lv_obj_t *obj);
// Style: NewMessageStyle
lv_style_t *get_style_new_message_style_MAIN_DEFAULT();
void add_style_new_message_style(lv_obj_t *obj);
void remove_style_new_message_style(lv_obj_t *obj);
// Style: ChatMessageStyle
lv_style_t *get_style_chat_message_style_MAIN_DEFAULT();
void add_style_chat_message_style(lv_obj_t *obj);
void remove_style_chat_message_style(lv_obj_t *obj);
// Style: TabViewStyle
lv_style_t *get_style_tab_view_style_MAIN_DEFAULT();
void add_style_tab_view_style(lv_obj_t *obj);
void remove_style_tab_view_style(lv_obj_t *obj);
// Style: DropDownStyle
void add_style_drop_down_style(lv_obj_t *obj);
void remove_style_drop_down_style(lv_obj_t *obj);
// Style: BWLabelStyle
lv_style_t *get_style_bw_label_style_MAIN_DEFAULT();
void add_style_bw_label_style(lv_obj_t *obj);
void remove_style_bw_label_style(lv_obj_t *obj);
// Style: ColorLabelStyle
lv_style_t *get_style_color_label_style_MAIN_DEFAULT();
void add_style_color_label_style(lv_obj_t *obj);
void remove_style_color_label_style(lv_obj_t *obj);
// Style: TopImageStyle
lv_style_t *get_style_top_image_style_MAIN_DEFAULT();
void add_style_top_image_style(lv_obj_t *obj);
void remove_style_top_image_style(lv_obj_t *obj);
// Style: HomeContainerStyle
lv_style_t *get_style_home_container_style_MAIN_DEFAULT();
void add_style_home_container_style(lv_obj_t *obj);
void remove_style_home_container_style(lv_obj_t *obj);
// Style: ButtonPanelStyle
lv_style_t *get_style_button_panel_style_MAIN_DEFAULT();
void add_style_button_panel_style(lv_obj_t *obj);
void remove_style_button_panel_style(lv_obj_t *obj);
// Style: AlertPanelStyle
lv_style_t *get_style_alert_panel_style_MAIN_DEFAULT();
void add_style_alert_panel_style(lv_obj_t *obj);
void remove_style_alert_panel_style(lv_obj_t *obj);
// Style: MainScreenStyle
lv_style_t *get_style_main_screen_style_MAIN_DEFAULT();
void add_style_main_screen_style(lv_obj_t *obj);
void remove_style_main_screen_style(lv_obj_t *obj);
// Style: NodeButtonStyle
lv_style_t *get_style_node_button_style_MAIN_DEFAULT();
void add_style_node_button_style(lv_obj_t *obj);
void remove_style_node_button_style(lv_obj_t *obj);
// Style: ChannelButtonStyle
lv_style_t *get_style_channel_button_style_MAIN_DEFAULT();
void add_style_channel_button_style(lv_obj_t *obj);
void remove_style_channel_button_style(lv_obj_t *obj);
// Style: ButtonMatrixStyle
lv_style_t *get_style_button_matrix_style_ITEMS_DEFAULT();
lv_style_t *get_style_button_matrix_style_MAIN_DEFAULT();
void add_style_button_matrix_style(lv_obj_t *obj);
void remove_style_button_matrix_style(lv_obj_t *obj);
// Style: SpinnerStyle
lv_style_t *get_style_spinner_style_MAIN_DEFAULT();
lv_style_t *get_style_spinner_style_INDICATOR_DEFAULT();
void add_style_spinner_style(lv_obj_t *obj);
void remove_style_spinner_style(lv_obj_t *obj);
// Style: SettingsLabelStyle
lv_style_t *get_style_settings_label_style_MAIN_DEFAULT();
void add_style_settings_label_style(lv_obj_t *obj);
void remove_style_settings_label_style(lv_obj_t *obj);
#ifdef __cplusplus
+5 -2
View File
@@ -88,6 +88,7 @@ class TFTView_320x240 : public MeshtasticView
eScreenTimeout,
eScreenLock,
eScreenBrightness,
eTheme,
eInputControl,
eAlertBuzzer,
eReset,
@@ -177,6 +178,7 @@ class TFTView_320x240 : public MeshtasticView
TFTView_320x240(const DisplayDriverConfig *cfg, DisplayDriver *driver);
void apply_hotfix(void);
void updateTheme(void);
void ui_events_init(void);
void ui_set_active(lv_obj_t *b, lv_obj_t *p, lv_obj_t *tp);
void showKeyboard(lv_obj_t *textArea);
@@ -214,7 +216,7 @@ class TFTView_320x240 : public MeshtasticView
static void ui_event_WLANButton(lv_event_t *e);
static void ui_event_MQTTButton(lv_event_t *e);
static void ui_event_MemoryButton(lv_event_t *e);
static void ui_event_KeyboardButton(lv_event_t *e);
static void ui_event_Keyboard(lv_event_t *e);
@@ -227,6 +229,7 @@ class TFTView_320x240 : public MeshtasticView
static void ui_event_language_button(lv_event_t *e);
static void ui_event_channel_button(lv_event_t *e);
static void ui_event_brightness_button(lv_event_t *e);
static void ui_event_theme_button(lv_event_t *e);
static void ui_event_calibration_button(lv_event_t *e);
static void ui_event_timeout_button(lv_event_t *e);
static void ui_event_screen_lock_button(lv_event_t *e);
@@ -267,7 +270,7 @@ class TFTView_320x240 : public MeshtasticView
// animations
static void ui_anim_node_panel_cb(void *var, int32_t v);
static void ui_anim_radar_cb(void * var, int32_t r);
static void ui_anim_radar_cb(void *var, int32_t r);
lv_obj_t *activeButton = nullptr;
lv_obj_t *activePanel = nullptr;
+103 -54
View File
@@ -9,11 +9,11 @@
#include "InputDriver.h"
#include "LoRaPresets.h"
#include "Ringtones.h"
#include "ViewController.h"
#include "Themes.h"
#include "ViewController.h"
#include "images.h"
#include "styles.h"
#include "lv_i18n.h"
#include "styles.h"
#include "ui.h" // this is the ui generated by eez-studio
#include <algorithm>
#include <cmath>
@@ -162,6 +162,8 @@ void TFTView_320x240::init(IClientBase *client)
// TODO: set dark/light mode
// lv_theme_t * theme = lv_theme_default_init(lv_display_get_default(), lv_color_hex(0xff0000), lv_color_hex(0x00ff00), true,
// LV_FONT_DEFAULT); lv_display_set_theme(lv_disp_get_default(), theme);
Themes::set(Themes::eDark);
lv_label_set_text(objects.basic_settings_theme_label, Themes::get() ? "Theme: Dark" : "Theme: Light");
// user data
objects.home_time_button->user_data = (void *)0;
@@ -234,7 +236,8 @@ void TFTView_320x240::apply_hotfix(void)
{
lv_obj_move_foreground(objects.keyboard);
Themes::initStyles();
updateTheme();
auto applyStyle = [](lv_obj_t *tab_buttons) {
for (int i = 0; i < tab_buttons->spec_attr->child_cnt; i++) {
if (tab_buttons->spec_attr->children[i]->class_p == &lv_button_class) {
@@ -252,21 +255,35 @@ void TFTView_320x240::apply_hotfix(void)
tab_buttons = lv_tabview_get_tab_bar(ui_SettingsTabView);
applyStyle(tab_buttons);
Themes::recolorButton(objects.home_location_button, false);
Themes::recolorButton(objects.home_wlan_button, false);
Themes::recolorButton(objects.home_memory_button, false);
Themes::recolorButton(objects.home_mqtt_button, false);
Themes::recolorText(objects.home_location_label, false);
Themes::recolorText(objects.home_wlan_label, false);
Themes::recolorText(objects.home_mqtt_label, false);
Themes::recolorText(objects.home_memory_label, false);
lv_obj_add_flag(objects.detector_radar_panel, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(objects.detected_node_button, LV_OBJ_FLAG_HIDDEN);
lv_label_set_text(objects.detector_start_label, "Start");
lv_obj_clear_flag(objects.detector_start_button_panel, LV_OBJ_FLAG_HIDDEN);
}
void TFTView_320x240::updateTheme(void)
{
Themes::initStyles();
Themes::recolorButton(objects.home_location_button,
db.config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED);
Themes::recolorButton(objects.home_wlan_button, db.config.network.wifi_enabled);
Themes::recolorButton(objects.home_mqtt_button, db.module_config.mqtt.enabled);
Themes::recolorButton(objects.home_memory_button, (bool)objects.home_memory_button->user_data);
Themes::recolorText(objects.home_location_label,
db.config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED);
Themes::recolorText(objects.home_wlan_label, db.config.network.wifi_enabled);
Themes::recolorText(objects.home_mqtt_label, db.module_config.mqtt.enabled);
Themes::recolorText(objects.home_memory_label, (bool)objects.home_memory_button->user_data);
lv_opa_t opa = (Themes::get() == Themes::eDark) ? 0 : 255;
lv_obj_set_style_bg_img_recolor_opa(objects.home_button, opa, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_img_recolor_opa(objects.nodes_button, opa, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_img_recolor_opa(objects.groups_button, opa, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_img_recolor_opa(objects.messages_button, opa, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_img_recolor_opa(objects.map_button, opa, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_img_recolor_opa(objects.settings_button, opa, LV_PART_MAIN | LV_STATE_DEFAULT);
}
void TFTView_320x240::ui_events_init(void)
{
// just a test to implement callback via non-static lambda function
@@ -331,20 +348,21 @@ void TFTView_320x240::ui_events_init(void)
lv_obj_add_event_cb(objects.message_input_area, ui_event_message_ready, LV_EVENT_ALL, NULL);
// basic settings buttons
lv_obj_add_event_cb(objects.basic_settings_user_button, ui_event_user_button, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(objects.basic_settings_role_button, ui_event_role_button, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(objects.basic_settings_region_button, ui_event_region_button, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(objects.basic_settings_modem_preset_button, ui_event_preset_button, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(objects.basic_settings_language_button, ui_event_language_button, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(objects.basic_settings_channel_button, ui_event_channel_button, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(objects.basic_settings_timeout_button, ui_event_timeout_button, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(objects.basic_settings_screen_lock_button, ui_event_screen_lock_button, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(objects.basic_settings_brightness_button, ui_event_brightness_button, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(objects.basic_settings_calibration_button, ui_event_calibration_button, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(objects.basic_settings_input_button, ui_event_input_button, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(objects.basic_settings_alert_button, ui_event_alert_button, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(objects.basic_settings_reset_button, ui_event_reset_button, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(objects.basic_settings_reboot_button, ui_event_reboot_button, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(objects.basic_settings_user_button, ui_event_user_button, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(objects.basic_settings_role_button, ui_event_role_button, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(objects.basic_settings_region_button, ui_event_region_button, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(objects.basic_settings_modem_preset_button, ui_event_preset_button, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(objects.basic_settings_language_button, ui_event_language_button, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(objects.basic_settings_channel_button, ui_event_channel_button, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(objects.basic_settings_timeout_button, ui_event_timeout_button, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(objects.basic_settings_screen_lock_button, ui_event_screen_lock_button, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(objects.basic_settings_brightness_button, ui_event_brightness_button, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(objects.basic_settings_theme_button, ui_event_theme_button, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(objects.basic_settings_calibration_button, ui_event_calibration_button, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(objects.basic_settings_input_button, ui_event_input_button, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(objects.basic_settings_alert_button, ui_event_alert_button, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(objects.basic_settings_reset_button, ui_event_reset_button, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(objects.basic_settings_reboot_button, ui_event_reboot_button, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(objects.reboot_button, ui_event_device_reboot_button, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(objects.shutdown_button, ui_event_device_shutdown_button, LV_EVENT_CLICKED, NULL);
@@ -387,6 +405,8 @@ void TFTView_320x240::ui_events_init(void)
lv_obj_add_event_cb(objects.obj12__cancel_button_w, ui_event_cancel, LV_EVENT_CLICKED, 0);
lv_obj_add_event_cb(objects.obj13__ok_button_w, ui_event_ok, LV_EVENT_CLICKED, 0);
lv_obj_add_event_cb(objects.obj13__cancel_button_w, ui_event_cancel, LV_EVENT_CLICKED, 0);
lv_obj_add_event_cb(objects.obj14__ok_button_w, ui_event_ok, LV_EVENT_CLICKED, 0);
lv_obj_add_event_cb(objects.obj14__cancel_button_w, ui_event_cancel, LV_EVENT_CLICKED, 0);
// modify channel buttons
lv_obj_add_event_cb(objects.settings_channel0_button, ui_event_modify_channel, LV_EVENT_ALL, (void *)0);
@@ -409,7 +429,7 @@ void TFTView_320x240::ui_events_init(void)
lv_obj_add_event_cb(objects.tools_signal_scanner_button, ui_event_signal_scanner, LV_EVENT_CLICKED, 0);
lv_obj_add_event_cb(objects.tools_trace_route_button, ui_event_trace_route, LV_EVENT_CLICKED, 0);
lv_obj_add_event_cb(objects.tools_neighbors_button, ui_event_neighbors, LV_EVENT_CLICKED, 0);
//lv_obj_add_event_cb(objects.tools_statistics_button, ui_event_statistics, LV_EVENT_CLICKED, 0);
// lv_obj_add_event_cb(objects.tools_statistics_button, ui_event_statistics, LV_EVENT_CLICKED, 0);
lv_obj_add_event_cb(objects.tools_debug_log_button, ui_event_debug_log, LV_EVENT_CLICKED, 0);
// tools
lv_obj_add_event_cb(objects.detector_start_button, ui_event_mesh_detector_start, LV_EVENT_CLICKED, 0);
@@ -491,8 +511,7 @@ void TFTView_320x240::ui_event_NodeButton(lv_event_t *e)
if (THIS->chooseNodeSignalScanner) {
THIS->chooseNodeSignalScanner = false;
ui_event_signal_scanner(NULL);
}
else if (THIS->chooseNodeTraceRoute) {
} else if (THIS->chooseNodeTraceRoute) {
THIS->chooseNodeTraceRoute = false;
ui_event_trace_route(NULL);
}
@@ -685,8 +704,7 @@ void TFTView_320x240::ui_event_LocationButton(lv_event_t *e)
// uint32_t toggle = (unsigned long)objects.home_location_button->user_data;
// objects.home_location_button->user_data = (void *)(1 - toggle);
// Themes::recolorButton(objects.home_location_button, toggle);
}
else if (event_code == LV_EVENT_LONG_PRESSED && THIS->configComplete) {
} else if (event_code == LV_EVENT_LONG_PRESSED && THIS->configComplete) {
// toggle GPS not_present <-> enabled
uint32_t toggle = (unsigned long)objects.home_location_button->user_data;
objects.home_location_button->user_data = (void *)(1 - toggle);
@@ -697,7 +715,8 @@ void TFTView_320x240::ui_event_LocationButton(lv_event_t *e)
else {
position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT;
}
Themes::recolorButton(objects.home_location_button, position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED);
Themes::recolorButton(objects.home_location_button,
position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED);
THIS->controller->sendConfig(meshtastic_Config_PositionConfig{position});
THIS->notifyReboot(true);
}
@@ -972,6 +991,18 @@ void TFTView_320x240::ui_event_brightness_button(lv_event_t *e)
}
}
void TFTView_320x240::ui_event_theme_button(lv_event_t *e)
{
lv_event_code_t event_code = lv_event_get_code(e);
if (event_code == LV_EVENT_CLICKED && THIS->activeSettings == eNone) {
lv_dropdown_set_selected(objects.settings_theme_dropdown, Themes::get());
lv_obj_clear_flag(objects.settings_theme_panel, LV_OBJ_FLAG_HIDDEN);
lv_group_focus_obj(objects.settings_theme_dropdown);
THIS->disablePanel(objects.controller_panel);
THIS->activeSettings = eTheme;
}
}
void TFTView_320x240::ui_event_calibration_button(lv_event_t *e)
{
lv_event_code_t event_code = lv_event_get_code(e);
@@ -1278,14 +1309,14 @@ void TFTView_320x240::ui_event_mesh_detector(lv_event_t *e)
THIS->ui_set_active(objects.settings_button, objects.mesh_detector_panel, objects.top_mesh_detector_panel);
}
void TFTView_320x240::ui_event_mesh_detector_start(_lv_event_t* e)
void TFTView_320x240::ui_event_mesh_detector_start(_lv_event_t *e)
{
static bool running = false;
if (!running) {
lv_label_set_text(objects.detector_start_label, "Stop");
// create radar animation
lv_anim_t& a = THIS->radar;
lv_anim_t &a = THIS->radar;
lv_anim_init(&a);
lv_anim_set_var(&a, objects.radar_beam);
lv_anim_set_values(&a, 0, 3600);
@@ -1294,8 +1325,7 @@ void TFTView_320x240::ui_event_mesh_detector_start(_lv_event_t* e)
lv_anim_set_exec_cb(&a, ui_anim_radar_cb);
lv_anim_start(&a);
lv_obj_clear_flag(objects.detector_radar_panel, LV_OBJ_FLAG_HIDDEN);
}
else {
} else {
lv_label_set_text(objects.detector_start_label, "Start");
lv_anim_del(&objects.radar_beam, ui_anim_radar_cb);
lv_obj_add_flag(objects.detector_radar_panel, LV_OBJ_FLAG_HIDDEN);
@@ -1352,7 +1382,7 @@ void TFTView_320x240::ui_event_signal_scanner_start(lv_event_t *e)
lv_obj_set_pos(obj, 0, -50);
lv_obj_set_size(obj, 68, 68);
lv_obj_set_style_align(obj, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
apply_style_spinner_style(obj);
add_style_spinner_style(obj);
lv_label_set_text(objects.signal_scanner_start_label, "30s");
THIS->scans = 6 + 1;
}
@@ -1411,7 +1441,7 @@ void TFTView_320x240::ui_event_trace_route_start(lv_event_t *e)
lv_obj_set_pos(obj, 0, 0);
lv_obj_set_size(obj, 68, 68);
lv_obj_set_style_align(obj, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
apply_style_spinner_style(obj);
add_style_spinner_style(obj);
lv_label_set_text(objects.trace_route_start_label, "30s");
// retrieve nodeNum from current node
@@ -1620,6 +1650,22 @@ void TFTView_320x240::ui_event_ok(lv_event_t *e)
lv_group_focus_obj(objects.basic_settings_brightness_button);
break;
}
case eTheme: {
char buf1[10], buf2[30];
lv_dropdown_get_selected_str(objects.settings_theme_dropdown, buf1, sizeof(buf1));
lv_snprintf(buf2, sizeof(buf2), _("Theme: %s"), buf1);
lv_label_set_text(objects.basic_settings_theme_label, buf2);
// change theme and redraw UI
Themes::Theme theme = (Themes::Theme)lv_dropdown_get_selected(objects.settings_theme_dropdown);
Themes::set(theme);
THIS->updateTheme();
lv_obj_set_style_bg_img_recolor(objects.settings_button, lv_color_hex(0x67EA94), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_add_flag(objects.settings_theme_panel, LV_OBJ_FLAG_HIDDEN);
lv_group_focus_obj(objects.basic_settings_theme_button);
lv_obj_invalidate(objects.main_screen);
break;
}
case eInputControl: {
char new_val_kbd[10], new_val_ptr[10];
lv_dropdown_get_selected_str(objects.settings_keyboard_input_dropdown, new_val_kbd, sizeof(new_val_kbd));
@@ -1812,6 +1858,11 @@ void TFTView_320x240::ui_event_cancel(lv_event_t *e)
THIS->displaydriver->setBrightness((uint8_t)(old_brightness * 255 / 100));
break;
}
case TFTView_320x240::eTheme: {
lv_obj_add_flag(objects.settings_theme_panel, LV_OBJ_FLAG_HIDDEN);
lv_group_focus_obj(objects.basic_settings_theme_button);
break;
}
case TFTView_320x240::eInputControl: {
lv_obj_add_flag(objects.settings_input_control_panel, LV_OBJ_FLAG_HIDDEN);
lv_group_focus_obj(objects.basic_settings_input_button);
@@ -1905,7 +1956,7 @@ void TFTView_320x240::ui_anim_node_panel_cb(void *var, int32_t v)
lv_obj_set_height((lv_obj_t *)var, v);
}
void TFTView_320x240::ui_anim_radar_cb(void * var, int32_t r)
void TFTView_320x240::ui_anim_radar_cb(void *var, int32_t r)
{
lv_img_set_angle(objects.radar_beam, r);
}
@@ -1964,7 +2015,7 @@ void TFTView_320x240::addMessage(uint32_t requestId, char *msg)
lv_obj_set_align(hiddenPanel, LV_ALIGN_CENTER);
lv_obj_clear_flag(hiddenPanel, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_style_radius(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
apply_style_panel_style(hiddenPanel);
add_style_panel_style(hiddenPanel);
lv_obj_set_style_border_width(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
@@ -1986,7 +2037,7 @@ void TFTView_320x240::addMessage(uint32_t requestId, char *msg)
if (msg[i] == CR_REPLACEMENT)
msg[i] = '\n';
lv_label_set_text(textLabel, msg);
apply_style_chat_message_style(textLabel);
add_style_chat_message_style(textLabel);
lv_obj_scroll_to_view(hiddenPanel, LV_ANIM_ON);
}
@@ -2022,7 +2073,7 @@ void TFTView_320x240::addNode(uint32_t nodeNum, uint8_t ch, const char *userShor
lv_obj_set_align(p, LV_ALIGN_CENTER);
lv_obj_clear_flag(p, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_PRESS_LOCK | LV_OBJ_FLAG_CLICK_FOCUSABLE |
LV_OBJ_FLAG_GESTURE_BUBBLE | LV_OBJ_FLAG_SNAPPABLE | LV_OBJ_FLAG_SCROLLABLE);
apply_style_node_panel_style(p);
add_style_node_panel_style(p);
// NodeImage
lv_obj_t *img = lv_img_create(p);
@@ -2039,7 +2090,7 @@ void TFTView_320x240::addNode(uint32_t nodeNum, uint8_t ch, const char *userShor
lv_obj_t *nodeButton = lv_btn_create(p);
lv_obj_set_pos(nodeButton, 0, 0);
lv_obj_set_size(nodeButton, LV_PCT(106), LV_PCT(100));
apply_style_node_button_style(nodeButton);
add_style_node_button_style(nodeButton);
lv_obj_set_align(nodeButton, LV_ALIGN_CENTER);
lv_obj_add_flag(nodeButton, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
lv_obj_set_style_shadow_width(nodeButton, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
@@ -2510,8 +2561,7 @@ void TFTView_320x240::updateConnectionStatus(const meshtastic_DeviceConnectionSt
if (status.wifi.status.is_mqtt_connected) {
Themes::recolorButton(objects.home_mqtt_button, true, 255);
Themes::recolorText(objects.home_mqtt_label, true);
}
else {
} else {
Themes::recolorText(objects.home_mqtt_label, false);
}
lv_obj_set_style_bg_img_src(objects.home_wlan_button, &img_home_wlan_off_image, LV_PART_MAIN | LV_STATE_DEFAULT);
@@ -2715,10 +2765,10 @@ void TFTView_320x240::addNodeToTraceRoute(uint32_t nodeNum)
nodePanel = it->second;
}
lv_obj_t *btn = lv_btn_create(objects.trace_route_panel);
//objects.trace_route_to_button = btn;
// objects.trace_route_to_button = btn;
lv_obj_set_pos(btn, 0, 0);
lv_obj_set_size(btn, LV_PCT(100), 38);
apply_style_settings_button_style(btn);
add_style_settings_button_style(btn);
lv_obj_set_style_align(btn, LV_ALIGN_TOP_MID, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_radius(btn, 6, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(btn, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
@@ -3284,7 +3334,7 @@ void TFTView_320x240::newMessage(uint32_t nodeNum, lv_obj_t *container, uint8_t
lv_obj_set_align(hiddenPanel, LV_ALIGN_CENTER);
lv_obj_clear_flag(hiddenPanel, LV_OBJ_FLAG_SCROLLABLE); /// Flags
lv_obj_set_style_radius(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
apply_style_panel_style(hiddenPanel);
add_style_panel_style(hiddenPanel);
lv_obj_set_style_pad_left(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
@@ -3297,7 +3347,7 @@ void TFTView_320x240::newMessage(uint32_t nodeNum, lv_obj_t *container, uint8_t
lv_obj_set_height(msgLabel, LV_SIZE_CONTENT); /// 1
lv_obj_set_align(msgLabel, LV_ALIGN_LEFT_MID);
lv_label_set_text(msgLabel, msg);
apply_style_new_message_style(msgLabel);
add_style_new_message_style(msgLabel);
lv_obj_scroll_to_view(hiddenPanel, LV_ANIM_ON);
}
@@ -3325,7 +3375,7 @@ void TFTView_320x240::addChat(uint32_t from, uint32_t to, uint8_t ch)
lv_obj_set_size(chatBtn, LV_PCT(100), 36);
lv_obj_add_flag(chatBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
lv_obj_clear_flag(chatBtn, LV_OBJ_FLAG_SCROLLABLE);
apply_style_home_button_style(chatBtn);
add_style_home_button_style(chatBtn);
lv_obj_set_style_align(chatBtn, LV_ALIGN_TOP_MID, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_color(chatBtn, lv_color_hex(0x808080), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_width(chatBtn, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
@@ -3854,12 +3904,11 @@ void TFTView_320x240::task_handler(void)
scanSignal(scans);
scans--;
}
if (startTime) {
if (startTime) {
if (curtime - startTime > 30) {
lv_label_set_text(objects.trace_route_start_label, "Start");
removeSpinner();
}
else {
} else {
char buf[16];
sprintf(buf, "%ds", ((35 - (curtime - startTime)) / 5) * 5);
lv_label_set_text(objects.trace_route_start_label, buf);
+265 -222
View File
File diff suppressed because it is too large Load Diff