Skip to content

Commit

Permalink
translucent statusbar and submenu
Browse files Browse the repository at this point in the history
  • Loading branch information
ligenxxxx committed Jun 20, 2024
1 parent c539e50 commit a13ab06
Show file tree
Hide file tree
Showing 21 changed files with 101 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/core/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,7 @@ int load_bmp_image(const char *file, uint32_t *obuf, int width, int height) {

static uint32_t img_menu_bg_data[1920 * 1080]; // 0x00BBGGRR
lv_img_dsc_t img_menu_bg;
uint8_t wallpaper_is_used = 0;
int load_wallpaper(char *file_path) {
if (load_bmp_image(file_path, img_menu_bg_data, 1920, 1080)) {
img_menu_bg.header.cf = LV_IMG_CF_TRUE_COLOR;
Expand All @@ -1062,6 +1063,7 @@ int load_wallpaper(char *file_path) {
img_menu_bg.header.h = 1080;
img_menu_bg.data_size = 1920 * 1080 * LV_COLOR_SIZE / 8;
img_menu_bg.data = (uint8_t *)img_menu_bg_data;
wallpaper_is_used = 1;
return 1;
} else {
return 0;
Expand Down
1 change: 1 addition & 0 deletions src/core/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ typedef struct {

extern uint8_t channel_osd_mode;
extern lv_img_dsc_t img_menu_bg;
extern uint8_t wallpaper_is_used;

int osd_init(void);
int osd_clear(void);
Expand Down
5 changes: 5 additions & 0 deletions src/ui/page_autoscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <minIni.h>

#include "core/osd.h"
#include "core/settings.h"
#include "ui/ui_style.h"

Expand All @@ -21,6 +22,8 @@ static lv_obj_t *page_autoscan_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_t *section = lv_menu_section_create(page);
lv_obj_add_style(section, &style_submenu, LV_PART_MAIN);
lv_obj_set_size(section, 1053, 894);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(section, LV_OPA_TRANSP, 0);

create_text(NULL, section, false, "Auto Scan:", LV_MENU_ITEM_BUILDER_VARIANT_2);

Expand All @@ -30,6 +33,8 @@ static lv_obj_t *page_autoscan_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_set_layout(cont, LV_LAYOUT_GRID);
lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_style(cont, &style_context, LV_PART_MAIN);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(cont, LV_OPA_50, 0);

lv_obj_set_style_grid_column_dsc_array(cont, col_dsc, 0);
lv_obj_set_style_grid_row_dsc_array(cont, row_dsc, 0);
Expand Down
5 changes: 5 additions & 0 deletions src/ui/page_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <minIni.h>

#include "core/common.hh"
#include "core/osd.h"
#include "core/settings.h"
#include "driver/rtc.h"
#include "ui/page_common.h"
Expand Down Expand Up @@ -353,6 +354,8 @@ static lv_obj_t *page_clock_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_t *section = lv_menu_section_create(page);
lv_obj_add_style(section, &style_submenu, LV_PART_MAIN);
lv_obj_set_size(section, 1053, 894);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(section, LV_OPA_TRANSP, 0);

create_text(NULL, section, false, "Clock:", LV_MENU_ITEM_BUILDER_VARIANT_2);

Expand All @@ -362,6 +365,8 @@ static lv_obj_t *page_clock_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_set_layout(cont, LV_LAYOUT_GRID);
lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_style(cont, &style_context, LV_PART_MAIN);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(cont, LV_OPA_50, 0);

lv_obj_set_style_grid_column_dsc_array(cont, col_dsc, 0);
lv_obj_set_style_grid_row_dsc_array(cont, row_dsc, 0);
Expand Down
5 changes: 5 additions & 0 deletions src/ui/page_elrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "core/common.hh"
#include "core/elrs.h"
#include "core/osd.h"
#include "core/settings.h"
#include "driver/esp32.h"
#include "page_version.h"
Expand Down Expand Up @@ -79,6 +80,8 @@ static lv_obj_t *page_elrs_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_t *section = lv_menu_section_create(page);
lv_obj_add_style(section, &style_submenu, LV_PART_MAIN);
lv_obj_set_size(section, 1053, 894);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(section, LV_OPA_TRANSP, 0);

create_text(NULL, section, false, "ELRS:", LV_MENU_ITEM_BUILDER_VARIANT_2);

Expand All @@ -88,6 +91,8 @@ static lv_obj_t *page_elrs_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_set_layout(cont, LV_LAYOUT_GRID);
lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_style(cont, &style_context, LV_PART_MAIN);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(cont, LV_OPA_50, 0);

lv_obj_set_style_grid_column_dsc_array(cont, col_dsc, 0);
lv_obj_set_style_grid_row_dsc_array(cont, row_dsc, 0);
Expand Down
5 changes: 5 additions & 0 deletions src/ui/page_fans.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "core/app_state.h"
#include "core/common.hh"
#include "core/osd.h"
#include "core/settings.h"
#include "driver/fans.h"
#include "driver/nct75.h"
Expand Down Expand Up @@ -50,6 +51,8 @@ static lv_obj_t *page_fans_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_t *section = lv_menu_section_create(page);
lv_obj_add_style(section, &style_submenu, LV_PART_MAIN);
lv_obj_set_size(section, 1053, 894);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(section, LV_OPA_TRANSP, 0);

create_text(NULL, section, false, "Fans:", LV_MENU_ITEM_BUILDER_VARIANT_2);

Expand All @@ -59,6 +62,8 @@ static lv_obj_t *page_fans_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_set_layout(cont, LV_LAYOUT_GRID);
lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_style(cont, &style_context, LV_PART_MAIN);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(cont, LV_OPA_50, 0);

lv_obj_set_style_grid_column_dsc_array(cont, col_dsc, 0);
lv_obj_set_style_grid_row_dsc_array(cont, row_dsc, 0);
Expand Down
2 changes: 2 additions & 0 deletions src/ui/page_focus_chart.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ lv_obj_t *page_focus_chart_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_t *section = lv_menu_section_create(page);
lv_obj_add_style(section, &style_submenu, LV_PART_MAIN);
lv_obj_set_size(section, 1053, 894);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(section, LV_OPA_TRANSP, 0);

create_text(NULL, section, false, "Focus Chart:", LV_MENU_ITEM_BUILDER_VARIANT_2);

Expand Down
5 changes: 5 additions & 0 deletions src/ui/page_headtracker.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "common.hh"
#include "core/app_state.h"
#include "core/osd.h"
#include "core/settings.h"
#include "ht.h"
#include "page_common.h"
Expand Down Expand Up @@ -140,6 +141,8 @@ static lv_obj_t *page_headtracker_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_t *section = lv_menu_section_create(page);
lv_obj_add_style(section, &style_submenu, LV_PART_MAIN);
lv_obj_set_size(section, 1053, 894);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(section, LV_OPA_TRANSP, 0);

create_text(NULL, section, false, "Head Tracker:", LV_MENU_ITEM_BUILDER_VARIANT_2);

Expand All @@ -149,6 +152,8 @@ static lv_obj_t *page_headtracker_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_set_layout(cont, LV_LAYOUT_GRID);
lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_style(cont, &style_context, LV_PART_MAIN);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(cont, LV_OPA_50, 0);

lv_obj_set_style_grid_column_dsc_array(cont, col_dsc, 0);
lv_obj_set_style_grid_row_dsc_array(cont, row_dsc, 0);
Expand Down
5 changes: 5 additions & 0 deletions src/ui/page_imagesettings.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "core/app_state.h"
#include "core/common.hh"
#include "core/osd.h"
#include "core/settings.h"
#include "driver/hardware.h"
#include "driver/oled.h"
Expand Down Expand Up @@ -35,6 +36,8 @@ static lv_obj_t *page_imagesettings_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_t *section = lv_menu_section_create(page);
lv_obj_add_style(section, &style_submenu, LV_PART_MAIN);
lv_obj_set_size(section, 1053, 894);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(section, LV_OPA_TRANSP, 0);

create_text(NULL, section, false, "Image Setting:", LV_MENU_ITEM_BUILDER_VARIANT_2);

Expand All @@ -44,6 +47,8 @@ static lv_obj_t *page_imagesettings_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_set_layout(cont, LV_LAYOUT_GRID);
lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_style(cont, &style_context, LV_PART_MAIN);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(cont, LV_OPA_50, 0);

lv_obj_set_style_grid_column_dsc_array(cont, col_dsc, 0);
lv_obj_set_style_grid_row_dsc_array(cont, row_dsc, 0);
Expand Down
20 changes: 12 additions & 8 deletions src/ui/page_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "core/dvr.h"
#include "core/ht.h"
#include "core/input_device.h"
#include "core/sleep_mode.h"
#include "core/osd.h"
#include "core/sleep_mode.h"

#include "ui/page_fans.h"
#include "ui/ui_image_setting.h"
Expand Down Expand Up @@ -37,10 +37,10 @@ static lv_coord_t col_dsc[] = {160, 200, 160, 160, 160, 120, LV_GRID_TEMPLATE_LA
static lv_coord_t row_dsc[] = {60, 60, 60, 60, 60, 60, 60, 60, 60, LV_GRID_TEMPLATE_LAST};

const char *btnOptions[] = {"Toggle OSD", "Main menu", "Toggle DVR", "Center HT", "Calibrate HT", "Go Sleep!", "Toggle fan speed"};
void (* const btnFunctionPointers[])() = {&osd_toggle, &app_switch_to_menu, &dvr_toggle, &ht_set_center_position, &ht_calibrate, &go_sleep, &step_topfan};
void (*const btnFunctionPointers[])() = {&osd_toggle, &app_switch_to_menu, &dvr_toggle, &ht_set_center_position, &ht_calibrate, &go_sleep, &step_topfan};

const char *rollerOptions[] = {"Switch channel", "Change fan speed", "OLED Brightness"};
void (* const rollerFunctionPointers[])(uint8_t) = {&tune_channel, &change_topfan, &change_oled_brightness};
void (*const rollerFunctionPointers[])(uint8_t) = {&tune_channel, &change_topfan, &change_oled_brightness};
const uint16_t rollerDefaultOption = 0;

static rowType_t selectedRow = ROW_COUNT;
Expand All @@ -51,7 +51,7 @@ static uint16_t previousSelection;
/**
* Build a '\n'-separated list of all available options for the dropdown element
*/
static void build_options_string(const char** input, size_t arraySize, char* output) {
static void build_options_string(const char **input, size_t arraySize, char *output) {
output[0] = 0;
for (size_t i = 0; i < arraySize; i++) {
strcat(output, input[i]);
Expand Down Expand Up @@ -168,6 +168,8 @@ static lv_obj_t *page_input_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_t *section = lv_menu_section_create(page);
lv_obj_add_style(section, &style_submenu, LV_PART_MAIN);
lv_obj_set_size(section, contentWidth + 93, contentHeight + 294);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(section, LV_OPA_TRANSP, 0);

create_text(NULL, section, false, "Inputs:", LV_MENU_ITEM_BUILDER_VARIANT_2);

Expand All @@ -177,6 +179,8 @@ static lv_obj_t *page_input_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_set_layout(content, LV_LAYOUT_GRID);
lv_obj_clear_flag(content, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_style(content, &style_context, LV_PART_MAIN);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(content, LV_OPA_50, 0);

lv_obj_set_style_grid_column_dsc_array(content, col_dsc, 0);
lv_obj_set_style_grid_row_dsc_array(content, row_dsc, 0);
Expand Down Expand Up @@ -246,7 +250,7 @@ static void page_input_exit() {
*/
static void page_input_on_roller(uint8_t key) {
if (is_any_dropdown_open()) {
lv_obj_t * const targetItem = pageItems[selectedRow];
lv_obj_t *const targetItem = pageItems[selectedRow];
uint32_t evt = (key == DIAL_KEY_DOWN) ? LV_KEY_UP : LV_KEY_DOWN;

lv_event_send(targetItem, LV_EVENT_KEY, &evt);
Expand Down Expand Up @@ -275,18 +279,18 @@ static void page_input_on_roller(uint8_t key) {
static void page_input_on_click(uint8_t key, int sel) {
LV_UNUSED(key);

if ((rowType_t) sel >= BACK_BTN) {
if ((rowType_t)sel >= BACK_BTN) {
return;
}

if (is_any_dropdown_open()) {
accept_dropdown(pageItems[selectedRow]);
} else {
selectedRow = (rowType_t)sel;
lv_obj_t * const currentItem = pageItems[selectedRow];
lv_obj_t *const currentItem = pageItems[selectedRow];

lv_dropdown_open(currentItem);
lv_obj_t * const list = lv_dropdown_get_list(currentItem);
lv_obj_t *const list = lv_dropdown_get_list(currentItem);
lv_obj_add_style(list, &style_dropdown, LV_PART_MAIN);
lv_obj_set_style_text_color(list, lv_color_make(0, 0, 0), LV_PART_SELECTED | LV_STATE_CHECKED);
previousSelection = lv_dropdown_get_selected(currentItem);
Expand Down
4 changes: 4 additions & 0 deletions src/ui/page_osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ static lv_obj_t *page_osd_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_t *section = lv_menu_section_create(page);
lv_obj_add_style(section, &style_submenu, LV_PART_MAIN);
lv_obj_set_size(section, 1053, 894);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(section, LV_OPA_TRANSP, 0);

create_text(NULL, section, false, "OSD:", LV_MENU_ITEM_BUILDER_VARIANT_2);

Expand All @@ -53,6 +55,8 @@ static lv_obj_t *page_osd_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_set_layout(cont, LV_LAYOUT_GRID);
lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_style(cont, &style_context, LV_PART_MAIN);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(cont, LV_OPA_50, 0);

lv_obj_set_style_grid_column_dsc_array(cont, col_dsc, 0);
lv_obj_set_style_grid_row_dsc_array(cont, row_dsc, 0);
Expand Down
4 changes: 4 additions & 0 deletions src/ui/page_playback.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@ static lv_obj_t *page_playback_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_t *section = lv_menu_section_create(page);
lv_obj_add_style(section, &style_submenu, LV_PART_MAIN);
lv_obj_set_size(section, 1142, 894);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(section, LV_OPA_TRANSP, 0);

create_text(NULL, section, false, "Playback:", LV_MENU_ITEM_BUILDER_VARIANT_2);

lv_obj_t *cont = lv_obj_create(section);
lv_obj_set_size(cont, 1164, 760);
lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_style(cont, &style_context, LV_PART_MAIN);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(cont, LV_OPA_50, 0);

for (uint32_t pos = 0; pos < ITEMS_LAYOUT_CNT; pos++) {
pb_ui[pos]._img = lv_img_create(cont);
Expand Down
7 changes: 6 additions & 1 deletion src/ui/page_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "core/app_state.h"
#include "core/battery.h"
#include "core/common.hh"
#include "core/osd.h"
#include "core/settings.h"
#include "driver/dm5680.h"
#include "driver/hardware.h"
Expand Down Expand Up @@ -42,7 +43,7 @@ static btn_group_t btn_group_osd_display_mode;
static btn_group_t btn_group_warn_type;
static btn_group_t btn_group_power_ana;

static slider_group_t* selected_slider_group = NULL;
static slider_group_t *selected_slider_group = NULL;

static lv_coord_t col_dsc[] = {160, 200, 160, 160, 120, 160, LV_GRID_TEMPLATE_LAST};
static lv_coord_t row_dsc[] = {60, 60, 60, 60, 60, 60, 60, 60, 60, 60, LV_GRID_TEMPLATE_LAST};
Expand Down Expand Up @@ -97,6 +98,8 @@ static lv_obj_t *page_power_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_t *section = lv_menu_section_create(page);
lv_obj_add_style(section, &style_submenu, LV_PART_MAIN);
lv_obj_set_size(section, 1063, 984);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(section, LV_OPA_TRANSP, 0);

create_text(NULL, section, false, "Power:", LV_MENU_ITEM_BUILDER_VARIANT_2);

Expand All @@ -106,6 +109,8 @@ static lv_obj_t *page_power_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_set_layout(cont, LV_LAYOUT_GRID);
lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_style(cont, &style_context, LV_PART_MAIN);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(cont, LV_OPA_50, 0);

lv_obj_set_style_grid_column_dsc_array(cont, col_dsc, 0);
lv_obj_set_style_grid_row_dsc_array(cont, row_dsc, 0);
Expand Down
5 changes: 5 additions & 0 deletions src/ui/page_record.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <minIni.h>

#include "../core/common.hh"
#include "core/osd.h"
#include "core/settings.h"
#include "driver/rtc.h"
#include "page_common.h"
Expand Down Expand Up @@ -48,6 +49,8 @@ static lv_obj_t *page_record_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_t *section = lv_menu_section_create(page);
lv_obj_add_style(section, &style_submenu, LV_PART_MAIN);
lv_obj_set_size(section, 1053, 894);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(section, LV_OPA_TRANSP, 0);

create_text(NULL, section, false, "Record Option:", LV_MENU_ITEM_BUILDER_VARIANT_2);

Expand All @@ -57,6 +60,8 @@ static lv_obj_t *page_record_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_set_layout(cont, LV_LAYOUT_GRID);
lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_style(cont, &style_context, LV_PART_MAIN);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(cont, LV_OPA_50, 0);

lv_obj_set_style_grid_column_dsc_array(cont, col_dsc, 0);
lv_obj_set_style_grid_row_dsc_array(cont, row_dsc, 0);
Expand Down
3 changes: 3 additions & 0 deletions src/ui/page_sleep.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "page_sleep.h"

#include "core/osd.h"
#include "driver/fans.h"
#include "page_fans.h"
#include "sleep_mode.h"
Expand All @@ -16,6 +17,8 @@ lv_obj_t *page_sleep_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_t *section = lv_menu_section_create(page);
lv_obj_add_style(section, &style_submenu, LV_PART_MAIN);
lv_obj_set_size(section, 1053, 894);
if (wallpaper_is_used)
lv_obj_set_style_bg_opa(section, LV_OPA_TRANSP, 0);

create_text(NULL, section, false, "Go Sleep:", LV_MENU_ITEM_BUILDER_VARIANT_2);

Expand Down
Loading

0 comments on commit a13ab06

Please sign in to comment.