Skip to content

Commit

Permalink
feat: screen saver runs by pressing back on Main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Otrebor671 committed Aug 17, 2024
1 parent 663c009 commit 7bc4308
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
3 changes: 2 additions & 1 deletion firmware/main/modules/menus_module/menus.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "display_settings.h"
#include "file_manager_module.h"
#include "ota_module.h"
#include "stealth_mode.h"
#include "web_file_browser_module.h"

typedef enum {
Expand Down Expand Up @@ -487,6 +488,6 @@ menu_t menus[] = { //////////////////////////////////
.menu_idx = MENU_STEALTH_MODE_2,
.parent_idx = MENU_SETTINGS_2,
.last_selected_submenu = 0,
.on_enter_cb = NULL,
.on_enter_cb = stealth_mode_open_menu,
.on_exit_cb = NULL,
.is_visible = true}};
14 changes: 5 additions & 9 deletions firmware/main/modules/menus_module/menus_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <string.h>

#include "leds.h"
#include "led_events.h"
#include "menu_screens_modules.h"
#include "menus_screens.h"
#include "modals_module.h"
Expand Down Expand Up @@ -93,6 +93,7 @@ static void navigation_enter() {

static void navigation_exit() {
if (menus_ctx->current_menu == MENU_MAIN_2) {
screen_saver_run();
return;
}
menus[get_menu_idx(menus_ctx->current_menu)].last_selected_submenu =
Expand Down Expand Up @@ -149,11 +150,9 @@ static void menus_input_cb(uint8_t button_name, uint8_t button_event) {

static void show_logo() {
oled_screen_clear();
leds_on();
buzzer_play();
led_control_run_effect(led_control_pulse_leds);
buzzer_play_for(100);
screen_saver_run();
vTaskDelay(500 / portTICK_PERIOD_MS);
buzzer_stop();
}

void menus_module_set_reset_screen(menu_idx_t menu) {
Expand All @@ -163,12 +162,9 @@ void menus_module_set_reset_screen(menu_idx_t menu) {

static void get_reset_menu() {
menus_ctx->current_menu = preferences_get_int("MENUNUMBER", MENU_MAIN_2);

if ((int) menus_ctx->current_menu == MENU_MAIN) {
preferences_put_int("logo_show", 1);
if ((int) menus_ctx->current_menu == MENU_MAIN_2) {
show_logo();
} else {
preferences_put_int("logo_show", 0);
preferences_put_int("MENUNUMBER", MENU_MAIN_2);
screen_saver_get_idle_state();
refresh_menus();
Expand Down
2 changes: 1 addition & 1 deletion firmware/main/modules/screen_saver/screen_saver.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ esp_timer_handle_t screen_savar_idle_timer2;
void screen_saver_run();

static void timer_callback() {
if (menus_module_get_app_state()) {
if (menus_module_get_app_state() || screen_saver_running) {
return;
}

Expand Down
3 changes: 1 addition & 2 deletions firmware/main/modules/settings/stealth_mode/stealth_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ static void set_stealth_status() {
buzzer_enable();
leds_begin();
}
menus_module_set_app_state(false, NULL);
menu_screens_exit_submenu();
menus_module_exit_app();
vTaskDelete(NULL);
}

Expand Down

0 comments on commit 7bc4308

Please sign in to comment.