diff --git a/COPYRIGHT.md b/COPYRIGHT.md new file mode 100644 index 00000000..674bdf10 --- /dev/null +++ b/COPYRIGHT.md @@ -0,0 +1,13 @@ +### Flipper Zero Firmware +Website: https://github.com/flipperdevices/flipperzero-firmware/ +License: GPL v3.0 +https://github.com/flipperdevices/flipperzero-firmware/blob/dev/LICENSE + +### Google Fonts +Website: https://fonts.google.com/icons +License: Apache License, version 2.0 +https://fonts.google.com/attribution + +### Components +See `/components` for the respective projects and their licenses. + diff --git a/components/nanobake/CMakeLists.txt b/components/nanobake/CMakeLists.txt index ebf57239..c46b78ab 100644 --- a/components/nanobake/CMakeLists.txt +++ b/components/nanobake/CMakeLists.txt @@ -4,6 +4,7 @@ idf_component_register( "src/apps/services/desktop" "src/apps/services/loader" "src/apps/services/gui" + "src/apps/services/gui/widgets" INCLUDE_DIRS "src" REQUIRES esp_lvgl_port esp_lcd esp_lcd_touch driver mlib cmsis_core furi nvs_flash spiffs fatfs ) diff --git a/components/nanobake/assets/placeholder.txt b/components/nanobake/assets/placeholder.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/components/nanobake/assets/wifi-off.png b/components/nanobake/assets/wifi-off.png new file mode 100644 index 00000000..c27a2815 Binary files /dev/null and b/components/nanobake/assets/wifi-off.png differ diff --git a/components/nanobake/assets/wifi-on.png b/components/nanobake/assets/wifi-on.png new file mode 100644 index 00000000..7e3141c8 Binary files /dev/null and b/components/nanobake/assets/wifi-on.png differ diff --git a/components/nanobake/src/apps/services/gui/gui_draw.c b/components/nanobake/src/apps/services/gui/gui_draw.c index 40cbfca0..5ae9fabb 100644 --- a/components/nanobake/src/apps/services/gui/gui_draw.c +++ b/components/nanobake/src/apps/services/gui/gui_draw.c @@ -1,6 +1,7 @@ #include "check.h" #include "gui_i.h" #include "esp_lvgl_port.h" +#include "apps/services/gui/widgets/widgets.h" static void gui_redraw_status_bar(Gui* gui, bool need_attention) { /* @@ -151,15 +152,29 @@ static void gui_redraw_status_bar(Gui* gui, bool need_attention) { } static bool gui_redraw_window(Gui* gui) { - /* - canvas_frame_set(gui->lvgl_parent, GUI_WINDOW_X, GUI_WINDOW_Y, GUI_WINDOW_WIDTH, GUI_WINDOW_HEIGHT); ViewPort* view_port = gui_view_port_find_enabled(gui->layers[GuiLayerWindow]); - if(view_port) { - view_port_draw(view_port, gui->lvgl_parent); + if (view_port) { + lv_obj_set_style_bg_blacken(gui->lvgl_parent); + + lv_obj_t* vertical_container = lv_obj_create(gui->lvgl_parent); + lv_obj_set_size(vertical_container, LV_PCT(100), LV_PCT(100)); + lv_obj_set_flex_flow(vertical_container, LV_FLEX_FLOW_COLUMN); + lv_obj_set_style_no_padding(vertical_container); + lv_obj_set_style_bg_blacken(vertical_container); + + top_bar(vertical_container); + + lv_obj_t* window_parent = lv_obj_create(vertical_container); + lv_obj_set_width(window_parent, LV_PCT(100)); + lv_obj_set_flex_grow(window_parent, 1); + lv_obj_set_style_no_padding(vertical_container); + lv_obj_set_style_bg_blacken(vertical_container); + + view_port_draw(view_port, window_parent); return true; + } else { + return false; } - */ - return false; } static bool gui_redraw_desktop(Gui* gui) { @@ -191,7 +206,6 @@ void gui_redraw(Gui* gui) { furi_check(lvgl_port_lock(100)); lv_obj_clean(gui->lvgl_parent); - lvgl_port_unlock(); gui_redraw_desktop(gui); if (!gui_redraw_fs(gui)) { @@ -201,5 +215,7 @@ void gui_redraw(Gui* gui) { gui_redraw_status_bar(gui, false); } + lvgl_port_unlock(); + gui_unlock(gui); } diff --git a/components/nanobake/src/apps/services/gui/view_port.c b/components/nanobake/src/apps/services/gui/view_port.c index b1951aaa..7238643d 100644 --- a/components/nanobake/src/apps/services/gui/view_port.c +++ b/components/nanobake/src/apps/services/gui/view_port.c @@ -89,10 +89,8 @@ void view_port_draw(ViewPort* view_port, lv_obj_t* parent) { furi_check(view_port->gui); if (view_port->draw_callback) { - furi_check(lvgl_port_lock(100)); // TODO: fail safely lv_obj_clean(parent); view_port->draw_callback(parent, view_port->draw_callback_context); - lvgl_port_unlock(); } furi_mutex_release(view_port->mutex); diff --git a/components/nanobake/src/apps/services/gui/widgets/top_bar.c b/components/nanobake/src/apps/services/gui/widgets/top_bar.c new file mode 100644 index 00000000..667c180a --- /dev/null +++ b/components/nanobake/src/apps/services/gui/widgets/top_bar.c @@ -0,0 +1,26 @@ +#include "top_bar.h" +#include "widgets.h" + +void top_bar(lv_obj_t* parent) { + lv_obj_t* topbar_container = lv_obj_create(parent); + lv_obj_set_width(topbar_container, LV_PCT(100)); + lv_obj_set_height(topbar_container, TOP_BAR_HEIGHT); + lv_obj_set_style_no_padding(topbar_container); + lv_obj_set_style_bg_blacken(topbar_container); + lv_obj_center(topbar_container); + lv_obj_set_flex_flow(topbar_container, LV_FLEX_FLOW_ROW); + + lv_obj_t* spacer = lv_obj_create(topbar_container); + lv_obj_set_height(spacer, LV_PCT(100)); + lv_obj_set_style_no_padding(spacer); + lv_obj_set_style_bg_blacken(spacer); + lv_obj_set_flex_grow(spacer, 1); + + lv_obj_t* wifi = lv_img_create(topbar_container); + lv_obj_set_size(wifi, TOP_BAR_ICON_SIZE, TOP_BAR_ICON_SIZE); + lv_obj_set_style_no_padding(wifi); + lv_obj_set_style_bg_blacken(wifi); + lv_obj_set_style_img_recolor(wifi, lv_color_white(), 0); + lv_obj_set_style_img_recolor_opa(wifi, 255, 0); + lv_img_set_src(wifi, "A:/assets/wifi-off.png"); +} \ No newline at end of file diff --git a/components/nanobake/src/apps/services/gui/widgets/top_bar.h b/components/nanobake/src/apps/services/gui/widgets/top_bar.h new file mode 100644 index 00000000..2eee282a --- /dev/null +++ b/components/nanobake/src/apps/services/gui/widgets/top_bar.h @@ -0,0 +1,8 @@ +#pragma once + +#include "lvgl.h" + +#define TOP_BAR_ICON_SIZE 18 +#define TOP_BAR_HEIGHT (TOP_BAR_ICON_SIZE + 2) + +void top_bar(lv_obj_t* parent); diff --git a/components/nanobake/src/apps/services/gui/widgets/widgets.c b/components/nanobake/src/apps/services/gui/widgets/widgets.c new file mode 100644 index 00000000..bf164f33 --- /dev/null +++ b/components/nanobake/src/apps/services/gui/widgets/widgets.c @@ -0,0 +1,11 @@ +#include "widgets.h" + +void lv_obj_set_style_bg_blacken(lv_obj_t* obj) { + lv_obj_set_style_bg_color(obj, lv_color_black(), 0); + lv_obj_set_style_border_color(obj, lv_color_black(), 0); +} + +void lv_obj_set_style_no_padding(lv_obj_t* obj) { + lv_obj_set_style_pad_all(obj, LV_STATE_DEFAULT, 0); + lv_obj_set_style_pad_gap(obj, LV_STATE_DEFAULT, 0); +} diff --git a/components/nanobake/src/apps/services/gui/widgets/widgets.h b/components/nanobake/src/apps/services/gui/widgets/widgets.h new file mode 100644 index 00000000..36acbed4 --- /dev/null +++ b/components/nanobake/src/apps/services/gui/widgets/widgets.h @@ -0,0 +1,6 @@ +#pragma once + +#include "top_bar.h" + +void lv_obj_set_style_bg_blacken(lv_obj_t* obj); +void lv_obj_set_style_no_padding(lv_obj_t* obj); diff --git a/components/nanobake/src/apps/services/loader/loader.c b/components/nanobake/src/apps/services/loader/loader.c index d08b53bf..e663d914 100644 --- a/components/nanobake/src/apps/services/loader/loader.c +++ b/components/nanobake/src/apps/services/loader/loader.c @@ -136,9 +136,18 @@ static void loader_start_app_with_manifest( loader->app_data.view_port = view_port; view_port_draw_callback_set(view_port, manifest->on_show, NULL); - FURI_RECORD_TRANSACTION(RECORD_GUI, Gui*, gui, { - gui_add_view_port(gui, view_port, GuiLayerFullscreen); // TODO: layer type - }) + switch (manifest->type) { + case AppTypeService: + furi_crash("service apps cannot have an on_show implementation"); + case AppTypeSystem: + case AppTypeUser: + FURI_RECORD_TRANSACTION(RECORD_GUI, Gui*, gui, { + gui_add_view_port(gui, view_port, GuiLayerWindow); + }) + break; + default: + furi_crash("viewport not implemented for app type"); + } } else { loader->app_data.view_port = NULL; } diff --git a/components/nanobake/src/graphics.c b/components/nanobake/src/graphics.c index fb2a685d..7eb11803 100644 --- a/components/nanobake/src/graphics.c +++ b/components/nanobake/src/graphics.c @@ -1,6 +1,7 @@ #include "check.h" #include "esp_lvgl_port.h" #include "graphics_i.h" +#include "lvgl.h" #define TAG "lvgl" diff --git a/components/nanobake/src/nanobake.c b/components/nanobake/src/nanobake.c index 2d381cca..79488fc4 100644 --- a/components/nanobake/src/nanobake.c +++ b/components/nanobake/src/nanobake.c @@ -1,5 +1,4 @@ #include "nanobake.h" -#include "app_i.h" #include "app_manifest_registry.h" #include "devices_i.h" #include "furi.h" @@ -52,5 +51,4 @@ __attribute__((unused)) extern void nanobake_start(Config* _Nonnull config) { register_apps(config); start_services(); - // TODO: option to await starting services? } diff --git a/components/nanobake/src/partitions.c b/components/nanobake/src/partitions.c index 5eb28127..c11034ba 100644 --- a/components/nanobake/src/partitions.c +++ b/components/nanobake/src/partitions.c @@ -43,7 +43,7 @@ esp_err_t nb_partitions_init() { esp_vfs_spiffs_conf_t assets_spiffs = { .base_path = MOUNT_POINT_ASSETS, .partition_label = NULL, - .max_files = 4, + .max_files = 100, .format_if_mount_failed = false }; @@ -54,7 +54,7 @@ esp_err_t nb_partitions_init() { esp_vfs_spiffs_conf_t config_spiffs = { .base_path = MOUNT_POINT_CONFIG, .partition_label = "config", - .max_files = 2, + .max_files = 100, .format_if_mount_failed = false }; diff --git a/main/src/hello_world/hello_world.c b/main/src/hello_world/hello_world.c index 65fb82b7..8e0e6e7a 100644 --- a/main/src/hello_world/hello_world.c +++ b/main/src/hello_world/hello_world.c @@ -4,6 +4,8 @@ #include "apps/services/loader/loader.h" static void on_button_click(lv_event_t _Nonnull* event) { + UNUSED(event); + FURI_RECORD_TRANSACTION(RECORD_LOADER, Loader*, loader, { loader_start_app_nonblocking(loader, "systeminfo", NULL); })