mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-04-18 17:35:05 +00:00
Reintroduce LVGL-related changes (#65)
This commit is contained in:
parent
62d30e8b7b
commit
5412f929c5
@ -46,11 +46,7 @@ bool tt_sdcard_mount(const SdCard* sdcard) {
|
|||||||
.sdcard = sdcard
|
.sdcard = sdcard
|
||||||
};
|
};
|
||||||
sdcard_unlock();
|
sdcard_unlock();
|
||||||
if (data.context != NULL) {
|
return (data.context != NULL);
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
TT_LOG_E(TAG, "Failed to lock");
|
TT_LOG_E(TAG, "Failed to lock");
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -39,9 +39,10 @@ static void update_pin_widgets(Gpio* gpio) {
|
|||||||
for (int j = 0; j < GPIO_NUM_MAX; ++j) {
|
for (int j = 0; j < GPIO_NUM_MAX; ++j) {
|
||||||
int level = gpio->pin_states[j];
|
int level = gpio->pin_states[j];
|
||||||
lv_obj_t* label = gpio->lv_pins[j];
|
lv_obj_t* label = gpio->lv_pins[j];
|
||||||
// user_data stores the state, so we can avoid unnecessary updates
|
void* label_user_data = lv_obj_get_user_data(label);
|
||||||
if ((void*)level != label->user_data) {
|
// The user data stores the state, so we can avoid unnecessary updates
|
||||||
label->user_data = (void*)level;
|
if ((void*)level != label_user_data) {
|
||||||
|
lv_obj_set_user_data(label, (void*)level);
|
||||||
if (level == 0) {
|
if (level == 0) {
|
||||||
lv_obj_set_style_text_color(label, lv_color_black(), 0);
|
lv_obj_set_style_text_color(label, lv_color_black(), 0);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -25,12 +25,12 @@ static void update_mode(ScreenshotUi* ui) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void on_mode_set(lv_event_t* event) {
|
static void on_mode_set(lv_event_t* event) {
|
||||||
ScreenshotUi* ui = (ScreenshotUi*)event->user_data;
|
ScreenshotUi* ui = (ScreenshotUi*)lv_event_get_user_data(event);
|
||||||
update_mode(ui);
|
update_mode(ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_start_pressed(lv_event_t* event) {
|
static void on_start_pressed(lv_event_t* event) {
|
||||||
ScreenshotUi* ui = event->user_data;
|
ScreenshotUi* ui = lv_event_get_user_data(event);
|
||||||
|
|
||||||
if (tt_screenshot_is_started()) {
|
if (tt_screenshot_is_started()) {
|
||||||
TT_LOG_I(TAG, "Stop screenshot");
|
TT_LOG_I(TAG, "Stop screenshot");
|
||||||
|
|||||||
@ -47,7 +47,7 @@ static bool is_image_file(const char* filename) {
|
|||||||
static void update_views(FilesData* data);
|
static void update_views(FilesData* data);
|
||||||
|
|
||||||
static void on_navigate_up_pressed(lv_event_t* event) {
|
static void on_navigate_up_pressed(lv_event_t* event) {
|
||||||
FilesData* files_data = (FilesData*)event->user_data;
|
FilesData* files_data = (FilesData*)lv_event_get_user_data(event);
|
||||||
if (strcmp(files_data->current_path, "/") != 0) {
|
if (strcmp(files_data->current_path, "/") != 0) {
|
||||||
TT_LOG_I(TAG, "Navigating upwards");
|
TT_LOG_I(TAG, "Navigating upwards");
|
||||||
char new_absolute_path[MAX_PATH_LENGTH];
|
char new_absolute_path[MAX_PATH_LENGTH];
|
||||||
@ -62,13 +62,13 @@ static void on_exit_app_pressed(TT_UNUSED lv_event_t* event) {
|
|||||||
loader_stop_app();
|
loader_stop_app();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_file_pressed(lv_event_t* e) {
|
static void on_file_pressed(lv_event_t* event) {
|
||||||
lv_event_code_t code = lv_event_get_code(e);
|
lv_event_code_t code = lv_event_get_code(event);
|
||||||
if (code == LV_EVENT_CLICKED) {
|
if (code == LV_EVENT_CLICKED) {
|
||||||
lv_obj_t* button = e->current_target;
|
lv_obj_t* button = lv_event_get_current_target_obj(event);
|
||||||
FilesData* files_data = lv_obj_get_user_data(button);
|
FilesData* files_data = lv_obj_get_user_data(button);
|
||||||
|
|
||||||
struct dirent* dir_entry = e->user_data;
|
struct dirent* dir_entry = lv_event_get_user_data(event);
|
||||||
TT_LOG_I(TAG, "Pressed %s %d", dir_entry->d_name, dir_entry->d_type);
|
TT_LOG_I(TAG, "Pressed %s %d", dir_entry->d_name, dir_entry->d_type);
|
||||||
|
|
||||||
switch (dir_entry->d_type) {
|
switch (dir_entry->d_type) {
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
#define TAG "wifi_connect"
|
#define TAG "wifi_connect"
|
||||||
|
|
||||||
static void on_connect(lv_event_t* event) {
|
static void on_connect(lv_event_t* event) {
|
||||||
WifiConnect* wifi = (WifiConnect*)event->user_data;
|
WifiConnect* wifi = (WifiConnect*)lv_event_get_user_data(event);
|
||||||
WifiConnectView* view = &wifi->view;
|
WifiConnectView* view = &wifi->view;
|
||||||
const char* ssid = lv_textarea_get_text(view->ssid_textarea);
|
const char* ssid = lv_textarea_get_text(view->ssid_textarea);
|
||||||
const char* password = lv_textarea_get_text(view->password_textarea);
|
const char* password = lv_textarea_get_text(view->password_textarea);
|
||||||
|
|||||||
@ -15,27 +15,27 @@ static void on_enable_switch_changed(lv_event_t* event) {
|
|||||||
lv_obj_t* enable_switch = lv_event_get_target(event);
|
lv_obj_t* enable_switch = lv_event_get_target(event);
|
||||||
if (code == LV_EVENT_VALUE_CHANGED) {
|
if (code == LV_EVENT_VALUE_CHANGED) {
|
||||||
bool is_on = lv_obj_has_state(enable_switch, LV_STATE_CHECKED);
|
bool is_on = lv_obj_has_state(enable_switch, LV_STATE_CHECKED);
|
||||||
WifiManageBindings* bindings = (WifiManageBindings*)event->user_data;
|
WifiManageBindings* bindings = (WifiManageBindings*)lv_event_get_user_data(event);
|
||||||
bindings->on_wifi_toggled(is_on);
|
bindings->on_wifi_toggled(is_on);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_disconnect_pressed(lv_event_t* event) {
|
static void on_disconnect_pressed(lv_event_t* event) {
|
||||||
WifiManageBindings* bindings = (WifiManageBindings*)event->user_data;
|
WifiManageBindings* bindings = (WifiManageBindings*)lv_event_get_user_data(event);
|
||||||
bindings->on_disconnect();
|
bindings->on_disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
// region Secondary updates
|
// region Secondary updates
|
||||||
|
|
||||||
static void connect(lv_event_t* event) {
|
static void connect(lv_event_t* event) {
|
||||||
lv_obj_t* button = event->current_target;
|
lv_obj_t* button = lv_event_get_current_target_obj(event);
|
||||||
// Assumes that the second child of the button is a label ... risky
|
// Assumes that the second child of the button is a label ... risky
|
||||||
lv_obj_t* label = lv_obj_get_child(button, 1);
|
lv_obj_t* label = lv_obj_get_child(button, 1);
|
||||||
// We get the SSID from the button label because it's safer than alloc'ing
|
// We get the SSID from the button label because it's safer than alloc'ing
|
||||||
// our own and passing it as the event data
|
// our own and passing it as the event data
|
||||||
const char* ssid = lv_label_get_text(label);
|
const char* ssid = lv_label_get_text(label);
|
||||||
TT_LOG_I(TAG, "Clicked AP: %s", ssid);
|
TT_LOG_I(TAG, "Clicked AP: %s", ssid);
|
||||||
WifiManageBindings* bindings = (WifiManageBindings*)event->user_data;
|
WifiManageBindings* bindings = (WifiManageBindings*)lv_event_get_user_data(event);
|
||||||
bindings->on_connect_ssid(ssid);
|
bindings->on_connect_ssid(ssid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ void gui_loader_callback(const void* message, void* context) {
|
|||||||
LoaderEvent* event = (LoaderEvent*)message;
|
LoaderEvent* event = (LoaderEvent*)message;
|
||||||
if (event->type == LoaderEventTypeApplicationShowing) {
|
if (event->type == LoaderEventTypeApplicationShowing) {
|
||||||
App* app = event->app_showing.app;
|
App* app = event->app_showing.app;
|
||||||
AppManifest* app_manifest = tt_app_get_manifest(app);
|
const AppManifest* app_manifest = tt_app_get_manifest(app);
|
||||||
gui_show_app(app, app_manifest->on_show, app_manifest->on_hide);
|
gui_show_app(app, app_manifest->on_show, app_manifest->on_hide);
|
||||||
} else if (event->type == LoaderEventTypeApplicationHiding) {
|
} else if (event->type == LoaderEventTypeApplicationHiding) {
|
||||||
gui_hide_app();
|
gui_hide_app();
|
||||||
|
|||||||
@ -7,8 +7,9 @@
|
|||||||
extern Gui* gui;
|
extern Gui* gui;
|
||||||
|
|
||||||
static void show_keyboard(lv_event_t* event) {
|
static void show_keyboard(lv_event_t* event) {
|
||||||
gui_keyboard_show(event->current_target);
|
lv_obj_t* target = lv_event_get_current_target_obj(event);
|
||||||
lv_obj_scroll_to_view(event->current_target, LV_ANIM_ON);
|
gui_keyboard_show(target);
|
||||||
|
lv_obj_scroll_to_view(target, LV_ANIM_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hide_keyboard(TT_UNUSED lv_event_t* event) {
|
static void hide_keyboard(TT_UNUSED lv_event_t* event) {
|
||||||
|
|||||||
@ -262,7 +262,7 @@ static void loader_do_stop_app() {
|
|||||||
|
|
||||||
// Stop current app
|
// Stop current app
|
||||||
App app_to_stop = loader_singleton->app_stack[current_app_index];
|
App app_to_stop = loader_singleton->app_stack[current_app_index];
|
||||||
AppManifest* manifest = tt_app_get_manifest(app_to_stop);
|
const AppManifest* manifest = tt_app_get_manifest(app_to_stop);
|
||||||
app_transition_to_state(app_to_stop, AppStateHiding);
|
app_transition_to_state(app_to_stop, AppStateHiding);
|
||||||
app_transition_to_state(app_to_stop, AppStateStopped);
|
app_transition_to_state(app_to_stop, AppStateStopped);
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,7 @@ typedef struct {
|
|||||||
} LoaderEventAppHiding;
|
} LoaderEventAppHiding;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
AppManifest* manifest;
|
const AppManifest* manifest;
|
||||||
} LoaderEventAppStopped;
|
} LoaderEventAppStopped;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration
|
||||||
#include "statusbar.h"
|
#include "statusbar.h"
|
||||||
|
|
||||||
#include "mutex.h"
|
#include "mutex.h"
|
||||||
|
|||||||
@ -1,10 +1,19 @@
|
|||||||
|
#define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration
|
||||||
#include "toolbar.h"
|
#include "toolbar.h"
|
||||||
|
|
||||||
#include "services/loader/loader.h"
|
#include "services/loader/loader.h"
|
||||||
#include "ui/spacer.h"
|
#include "ui/spacer.h"
|
||||||
#include "ui/style.h"
|
#include "ui/style.h"
|
||||||
|
|
||||||
#include "lvgl.h"
|
typedef struct {
|
||||||
|
lv_obj_t obj;
|
||||||
|
lv_obj_t* title_label;
|
||||||
|
lv_obj_t* close_button;
|
||||||
|
lv_obj_t* close_button_image;
|
||||||
|
lv_obj_t* action_container;
|
||||||
|
ToolbarAction* action_array[TOOLBAR_ACTION_LIMIT];
|
||||||
|
uint8_t action_count;
|
||||||
|
} Toolbar;
|
||||||
|
|
||||||
static void toolbar_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj);
|
static void toolbar_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj);
|
||||||
|
|
||||||
|
|||||||
@ -20,16 +20,6 @@ typedef struct {
|
|||||||
void* _Nullable callback_context;
|
void* _Nullable callback_context;
|
||||||
} ToolbarAction;
|
} ToolbarAction;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
lv_obj_t obj;
|
|
||||||
lv_obj_t* title_label;
|
|
||||||
lv_obj_t* close_button;
|
|
||||||
lv_obj_t* close_button_image;
|
|
||||||
lv_obj_t* action_container;
|
|
||||||
ToolbarAction* action_array[TOOLBAR_ACTION_LIMIT];
|
|
||||||
uint8_t action_count;
|
|
||||||
} Toolbar;
|
|
||||||
|
|
||||||
lv_obj_t* tt_toolbar_create(lv_obj_t* parent, const char* title);
|
lv_obj_t* tt_toolbar_create(lv_obj_t* parent, const char* title);
|
||||||
lv_obj_t* tt_toolbar_create_for_app(lv_obj_t* parent, App app);
|
lv_obj_t* tt_toolbar_create_for_app(lv_obj_t* parent, App app);
|
||||||
void tt_toolbar_set_title(lv_obj_t* obj, const char* title);
|
void tt_toolbar_set_title(lv_obj_t* obj, const char* title);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user