diff --git a/applications/services/gui/gui.c b/applications/services/gui/gui.c index 24ea57bc0bd..68a28731076 100644 --- a/applications/services/gui/gui.c +++ b/applications/services/gui/gui.c @@ -249,7 +249,7 @@ static void gui_redraw(Gui* gui) { canvas_reset(gui->canvas); - if(gui->lockdown) { + if(gui_is_lockdown(gui)) { gui_redraw_desktop(gui); bool need_attention = (gui_view_port_find_enabled(gui->layers[GuiLayerWindow]) != 0 || @@ -299,7 +299,7 @@ static void gui_input(Gui* gui, InputEvent* input_event) { ViewPort* view_port = NULL; - if(gui->lockdown) { + if(gui_is_lockdown(gui)) { view_port = gui_view_port_find_enabled(gui->layers[GuiLayerDesktop]); } else { view_port = gui_view_port_find_enabled(gui->layers[GuiLayerFullscreen]); @@ -495,6 +495,23 @@ void gui_set_lockdown(Gui* gui, bool lockdown) { gui_update(gui); } +void gui_set_lockdown_inhibit(Gui* gui, bool inhibit) { + furi_check(gui); + + gui_lock(gui); + gui->lockdown_inhibit = inhibit; + gui_unlock(gui); + + // Request redraw + gui_update(gui); +} + +bool gui_is_lockdown(const Gui* gui) { + furi_check(gui); + + return gui->lockdown && !gui->lockdown_inhibit; +} + Canvas* gui_direct_draw_acquire(Gui* gui) { furi_check(gui); diff --git a/applications/services/gui/gui.h b/applications/services/gui/gui.h index 1b5987edace..7eb19b91d19 100644 --- a/applications/services/gui/gui.h +++ b/applications/services/gui/gui.h @@ -110,6 +110,23 @@ size_t gui_get_framebuffer_size(const Gui* gui); */ void gui_set_lockdown(Gui* gui, bool lockdown); +/** Inhibit lockdown mode + * + * Lockdown mode can be inhibited by calling this function with inhibit set to true. + * This is used to show information even when flipper is locked. + * + * @param gui Gui instance + * @param inhibit true to inhibit lockdown mode + */ +void gui_set_lockdown_inhibit(Gui* gui, bool inhibit); + +/** Check if Gui is in lockdown mode + * + * @param gui Gui instance + * @return bool true if Gui is in lockdown mode + */ +bool gui_is_lockdown(const Gui* gui); + /** Acquire Direct Draw lock and get Canvas instance * * This method return Canvas instance for use in monopoly mode. Direct draw lock diff --git a/applications/services/gui/gui_i.h b/applications/services/gui/gui_i.h index 8bd3215f97c..f146ad1fca6 100644 --- a/applications/services/gui/gui_i.h +++ b/applications/services/gui/gui_i.h @@ -51,6 +51,7 @@ struct Gui { // Layers and Canvas bool lockdown; + bool lockdown_inhibit; bool direct_draw; ViewPortArray_t layers[GuiLayerMAX]; Canvas* canvas; diff --git a/applications/settings/clock_settings/clock_settings_alarm.c b/applications/settings/clock_settings/clock_settings_alarm.c index 7b096ef7066..ef348c0b190 100644 --- a/applications/settings/clock_settings/clock_settings_alarm.c +++ b/applications/settings/clock_settings/clock_settings_alarm.c @@ -11,9 +11,16 @@ #define TAG "ClockSettingsAlarm" +#define SNOOZE_MINUTES 9 +#define TIMEOUT_MINUTES 10 + typedef struct { DateTime now; + DateTime snooze_until; + DateTime alarm_start; IconAnimation* icon; + + bool is_snooze; } ClockSettingsAlramModel; const NotificationSequence sequence_alarm = { @@ -47,12 +54,15 @@ static void clock_settings_alarm_draw_callback(Canvas* canvas, void* ctx) { ClockSettingsAlramModel* model = ctx; char buffer[64] = {}; + // Clock icon canvas_draw_icon_animation(canvas, 5, 6, model->icon); + // Time canvas_set_font(canvas, FontBigNumbers); snprintf(buffer, sizeof(buffer), "%02u:%02u", model->now.hour, model->now.minute); canvas_draw_str(canvas, 58, 32, buffer); + // Date canvas_set_font(canvas, FontPrimary); snprintf( buffer, @@ -62,6 +72,11 @@ static void clock_settings_alarm_draw_callback(Canvas* canvas, void* ctx) { model->now.month, model->now.year); canvas_draw_str(canvas, 60, 44, buffer); + + // Press Back to snooze + canvas_set_font(canvas, FontPrimary); + canvas_draw_icon_ex(canvas, 5, 50, &I_back_btn_10x8, 0); + canvas_draw_str_aligned(canvas, 20, 50, AlignLeft, AlignTop, "Snooze"); } static void clock_settings_alarm_input_callback(InputEvent* input_event, void* ctx) { @@ -81,8 +96,10 @@ int32_t clock_settings_alarm(void* p) { // View Model ClockSettingsAlramModel model; + model.is_snooze = false; furi_hal_rtc_get_datetime(&model.now); + furi_hal_rtc_get_alarm(&model.alarm_start); model.icon = icon_animation_alloc(&A_Alarm_47x39); // Alloc message queue @@ -95,6 +112,7 @@ int32_t clock_settings_alarm(void* p) { // Register view port in GUI Gui* gui = furi_record_open(RECORD_GUI); + gui_set_lockdown_inhibit(gui, true); gui_add_view_port(gui, view_port, GuiLayerFullscreen); NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION); @@ -110,12 +128,43 @@ int32_t clock_settings_alarm(void* p) { while(running) { if(furi_message_queue_get(event_queue, &event, 2000) == FuriStatusOk) { if(event.type == InputTypePress) { - running = false; + // Snooze + if(event.key == InputKeyBack) { + furi_hal_rtc_get_datetime(&model.snooze_until); + model.snooze_until.minute += SNOOZE_MINUTES; + model.snooze_until.hour += model.snooze_until.minute / 60; + model.snooze_until.minute %= 60; + model.snooze_until.hour %= 24; + + model.is_snooze = true; + model.alarm_start = model.snooze_until; // For correct timeout behavior + view_port_enabled_set(view_port, false); + gui_set_lockdown_inhibit(gui, false); + } else { + running = false; + } + } + } else if(model.is_snooze) { + furi_hal_rtc_get_datetime(&model.now); + if(datetime_datetime_to_timestamp(&model.now) >= + datetime_datetime_to_timestamp(&model.snooze_until)) { + view_port_enabled_set(view_port, true); + gui_set_lockdown_inhibit(gui, true); + + model.is_snooze = false; } } else { notification_message(notification, &sequence_alarm); furi_hal_rtc_get_datetime(&model.now); view_port_update(view_port); + + // Stop the alarm if it has been ringing for more than TIMEOUT_MINUTES + if((model.now.hour == model.alarm_start.hour && + model.now.minute >= model.alarm_start.minute + TIMEOUT_MINUTES) || + (model.now.hour == (model.alarm_start.hour + 1) % 24 && + model.now.minute < (model.alarm_start.minute + TIMEOUT_MINUTES) % 60)) { + running = false; + } } } @@ -125,6 +174,7 @@ int32_t clock_settings_alarm(void* p) { furi_record_close(RECORD_NOTIFICATION); view_port_enabled_set(view_port, false); + gui_set_lockdown_inhibit(gui, false); gui_remove_view_port(gui, view_port); view_port_free(view_port); furi_message_queue_free(event_queue); diff --git a/targets/f18/api_symbols.csv b/targets/f18/api_symbols.csv index 0a4b7dde62c..13c1afb8710 100644 --- a/targets/f18/api_symbols.csv +++ b/targets/f18/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,79.2,, +Version,+,80.0,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/bt/bt_service/bt_keys_storage.h,, Header,+,applications/services/cli/cli.h,, @@ -1736,9 +1736,11 @@ Function,+,gui_add_view_port,void,"Gui*, ViewPort*, GuiLayer" Function,+,gui_direct_draw_acquire,Canvas*,Gui* Function,+,gui_direct_draw_release,void,Gui* Function,+,gui_get_framebuffer_size,size_t,const Gui* +Function,+,gui_is_lockdown,_Bool,const Gui* Function,+,gui_remove_framebuffer_callback,void,"Gui*, GuiCanvasCommitCallback, void*" Function,+,gui_remove_view_port,void,"Gui*, ViewPort*" Function,+,gui_set_lockdown,void,"Gui*, _Bool" +Function,+,gui_set_lockdown_inhibit,void,"Gui*, _Bool" Function,-,gui_view_port_send_to_back,void,"Gui*, ViewPort*" Function,+,gui_view_port_send_to_front,void,"Gui*, ViewPort*" Function,-,hci_send_req,int,"hci_request*, uint8_t" @@ -2302,9 +2304,9 @@ Function,+,pipe_install_as_stdio,void,PipeSide* Function,+,pipe_receive,size_t,"PipeSide*, void*, size_t, FuriWait" Function,+,pipe_role,PipeRole,PipeSide* Function,+,pipe_send,size_t,"PipeSide*, const void*, size_t, FuriWait" +Function,+,pipe_set_broken_callback,void,"PipeSide*, PipeSideBrokenCallback, FuriEventLoopEvent" Function,+,pipe_set_callback_context,void,"PipeSide*, void*" Function,+,pipe_set_data_arrived_callback,void,"PipeSide*, PipeSideDataArrivedCallback, FuriEventLoopEvent" -Function,+,pipe_set_broken_callback,void,"PipeSide*, PipeSideBrokenCallback, FuriEventLoopEvent" Function,+,pipe_set_space_freed_callback,void,"PipeSide*, PipeSideSpaceFreedCallback, FuriEventLoopEvent" Function,+,pipe_spaces_available,size_t,PipeSide* Function,+,pipe_state,PipeState,PipeSide* diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index 15f4d70d7d9..ccdf3711db1 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,79.2,, +Version,+,80.0,, Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/bt/bt_service/bt_keys_storage.h,, @@ -1955,9 +1955,11 @@ Function,+,gui_add_view_port,void,"Gui*, ViewPort*, GuiLayer" Function,+,gui_direct_draw_acquire,Canvas*,Gui* Function,+,gui_direct_draw_release,void,Gui* Function,+,gui_get_framebuffer_size,size_t,const Gui* +Function,+,gui_is_lockdown,_Bool,const Gui* Function,+,gui_remove_framebuffer_callback,void,"Gui*, GuiCanvasCommitCallback, void*" Function,+,gui_remove_view_port,void,"Gui*, ViewPort*" Function,+,gui_set_lockdown,void,"Gui*, _Bool" +Function,+,gui_set_lockdown_inhibit,void,"Gui*, _Bool" Function,-,gui_view_port_send_to_back,void,"Gui*, ViewPort*" Function,+,gui_view_port_send_to_front,void,"Gui*, ViewPort*" Function,-,hci_send_req,int,"hci_request*, uint8_t" @@ -2938,9 +2940,9 @@ Function,+,pipe_install_as_stdio,void,PipeSide* Function,+,pipe_receive,size_t,"PipeSide*, void*, size_t, FuriWait" Function,+,pipe_role,PipeRole,PipeSide* Function,+,pipe_send,size_t,"PipeSide*, const void*, size_t, FuriWait" +Function,+,pipe_set_broken_callback,void,"PipeSide*, PipeSideBrokenCallback, FuriEventLoopEvent" Function,+,pipe_set_callback_context,void,"PipeSide*, void*" Function,+,pipe_set_data_arrived_callback,void,"PipeSide*, PipeSideDataArrivedCallback, FuriEventLoopEvent" -Function,+,pipe_set_broken_callback,void,"PipeSide*, PipeSideBrokenCallback, FuriEventLoopEvent" Function,+,pipe_set_space_freed_callback,void,"PipeSide*, PipeSideSpaceFreedCallback, FuriEventLoopEvent" Function,+,pipe_spaces_available,size_t,PipeSide* Function,+,pipe_state,PipeState,PipeSide*