mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-30 08:20:21 +00:00
Merge remote-tracking branch 'OFW/dev' into dev
This commit is contained in:
commit
f02b03172a
4 changed files with 55 additions and 1 deletions
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
FuriTimer* timer;
|
FuriTimer* timer;
|
||||||
|
FuriString* enter_pin_string;
|
||||||
} DesktopScenePinInputState;
|
} DesktopScenePinInputState;
|
||||||
|
|
||||||
static void desktop_scene_locked_light_red(bool value) {
|
static void desktop_scene_locked_light_red(bool value) {
|
||||||
|
@ -69,6 +70,18 @@ static void desktop_scene_pin_input_timer_callback(void* context) {
|
||||||
desktop->view_dispatcher, DesktopPinInputEventResetWrongPinLabel);
|
desktop->view_dispatcher, DesktopPinInputEventResetWrongPinLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
desktop_scene_pin_input_update_wrong_count(DesktopScenePinInputState* state, Desktop* desktop) {
|
||||||
|
uint32_t attempts = furi_hal_rtc_get_pin_fails();
|
||||||
|
if(attempts > 0) {
|
||||||
|
furi_string_printf(state->enter_pin_string, "Wrong Attempts: %lu", attempts);
|
||||||
|
desktop_view_pin_input_set_label_tertiary(
|
||||||
|
desktop->pin_input_view, 64, 60, furi_string_get_cstr(state->enter_pin_string));
|
||||||
|
} else {
|
||||||
|
desktop_view_pin_input_set_label_tertiary(desktop->pin_input_view, 64, 60, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void desktop_scene_pin_input_on_enter(void* context) {
|
void desktop_scene_pin_input_on_enter(void* context) {
|
||||||
Desktop* desktop = (Desktop*)context;
|
Desktop* desktop = (Desktop*)context;
|
||||||
|
|
||||||
|
@ -81,6 +94,7 @@ void desktop_scene_pin_input_on_enter(void* context) {
|
||||||
desktop->pin_input_view, desktop_scene_pin_input_done_callback);
|
desktop->pin_input_view, desktop_scene_pin_input_done_callback);
|
||||||
|
|
||||||
DesktopScenePinInputState* state = malloc(sizeof(DesktopScenePinInputState));
|
DesktopScenePinInputState* state = malloc(sizeof(DesktopScenePinInputState));
|
||||||
|
state->enter_pin_string = furi_string_alloc();
|
||||||
state->timer =
|
state->timer =
|
||||||
furi_timer_alloc(desktop_scene_pin_input_timer_callback, FuriTimerTypeOnce, desktop);
|
furi_timer_alloc(desktop_scene_pin_input_timer_callback, FuriTimerTypeOnce, desktop);
|
||||||
scene_manager_set_scene_state(desktop->scene_manager, DesktopScenePinInput, (uint32_t)state);
|
scene_manager_set_scene_state(desktop->scene_manager, DesktopScenePinInput, (uint32_t)state);
|
||||||
|
@ -88,6 +102,7 @@ void desktop_scene_pin_input_on_enter(void* context) {
|
||||||
desktop_view_pin_input_hide_pin(desktop->pin_input_view, true);
|
desktop_view_pin_input_hide_pin(desktop->pin_input_view, true);
|
||||||
desktop_view_pin_input_set_label_button(desktop->pin_input_view, "OK");
|
desktop_view_pin_input_set_label_button(desktop->pin_input_view, "OK");
|
||||||
desktop_view_pin_input_set_label_secondary(desktop->pin_input_view, 44, 25, "Enter PIN:");
|
desktop_view_pin_input_set_label_secondary(desktop->pin_input_view, 44, 25, "Enter PIN:");
|
||||||
|
desktop_scene_pin_input_update_wrong_count(state, desktop);
|
||||||
desktop_view_pin_input_set_pin_position(desktop->pin_input_view, 64, 37);
|
desktop_view_pin_input_set_pin_position(desktop->pin_input_view, 64, 37);
|
||||||
desktop_view_pin_input_reset_pin(desktop->pin_input_view);
|
desktop_view_pin_input_reset_pin(desktop->pin_input_view);
|
||||||
|
|
||||||
|
@ -98,7 +113,8 @@ bool desktop_scene_pin_input_on_event(void* context, SceneManagerEvent event) {
|
||||||
Desktop* desktop = (Desktop*)context;
|
Desktop* desktop = (Desktop*)context;
|
||||||
bool consumed = false;
|
bool consumed = false;
|
||||||
uint32_t pin_timeout = 0;
|
uint32_t pin_timeout = 0;
|
||||||
|
DesktopScenePinInputState* state = (DesktopScenePinInputState*)scene_manager_get_scene_state(
|
||||||
|
desktop->scene_manager, DesktopScenePinInput);
|
||||||
if(event.type == SceneManagerEventTypeCustom) {
|
if(event.type == SceneManagerEventTypeCustom) {
|
||||||
switch(event.event) {
|
switch(event.event) {
|
||||||
case DesktopPinInputEventUnlockFailed:
|
case DesktopPinInputEventUnlockFailed:
|
||||||
|
@ -114,6 +130,7 @@ bool desktop_scene_pin_input_on_event(void* context, SceneManagerEvent event) {
|
||||||
desktop_view_pin_input_set_label_secondary(
|
desktop_view_pin_input_set_label_secondary(
|
||||||
desktop->pin_input_view, 25, 25, "Wrong PIN try again:");
|
desktop->pin_input_view, 25, 25, "Wrong PIN try again:");
|
||||||
desktop_scene_pin_input_set_timer(desktop, true, WRONG_PIN_HEADER_TIMEOUT);
|
desktop_scene_pin_input_set_timer(desktop, true, WRONG_PIN_HEADER_TIMEOUT);
|
||||||
|
desktop_scene_pin_input_update_wrong_count(state, desktop);
|
||||||
desktop_view_pin_input_reset_pin(desktop->pin_input_view);
|
desktop_view_pin_input_reset_pin(desktop->pin_input_view);
|
||||||
}
|
}
|
||||||
consumed = true;
|
consumed = true;
|
||||||
|
@ -123,6 +140,7 @@ bool desktop_scene_pin_input_on_event(void* context, SceneManagerEvent event) {
|
||||||
desktop_view_pin_input_set_label_primary(desktop->pin_input_view, 0, 0, NULL);
|
desktop_view_pin_input_set_label_primary(desktop->pin_input_view, 0, 0, NULL);
|
||||||
desktop_view_pin_input_set_label_secondary(
|
desktop_view_pin_input_set_label_secondary(
|
||||||
desktop->pin_input_view, 44, 25, "Enter PIN:");
|
desktop->pin_input_view, 44, 25, "Enter PIN:");
|
||||||
|
desktop_scene_pin_input_update_wrong_count(state, desktop);
|
||||||
consumed = true;
|
consumed = true;
|
||||||
break;
|
break;
|
||||||
case DesktopPinInputEventUnlocked:
|
case DesktopPinInputEventUnlocked:
|
||||||
|
@ -150,5 +168,6 @@ void desktop_scene_pin_input_on_exit(void* context) {
|
||||||
desktop->scene_manager, DesktopScenePinInput);
|
desktop->scene_manager, DesktopScenePinInput);
|
||||||
|
|
||||||
furi_timer_free(state->timer);
|
furi_timer_free(state->timer);
|
||||||
|
furi_string_free(state->enter_pin_string);
|
||||||
free(state);
|
free(state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,9 @@ typedef struct {
|
||||||
const char* secondary_str;
|
const char* secondary_str;
|
||||||
uint8_t secondary_str_x;
|
uint8_t secondary_str_x;
|
||||||
uint8_t secondary_str_y;
|
uint8_t secondary_str_y;
|
||||||
|
const char* tertiary_str;
|
||||||
|
uint8_t tertiary_str_x;
|
||||||
|
uint8_t tertiary_str_y;
|
||||||
const char* button_label;
|
const char* button_label;
|
||||||
} DesktopViewPinInputModel;
|
} DesktopViewPinInputModel;
|
||||||
|
|
||||||
|
@ -167,6 +170,17 @@ static void desktop_view_pin_input_draw(Canvas* canvas, void* context) {
|
||||||
canvas_draw_str(
|
canvas_draw_str(
|
||||||
canvas, model->secondary_str_x, model->secondary_str_y, model->secondary_str);
|
canvas, model->secondary_str_x, model->secondary_str_y, model->secondary_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(model->tertiary_str && model->pin.length == 0) {
|
||||||
|
canvas_set_font(canvas, FontSecondary);
|
||||||
|
canvas_draw_str_aligned(
|
||||||
|
canvas,
|
||||||
|
model->tertiary_str_x,
|
||||||
|
model->tertiary_str_y,
|
||||||
|
AlignCenter,
|
||||||
|
AlignBottom,
|
||||||
|
model->tertiary_str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void desktop_view_pin_input_timer_callback(void* context) {
|
void desktop_view_pin_input_timer_callback(void* context) {
|
||||||
|
@ -294,6 +308,20 @@ void desktop_view_pin_input_set_label_secondary(
|
||||||
view_commit_model(pin_input->view, true);
|
view_commit_model(pin_input->view, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void desktop_view_pin_input_set_label_tertiary(
|
||||||
|
DesktopViewPinInput* pin_input,
|
||||||
|
uint8_t x,
|
||||||
|
uint8_t y,
|
||||||
|
const char* label) {
|
||||||
|
furi_assert(pin_input);
|
||||||
|
|
||||||
|
DesktopViewPinInputModel* model = view_get_model(pin_input->view);
|
||||||
|
model->tertiary_str = label;
|
||||||
|
model->tertiary_str_x = x;
|
||||||
|
model->tertiary_str_y = y;
|
||||||
|
view_commit_model(pin_input->view, true);
|
||||||
|
}
|
||||||
|
|
||||||
void desktop_view_pin_input_set_pin_position(DesktopViewPinInput* pin_input, uint8_t x, uint8_t y) {
|
void desktop_view_pin_input_set_pin_position(DesktopViewPinInput* pin_input, uint8_t x, uint8_t y) {
|
||||||
furi_assert(pin_input);
|
furi_assert(pin_input);
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,11 @@ void desktop_view_pin_input_set_label_secondary(
|
||||||
uint8_t x,
|
uint8_t x,
|
||||||
uint8_t y,
|
uint8_t y,
|
||||||
const char* label);
|
const char* label);
|
||||||
|
void desktop_view_pin_input_set_label_tertiary(
|
||||||
|
DesktopViewPinInput* pin_input,
|
||||||
|
uint8_t x,
|
||||||
|
uint8_t y,
|
||||||
|
const char* label);
|
||||||
void desktop_view_pin_input_set_pin_position(DesktopViewPinInput* pin_input, uint8_t x, uint8_t y);
|
void desktop_view_pin_input_set_pin_position(DesktopViewPinInput* pin_input, uint8_t x, uint8_t y);
|
||||||
View* desktop_view_pin_input_get_view(DesktopViewPinInput*);
|
View* desktop_view_pin_input_get_view(DesktopViewPinInput*);
|
||||||
void desktop_view_pin_input_set_done_callback(
|
void desktop_view_pin_input_set_done_callback(
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include <furi_hal_infrared.h>
|
#include <furi_hal_infrared.h>
|
||||||
#include <infrared.h>
|
#include <infrared.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
Loading…
Reference in a new issue