Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 7 additions & 24 deletions ext_components/cp0_lvgl/src/cp0/cp0_lvgl_keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,6 @@ __attribute__((weak)) void ui_global_hint_on_key(const struct key_item *elm)
(void)elm;
}

/* Optional idle screen-blanking ("DarkTime") hook, provided by the launcher.
* Returns 1 if the key was swallowed only to wake the screen and must not be
* delivered to the UI. Weak no-op for apps that don't implement it. */
__attribute__((weak)) int ui_darkscreen_filter_key(const struct key_item *elm)
{
(void)elm;
return 0;
}

static const char *getenv_default(const char *name, const char *dflt)
{
const char *value = getenv(name);
Expand Down Expand Up @@ -185,23 +176,15 @@ static void cp0_keypad_read_cb(lv_indev_t *indev, lv_indev_data_t *data)
elm->key_code, kbd_state_name(elm->key_state), elm->sym_name,
utf8_dbg, elm->codepoint, (void *)lv_screen_active());

/* DarkTime: if the screen is blanked this key only wakes it and must
* not reach the UI (nor the keypad indev) so it doesn't also act. */
int swallowed = ui_darkscreen_filter_key(elm);

if (!swallowed) {
lv_obj_t *root = lv_screen_active();
if (root)
lv_obj_send_event(root, (lv_event_code_t)LV_EVENT_KEYBOARD, elm);
lv_obj_t *root = lv_screen_active();
if (root)
lv_obj_send_event(root, (lv_event_code_t)LV_EVENT_KEYBOARD, elm);

ui_global_hint_on_key(elm);
ui_global_hint_on_key(elm);

data->key = cp0_evdev_process_key(elm->key_code);
if (data->key) {
data->state = (lv_indev_state_t)elm->key_state;
data->continue_reading = !STAILQ_EMPTY(&keyboard_queue);
}
} else {
data->key = cp0_evdev_process_key(elm->key_code);
if (data->key) {
data->state = (lv_indev_state_t)elm->key_state;
data->continue_reading = !STAILQ_EMPTY(&keyboard_queue);
}
free(elm);
Expand Down
12 changes: 10 additions & 2 deletions ext_components/cp0_lvgl/src/cp0/cp0_lvgl_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,16 @@ class WifiSystem
if (state_connected || has_connection) {
st.connected = 1;
wifi_iface = device;
if (has_connection)
cp0_copy_string(st.ssid, sizeof(st.ssid), connection);
if (has_connection) {
// Imager/netplan-provisioned networks are named
// "netplan-<iface>-<SSID>". Strip that prefix so the UI
// shows the plain SSID instead of the profile name (#66).
std::string display = connection;
const std::string prefix = "netplan-" + device + "-";
if (display.rfind(prefix, 0) == 0)
display = display.substr(prefix.size());
cp0_copy_string(st.ssid, sizeof(st.ssid), display.c_str());
}
}
}
}
Expand Down
26 changes: 7 additions & 19 deletions ext_components/cp0_lvgl/src/sdl/sdl_lvgl_keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ typedef struct {
static void cp0_sdl_keyboard_read(lv_indev_t *indev, lv_indev_data_t *data);
static void cp0_sdl_keyboard_delete_cb(lv_event_t *event);

__attribute__((weak)) int ui_darkscreen_filter_key(const struct key_item *elm)
{
(void)elm;
return 0;
}

__attribute__((weak)) void ui_global_hint_on_key(const struct key_item *elm)
{
(void)elm;
Expand Down Expand Up @@ -519,21 +513,15 @@ static void cp0_sdl_keyboard_read(lv_indev_t *indev, lv_indev_data_t *data)
struct key_item *elm = STAILQ_FIRST(&keyboard_queue);
STAILQ_REMOVE_HEAD(&keyboard_queue, entries);

int swallowed = ui_darkscreen_filter_key(elm);

if (!swallowed) {
lv_obj_t *root = lv_screen_active();
if (root != NULL)
lv_obj_send_event(root, (lv_event_code_t)LV_EVENT_KEYBOARD, elm);
lv_obj_t *root = lv_screen_active();
if (root != NULL)
lv_obj_send_event(root, (lv_event_code_t)LV_EVENT_KEYBOARD, elm);

ui_global_hint_on_key(elm);
ui_global_hint_on_key(elm);

data->key = cp0_evdev_process_key(elm->key_code);
if (data->key) {
data->state = (lv_indev_state_t)elm->key_state;
data->continue_reading = !STAILQ_EMPTY(&keyboard_queue);
}
} else {
data->key = cp0_evdev_process_key(elm->key_code);
if (data->key) {
data->state = (lv_indev_state_t)elm->key_state;
data->continue_reading = !STAILQ_EMPTY(&keyboard_queue);
}
free(elm);
Expand Down
7 changes: 0 additions & 7 deletions projects/APPLaunch/main/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <string>
#include <semaphore.h>
#include "ui/ui.h"
#include "ui/ui_darkscreen.h"
#include "keyboard_input.h"
#include "cp0_lvgl_app.h"
#include "cp0_lvgl_file.hpp"
Expand Down Expand Up @@ -95,12 +94,6 @@ int main(void)

/*Handle LVGL tasks*/
SLOGI("Entering main loop (FULL render mode)...");
// while(1) {
// // APPLaunch_lock();
// // ui_darkscreen_tick();
// lv_timer_handler();
// usleep(5000);
// }
while (1) {
uint32_t ms = lv_timer_handler();
if (ms == LV_NO_TIMER_READY) {
Expand Down
19 changes: 19 additions & 0 deletions projects/APPLaunch/main/ui/launch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,25 @@ void Launch::applications_load()
continue;
}

// Never let a third-party *.desktop shadow a built-in app: if the Exec
// matches a built-in, the built-in registry owns visibility. Otherwise a
// built-in the user hid (removed from app_list) would silently reappear
// here as a "third-party" entry (#59).
bool shadows_builtin = false;
for (const auto &registration : kBuiltinApps)
{
if (registration.exec && app_exec == registration.exec)
{
shadows_builtin = true;
break;
}
}
if (shadows_builtin)
{
fprintf(stderr, "applications_load: skip %s (shadows built-in app)\n", filepath.c_str());
continue;
}

app_list.emplace_back(page_title, cp0_file_path(app_icon), app_exec, app_terminal, app_sysplause);
}

Expand Down
46 changes: 12 additions & 34 deletions projects/APPLaunch/main/ui/page_app/ui_app_setup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ class UISetupPage : public AppPage
m.label = "Screen";
m.sub_items = {
{"Brightness", false, false, [this]() { enter_brightness_adjust(); }},
{"DarkTime", false, false, [this]() { enter_darktime_adjust(); }},
};
menu_items_.push_back(m);
}
Expand Down Expand Up @@ -422,16 +421,6 @@ class UISetupPage : public AppPage
m.on_enter = [this]() { refresh_version_info(); };
menu_items_.push_back(m);
}
// --- Reset ---
{
MenuItem m;
m.label = "Reset";
m.sub_items = {
{"Run Setup Wizard", false, false, [this]() { enter_confirm_action("Run Setup?", [this](){ rearm_oobe_and_reboot(); }); }},
{"Factory Reset", false, false, [this]() { factory_reset(); }},
};
menu_items_.push_back(m);
}
// --- SoundCard ---
{
MenuItem m;
Expand All @@ -445,20 +434,6 @@ class UISetupPage : public AppPage
}

// ==================== Placeholder functions for new menus ====================
void enter_darktime_adjust()
{
val_title_ = "DarkTime";
val_options_ = {"Never", "10S", "30S", "60S", "300S"};
const int times[] = {0, 10, 30, 60, 300};
int saved = config_get_int("dark_time", 30); // default 30S
val_sel_idx_ = 2;
for (int i = 0; i < (int)(sizeof(times) / sizeof(times[0])); ++i) {
if (times[i] == saved) { val_sel_idx_ = i; break; }
}
view_state_ = ViewState::VALUE_SELECT;
transition_enter_level();
}

void enter_volume_adjust()
{
val_title_ = "Volume";
Expand Down Expand Up @@ -1104,6 +1079,13 @@ class UISetupPage : public AppPage

void save_app_toggle(const std::string &config_key)
{
// Locate the Launcher menu by label instead of assuming a fixed index,
// so reordering the menu list can't desync the toggle from its app.
int launcher_idx = find_menu("Launcher");
if (launcher_idx < 0)
return;
MenuItem &launcher_menu = menu_items_[launcher_idx];

std::size_t app_count = 0;
const AppDescriptor *apps = launcher_app_registry_entries(&app_count);
int visible_idx = 0;
Expand All @@ -1112,7 +1094,9 @@ class UISetupPage : public AppPage
if (!desc.configurable)
continue;
if (config_key == desc.config_key) {
bool enabled = menu_items_[0].sub_items[visible_idx].toggle_state;
if (visible_idx >= (int)launcher_menu.sub_items.size())
return;
bool enabled = launcher_menu.sub_items[visible_idx].toggle_state;
launcher_app_registry_set_enabled(desc, enabled);
config_save();
launcher_app_registry_notify_changed();
Expand Down Expand Up @@ -1976,12 +1960,6 @@ class UISetupPage : public AppPage
config_save();
} else if (val_title_ == "Volume") {
apply_volume();
} else if (val_title_ == "DarkTime") {
// Idle screen-blank timeout in seconds (0 = Never); consumed by
// ui_darkscreen_tick() in the launcher main loop (#72).
int times[] = {0, 10, 30, 60, 300};
config_set_int("dark_time", times[val_sel_idx_]);
config_save();
} else if (val_title_ == "Resolution") {
config_set_int("cam_resolution", val_sel_idx_);
config_save();
Expand Down Expand Up @@ -2442,7 +2420,7 @@ class UISetupPage : public AppPage
else if (cur_sub.is_toggle && item.label == "Bluetooth" && cur_sub.label == "Named Only")
lv_label_set_text(hint, cur_sub.toggle_state ? "ok:show all" : "ok:named");
else if (cur_sub.is_toggle)
lv_label_set_text(hint, cur_sub.toggle_state ? "ok:hide" : "ok:select");
lv_label_set_text(hint, cur_sub.toggle_state ? "ok:hide" : "ok:show");
else if (item.label == "RTC" && rtc_ntp_on_)
lv_label_set_text(hint, "ntp on");
else
Expand Down Expand Up @@ -2491,7 +2469,7 @@ class UISetupPage : public AppPage
lv_obj_set_style_border_width(bar, 0, LV_PART_MAIN);
lv_obj_clear_flag(bar, LV_OBJ_FLAG_SCROLLABLE);

// Left column: sub-items (Brightness/DarkTime) as carousel at MENU_X
// Left column: sub-items (Brightness) as carousel at MENU_X
lv_obj_t *val_left_lbl = nullptr;
for (int vi = 0; vi < ROWS_VISIBLE; ++vi) {
int si = sub_selected_idx_ - ROW_CENTER + vi;
Expand Down
Loading
Loading