From 9317ded1a96b6ed3e78e094bb8cbd4f72e5eadbb Mon Sep 17 00:00:00 2001 From: Nikolay Minaylov Date: Mon, 22 Aug 2022 20:54:01 +0300 Subject: [PATCH] [FL-2749] New power off screen #1637 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: あく --- applications/power/power_service/power.c | 14 +++--- applications/power/power_service/power_api.c | 4 +- applications/power/power_service/power_i.h | 5 +- .../power_service/views/power_unplug_usb.c | 43 ++++++++++++++++++ .../power_service/views/power_unplug_usb.h | 11 +++++ .../icons/Power/Unplug_bg_bottom_128x10.png | Bin 0 -> 5355 bytes assets/icons/Power/Unplug_bg_top_128x14.png | Bin 0 -> 5945 bytes 7 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 applications/power/power_service/views/power_unplug_usb.c create mode 100644 applications/power/power_service/views/power_unplug_usb.h create mode 100644 assets/icons/Power/Unplug_bg_bottom_128x10.png create mode 100644 assets/icons/Power/Unplug_bg_top_128x14.png diff --git a/applications/power/power_service/power.c b/applications/power/power_service/power.c index 9036ae1c..3a2c6cf3 100644 --- a/applications/power/power_service/power.c +++ b/applications/power/power_service/power.c @@ -55,13 +55,14 @@ Power* power_alloc() { // Gui power->view_dispatcher = view_dispatcher_alloc(); - power->popup = popup_alloc(); - popup_set_header( - power->popup, "Disconnect USB for safe\nshutdown", 64, 26, AlignCenter, AlignTop); - view_dispatcher_add_view(power->view_dispatcher, PowerViewPopup, popup_get_view(power->popup)); power->power_off = power_off_alloc(); view_dispatcher_add_view( power->view_dispatcher, PowerViewOff, power_off_get_view(power->power_off)); + power->power_unplug_usb = power_unplug_usb_alloc(); + view_dispatcher_add_view( + power->view_dispatcher, + PowerViewUnplugUsb, + power_unplug_usb_get_view(power->power_unplug_usb)); view_dispatcher_attach_to_gui( power->view_dispatcher, power->gui, ViewDispatcherTypeFullscreen); @@ -78,8 +79,9 @@ void power_free(Power* power) { // Gui view_dispatcher_remove_view(power->view_dispatcher, PowerViewOff); power_off_free(power->power_off); - view_dispatcher_remove_view(power->view_dispatcher, PowerViewPopup); - popup_free(power->popup); + view_dispatcher_remove_view(power->view_dispatcher, PowerViewUnplugUsb); + power_unplug_usb_free(power->power_unplug_usb); + view_port_free(power->battery_view_port); // State diff --git a/applications/power/power_service/power_api.c b/applications/power/power_service/power_api.c index d26fb3b4..8185b7cd 100644 --- a/applications/power/power_service/power_api.c +++ b/applications/power/power_service/power_api.c @@ -8,8 +8,8 @@ void power_off(Power* power) { furi_hal_power_off(); // Notify user if USB is plugged view_dispatcher_send_to_front(power->view_dispatcher); - view_dispatcher_switch_to_view(power->view_dispatcher, PowerViewPopup); - furi_delay_ms(10); + view_dispatcher_switch_to_view(power->view_dispatcher, PowerViewUnplugUsb); + furi_delay_ms(100); furi_halt("Disconnect USB for safe shutdown"); } diff --git a/applications/power/power_service/power_i.h b/applications/power/power_service/power_i.h index c7181d0a..66ced885 100755 --- a/applications/power/power_service/power_i.h +++ b/applications/power/power_service/power_i.h @@ -8,6 +8,7 @@ #include #include "views/power_off.h" +#include "views/power_unplug_usb.h" #include @@ -21,8 +22,8 @@ typedef enum { struct Power { ViewDispatcher* view_dispatcher; - Popup* popup; PowerOff* power_off; + PowerUnplugUsb* power_unplug_usb; ViewPort* battery_view_port; Gui* gui; @@ -42,6 +43,6 @@ struct Power { }; typedef enum { - PowerViewPopup, PowerViewOff, + PowerViewUnplugUsb, } PowerView; diff --git a/applications/power/power_service/views/power_unplug_usb.c b/applications/power/power_service/views/power_unplug_usb.c new file mode 100644 index 00000000..6d14be22 --- /dev/null +++ b/applications/power/power_service/views/power_unplug_usb.c @@ -0,0 +1,43 @@ +#include "power_unplug_usb.h" +#include +#include + +struct PowerUnplugUsb { + View* view; +}; + +static void power_unplug_usb_draw_callback(Canvas* canvas, void* _model) { + UNUSED(_model); + + canvas_set_color(canvas, ColorBlack); + canvas_draw_icon(canvas, 0, 0, &I_Unplug_bg_top_128x14); + canvas_draw_box(canvas, 0, 14, 128, (64 - 10 - 14)); + canvas_draw_icon(canvas, 0, (64 - 10), &I_Unplug_bg_bottom_128x10); + + canvas_set_color(canvas, ColorWhite); + canvas_set_font(canvas, FontPrimary); + elements_multiline_text_aligned( + canvas, 64, 32, AlignCenter, AlignCenter, "It's now safe to unplug\nUSB cable"); +} + +PowerUnplugUsb* power_unplug_usb_alloc() { + PowerUnplugUsb* power_unplug_usb = malloc(sizeof(PowerUnplugUsb)); + + power_unplug_usb->view = view_alloc(); + view_set_context(power_unplug_usb->view, power_unplug_usb); + view_set_draw_callback(power_unplug_usb->view, power_unplug_usb_draw_callback); + view_set_input_callback(power_unplug_usb->view, NULL); + + return power_unplug_usb; +} + +void power_unplug_usb_free(PowerUnplugUsb* power_unplug_usb) { + furi_assert(power_unplug_usb); + view_free(power_unplug_usb->view); + free(power_unplug_usb); +} + +View* power_unplug_usb_get_view(PowerUnplugUsb* power_unplug_usb) { + furi_assert(power_unplug_usb); + return power_unplug_usb->view; +} diff --git a/applications/power/power_service/views/power_unplug_usb.h b/applications/power/power_service/views/power_unplug_usb.h new file mode 100644 index 00000000..e85c6d03 --- /dev/null +++ b/applications/power/power_service/views/power_unplug_usb.h @@ -0,0 +1,11 @@ +#pragma once + +typedef struct PowerUnplugUsb PowerUnplugUsb; + +#include + +PowerUnplugUsb* power_unplug_usb_alloc(); + +void power_unplug_usb_free(PowerUnplugUsb* power_unplug_usb); + +View* power_unplug_usb_get_view(PowerUnplugUsb* power_unplug_usb); diff --git a/assets/icons/Power/Unplug_bg_bottom_128x10.png b/assets/icons/Power/Unplug_bg_bottom_128x10.png new file mode 100644 index 0000000000000000000000000000000000000000..35d73ba76ea10724f02119ac7c7413c6ec7d6d3f GIT binary patch literal 5355 zcmeHKc~lcu7mtVn0nv(}RVp#iD%HuJkPL)HK#3X%i!3VWWHJdMD@ib66O0>+h>BVf z5L8qU3M!y1qV_|<6^pyLp;8wV#08humTwYV@U-WA$8)~^XU>`A&0T))-ru|LzPxmv z|I88C@mLH7GlJvi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J? zBf454)Mz0U;w3_PM7cuC)5sNWigBTwKaWKljTlw|B@7@jfxi<*e4jAU&@(<{>_+?> zCvHZAK}`nr8<3&R3+;u(kInEsXK1|t=I8xd{F_tYa9=0+B7VQp^_8wKV&IF6zgE{* zy1s~kFEajGUH><_u%E6|h#dVFq(v`F?Ryu+q8F{<{Mj>oj8`tqTknPxbY!9Qi%?@Q zmNtfG2xd$EI8x<`S?WZWr_iqttv6Yg$&cd4(I zGg~J*H#IwP$FfzI1I&{q>hC?}>v?~e;f5-yLH|iSALd>;oc*e{=<= G^#294V-(;3 literal 0 HcmV?d00001 diff --git a/assets/icons/Power/Unplug_bg_top_128x14.png b/assets/icons/Power/Unplug_bg_top_128x14.png new file mode 100644 index 0000000000000000000000000000000000000000..bafa2c4947082eff8f59d48d119e9ca01ece9729 GIT binary patch literal 5945 zcmeHKcTiK?){lxbDPB;nfF%Y+5JGxLazm3229TnmbCMh&lq4jf2?&bv07a1^qEs(J zE+SY!k)l@-QA8{VHY^trq$$!xk#_>td2i+$XTJBJnK?OUuf5i9uk~ANwfKZC3+|F?y|xA9?xUt995XIZm%o$sX}rWUb~x$J zu@laH!Idgg8CxulbdC*Aw|rP>dg1nD?@Z!zqZDtGe5s_u7J?C~((h9gb;pVbPtEXg zDbpAu#g5yG7LkLK_6d1=&O~KYlMfWWThZJ%4mXtS(J8xQk+sH@ZZFZhiV+)wG6F9I z$F6w)u~zzZZnKY_wV-9EptbLn@dUSKq`O$qBc;q--I>)%YFfF*9@edsV`#YOK#M2R z+ip53^FXbAP~(j6kh1%F1E-MPM_>EZRyZtg!-5mnXNya7uv-)C;W z=k4kT;ofM$MW#@<(D33E?Z)M6@_wziH^(3JR}_s)PQ^rjB2}nLp7?W6NflP>rMWd_ z)_GU7a&9*L!o_Z-S5(Qk#N#@x1#wCMvPaEbE-meIn&l-P_jc{12U1AcHm&lU z?IXt{&ASW;?N^5zNsV%v8>f}3O#)M0Y}UsX3HkmV9=0c|T>h%xPjTlQZ|^vQM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