mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-11-23 10:01:58 +03:00
Merge remote-tracking branch 'OFW/dev' into dev
This commit is contained in:
commit
96db11a0d6
@ -61,11 +61,11 @@ static void desktop_clock_update(Desktop* desktop) {
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
bool time_format_12 = locale_get_time_format() == LocaleTimeFormat12h;
|
||||
|
||||
if(desktop->time_hour != curr_dt.hour || desktop->time_minute != curr_dt.minute ||
|
||||
desktop->time_format_12 != time_format_12) {
|
||||
desktop->time_format_12 = time_format_12;
|
||||
desktop->time_hour = curr_dt.hour;
|
||||
desktop->time_minute = curr_dt.minute;
|
||||
if(desktop->clock.hour != curr_dt.hour || desktop->clock.minute != curr_dt.minute ||
|
||||
desktop->clock.format_12 != time_format_12) {
|
||||
desktop->clock.format_12 = time_format_12;
|
||||
desktop->clock.hour = curr_dt.hour;
|
||||
desktop->clock.minute = curr_dt.minute;
|
||||
view_port_update(desktop->clock_viewport);
|
||||
}
|
||||
}
|
||||
@ -92,8 +92,8 @@ static void desktop_clock_draw_callback(Canvas* canvas, void* context) {
|
||||
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
|
||||
uint8_t hour = desktop->time_hour;
|
||||
if(desktop->time_format_12) {
|
||||
uint8_t hour = desktop->clock.hour;
|
||||
if(desktop->clock.format_12) {
|
||||
if(hour > 12) {
|
||||
hour -= 12;
|
||||
}
|
||||
@ -103,11 +103,11 @@ static void desktop_clock_draw_callback(Canvas* canvas, void* context) {
|
||||
}
|
||||
|
||||
char buffer[20];
|
||||
snprintf(buffer, sizeof(buffer), "%02u:%02u", hour, desktop->time_minute);
|
||||
snprintf(buffer, sizeof(buffer), "%02u:%02u", hour, desktop->clock.minute);
|
||||
|
||||
view_port_set_width(
|
||||
desktop->clock_viewport,
|
||||
canvas_string_width(canvas, buffer) - 1 + (desktop->time_minute % 10 == 1));
|
||||
canvas_string_width(canvas, buffer) - 1 + (desktop->clock.minute % 10 == 1));
|
||||
|
||||
canvas_draw_str_aligned(canvas, 0, 8, AlignLeft, AlignBottom, buffer);
|
||||
}
|
||||
@ -140,7 +140,7 @@ static bool desktop_custom_event_callback(void* context, uint32_t event) {
|
||||
}
|
||||
return true;
|
||||
case DesktopGlobalAutoLock:
|
||||
if(!loader_is_locked(desktop->loader)) {
|
||||
if(!loader_is_locked(desktop->loader) && !desktop->locked) {
|
||||
desktop_lock(desktop);
|
||||
}
|
||||
return true;
|
||||
@ -216,6 +216,8 @@ static void desktop_clock_timer_callback(void* context) {
|
||||
}
|
||||
|
||||
void desktop_lock(Desktop* desktop) {
|
||||
furi_assert(!desktop->locked);
|
||||
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagLock);
|
||||
|
||||
if(desktop->settings.pin_code.length) {
|
||||
@ -231,9 +233,13 @@ void desktop_lock(Desktop* desktop) {
|
||||
|
||||
DesktopStatus status = {.locked = true};
|
||||
furi_pubsub_publish(desktop->status_pubsub, &status);
|
||||
|
||||
desktop->locked = true;
|
||||
}
|
||||
|
||||
void desktop_unlock(Desktop* desktop) {
|
||||
furi_assert(desktop->locked);
|
||||
|
||||
view_port_enabled_set(desktop->lock_icon_viewport, false);
|
||||
Gui* gui = furi_record_open(RECORD_GUI);
|
||||
gui_set_lockdown(gui, false);
|
||||
@ -252,6 +258,8 @@ void desktop_unlock(Desktop* desktop) {
|
||||
|
||||
DesktopStatus status = {.locked = false};
|
||||
furi_pubsub_publish(desktop->status_pubsub, &status);
|
||||
|
||||
desktop->locked = false;
|
||||
}
|
||||
|
||||
void desktop_set_dummy_mode_state(Desktop* desktop, bool enabled) {
|
||||
|
@ -35,6 +35,12 @@ typedef enum {
|
||||
DesktopViewIdTotal,
|
||||
} DesktopViewId;
|
||||
|
||||
typedef struct {
|
||||
uint8_t hour;
|
||||
uint8_t minute;
|
||||
bool format_12; // 1 - 12 hour, 0 - 24H
|
||||
} DesktopClock;
|
||||
|
||||
struct Desktop {
|
||||
// Scene
|
||||
FuriThread* scene_thread;
|
||||
@ -75,11 +81,10 @@ struct Desktop {
|
||||
|
||||
FuriPubSub* status_pubsub;
|
||||
|
||||
uint8_t time_hour;
|
||||
uint8_t time_minute;
|
||||
bool time_format_12 : 1; // 1 - 12 hour, 0 - 24H
|
||||
DesktopClock clock;
|
||||
|
||||
bool in_transition : 1;
|
||||
bool locked : 1;
|
||||
|
||||
FuriSemaphore* animation_semaphore;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user