|
|
|
|
@@ -8,6 +8,7 @@
|
|
|
|
|
#include <furi_hal.h>
|
|
|
|
|
#include <cli/cli.h>
|
|
|
|
|
#include <cli/cli_vcp.h>
|
|
|
|
|
#include <locale/locale.h>
|
|
|
|
|
|
|
|
|
|
#include "animations/animation_manager.h"
|
|
|
|
|
#include "desktop/scenes/desktop_scene.h"
|
|
|
|
|
@@ -48,6 +49,21 @@ static void desktop_dummy_mode_icon_draw_callback(Canvas* canvas, void* context)
|
|
|
|
|
canvas_draw_icon(canvas, 0, 0, &I_GameMode_11x8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void desktop_togle_clock_view(Desktop* desktop, bool is_enabled) {
|
|
|
|
|
furi_assert(desktop);
|
|
|
|
|
|
|
|
|
|
// clock type upd after 1 minute
|
|
|
|
|
desktop->clock_type = (locale_get_time_format() == LocaleTimeFormat24h);
|
|
|
|
|
|
|
|
|
|
if(is_enabled) { // && !furi_timer_is_running(desktop->update_clock_timer)) {
|
|
|
|
|
furi_timer_start(desktop->update_clock_timer, furi_ms_to_ticks(1000));
|
|
|
|
|
} else if(!is_enabled) { //&& furi_timer_is_running(desktop->update_clock_timer)) {
|
|
|
|
|
furi_timer_stop(desktop->update_clock_timer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
view_port_enabled_set(desktop->clock_viewport, is_enabled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static uint8_t desktop_clock_get_num_w(uint8_t num) {
|
|
|
|
|
if(num == 1) {
|
|
|
|
|
return 3;
|
|
|
|
|
@@ -81,7 +97,8 @@ static void desktop_clock_draw_callback(Canvas* canvas, void* context) {
|
|
|
|
|
desktop_clock_get_num_w(d[3]) + //c4
|
|
|
|
|
2 + 4; // ":" + 4 separators
|
|
|
|
|
|
|
|
|
|
view_port_set_width(desktop->clock_viewport, new_w - 1);
|
|
|
|
|
// further away from the battery charge indicator, if the smallest minute is 1
|
|
|
|
|
view_port_set_width(desktop->clock_viewport, new_w - !(d[0] == 1));
|
|
|
|
|
|
|
|
|
|
uint8_t x = new_w;
|
|
|
|
|
|
|
|
|
|
@@ -123,6 +140,9 @@ static bool desktop_custom_event_callback(void* context, uint32_t event) {
|
|
|
|
|
// TODO: Implement a message mechanism for loading settings and (optionally)
|
|
|
|
|
// locking and unlocking
|
|
|
|
|
DESKTOP_SETTINGS_LOAD(&desktop->settings);
|
|
|
|
|
|
|
|
|
|
desktop_togle_clock_view(desktop, desktop->settings.display_clock);
|
|
|
|
|
|
|
|
|
|
desktop_auto_lock_arm(desktop);
|
|
|
|
|
return true;
|
|
|
|
|
case DesktopGlobalAutoLock:
|
|
|
|
|
@@ -192,15 +212,25 @@ static void desktop_update_clock_timer_callback(void* context) {
|
|
|
|
|
furi_assert(context);
|
|
|
|
|
Desktop* desktop = context;
|
|
|
|
|
|
|
|
|
|
FuriHalRtcDateTime curr_dt;
|
|
|
|
|
furi_hal_rtc_get_datetime(&curr_dt);
|
|
|
|
|
if(desktop->minute != curr_dt.minute) {
|
|
|
|
|
desktop->hour = curr_dt.hour;
|
|
|
|
|
desktop->minute = curr_dt.minute;
|
|
|
|
|
view_port_update(desktop->clock_viewport);
|
|
|
|
|
}
|
|
|
|
|
if(gui_get_count_of_enabled_view_port_in_layer(desktop->gui, GuiLayerStatusBarLeft) < 6) {
|
|
|
|
|
FuriHalRtcDateTime curr_dt;
|
|
|
|
|
furi_hal_rtc_get_datetime(&curr_dt);
|
|
|
|
|
|
|
|
|
|
// view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopGlobalAutoLock);
|
|
|
|
|
if(desktop->minute != curr_dt.minute) {
|
|
|
|
|
if(desktop->clock_type) {
|
|
|
|
|
desktop->hour = curr_dt.hour;
|
|
|
|
|
} else {
|
|
|
|
|
desktop->hour = (curr_dt.hour > 12) ? curr_dt.hour - 12 :
|
|
|
|
|
((curr_dt.hour == 0) ? 12 : curr_dt.hour);
|
|
|
|
|
}
|
|
|
|
|
desktop->minute = curr_dt.minute;
|
|
|
|
|
view_port_update(desktop->clock_viewport);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
view_port_enabled_set(desktop->clock_viewport, true);
|
|
|
|
|
} else {
|
|
|
|
|
view_port_enabled_set(desktop->clock_viewport, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void desktop_lock(Desktop* desktop) {
|
|
|
|
|
@@ -353,7 +383,7 @@ Desktop* desktop_alloc() {
|
|
|
|
|
desktop->clock_viewport = view_port_alloc();
|
|
|
|
|
view_port_set_width(desktop->clock_viewport, 25);
|
|
|
|
|
view_port_draw_callback_set(desktop->clock_viewport, desktop_clock_draw_callback, desktop);
|
|
|
|
|
view_port_enabled_set(desktop->clock_viewport, true);
|
|
|
|
|
view_port_enabled_set(desktop->clock_viewport, false);
|
|
|
|
|
gui_add_view_port(desktop->gui, desktop->clock_viewport, GuiLayerStatusBarRight);
|
|
|
|
|
|
|
|
|
|
// Stealth mode icon
|
|
|
|
|
@@ -391,11 +421,14 @@ Desktop* desktop_alloc() {
|
|
|
|
|
FuriHalRtcDateTime curr_dt;
|
|
|
|
|
furi_hal_rtc_get_datetime(&curr_dt);
|
|
|
|
|
|
|
|
|
|
desktop->hour = curr_dt.hour;
|
|
|
|
|
if(desktop->clock_type) {
|
|
|
|
|
desktop->hour = curr_dt.hour;
|
|
|
|
|
} else {
|
|
|
|
|
desktop->hour = (curr_dt.hour > 12) ? curr_dt.hour - 12 :
|
|
|
|
|
((curr_dt.hour == 0) ? 12 : curr_dt.hour);
|
|
|
|
|
}
|
|
|
|
|
desktop->minute = curr_dt.minute;
|
|
|
|
|
|
|
|
|
|
furi_timer_start(desktop->update_clock_timer, furi_ms_to_ticks(1000));
|
|
|
|
|
|
|
|
|
|
furi_record_create(RECORD_DESKTOP, desktop);
|
|
|
|
|
|
|
|
|
|
return desktop;
|
|
|
|
|
@@ -489,6 +522,9 @@ int32_t desktop_srv(void* p) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
view_port_enabled_set(desktop->dummy_mode_icon_viewport, desktop->settings.dummy_mode);
|
|
|
|
|
|
|
|
|
|
desktop_togle_clock_view(desktop, desktop->settings.display_clock);
|
|
|
|
|
|
|
|
|
|
desktop_main_set_dummy_mode_state(desktop->main_view, desktop->settings.dummy_mode);
|
|
|
|
|
animation_manager_set_dummy_mode_state(
|
|
|
|
|
desktop->animation_manager, desktop->settings.dummy_mode);
|
|
|
|
|
|