Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into release-candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
skotopes committed Jun 13, 2022
2 parents 84cc381 + cc861dd commit ae95d75
Show file tree
Hide file tree
Showing 32 changed files with 284 additions and 83 deletions.
5 changes: 3 additions & 2 deletions applications/desktop/desktop_settings/desktop_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stdbool.h>
#include <toolbox/saved_struct.h>

#define DESKTOP_SETTINGS_VER (3)
#define DESKTOP_SETTINGS_VER (4)
#define DESKTOP_SETTINGS_PATH "/int/desktop.settings"
#define DESKTOP_SETTINGS_MAGIC (0x17)
#define PIN_MAX_LENGTH 12
Expand Down Expand Up @@ -37,7 +37,8 @@ typedef struct {
} PinCode;

typedef struct {
uint16_t favorite;
uint16_t favorite_primary;
uint16_t favorite_secondary;
PinCode pin_code;
uint8_t is_locked;
uint32_t auto_lock_delay_ms;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@ typedef struct {
bool pincode_buffer_filled;

uint8_t menu_idx;

} DesktopSettingsApp;
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,35 @@ void desktop_settings_scene_favorite_on_enter(void* context) {
app);
}

submenu_set_header(app->submenu, "Quick access app:");
submenu_set_selected_item(app->submenu, app->settings.favorite);
uint32_t primary_favorite =
scene_manager_get_scene_state(app->scene_manager, DesktopSettingsAppSceneFavorite);

submenu_set_header(
app->submenu, primary_favorite ? "Primary favorite app:" : "Secondary favorite app:");

if(primary_favorite) {
submenu_set_selected_item(app->submenu, app->settings.favorite_primary);
} else {
submenu_set_selected_item(app->submenu, app->settings.favorite_secondary);
}
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewMenu);
}

bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent event) {
DesktopSettingsApp* app = context;
bool consumed = false;

uint32_t primary_favorite =
scene_manager_get_scene_state(app->scene_manager, DesktopSettingsAppSceneFavorite);

if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) {
default:
app->settings.favorite = event.event;
scene_manager_previous_scene(app->scene_manager);
consumed = true;
break;
if(primary_favorite) {
app->settings.favorite_primary = event.event;
} else {
app->settings.favorite_secondary = event.event;
}
scene_manager_previous_scene(app->scene_manager);
consumed = true;
}
return consumed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
#include "../desktop_settings_app.h"
#include "desktop_settings_scene.h"

#define SCENE_EVENT_SELECT_FAVORITE 0
#define SCENE_EVENT_SELECT_PIN_SETUP 1
#define SCENE_EVENT_SELECT_AUTO_LOCK_DELAY 2
#define SCENE_EVENT_SELECT_FAVORITE_PRIMARY 0
#define SCENE_EVENT_SELECT_FAVORITE_SECONDARY 1
#define SCENE_EVENT_SELECT_PIN_SETUP 2
#define SCENE_EVENT_SELECT_AUTO_LOCK_DELAY 3

#define AUTO_LOCK_DELAY_COUNT 6
const char* const auto_lock_delay_text[AUTO_LOCK_DELAY_COUNT] = {
Expand Down Expand Up @@ -41,7 +42,9 @@ void desktop_settings_scene_start_on_enter(void* context) {
VariableItem* item;
uint8_t value_index;

variable_item_list_add(variable_item_list, "Favorite App", 1, NULL, NULL);
variable_item_list_add(variable_item_list, "Primary Favorite App", 1, NULL, NULL);

variable_item_list_add(variable_item_list, "Secondary Favorite App", 1, NULL, NULL);

variable_item_list_add(variable_item_list, "PIN Setup", 1, NULL, NULL);

Expand All @@ -68,7 +71,13 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even

if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) {
case SCENE_EVENT_SELECT_FAVORITE:
case SCENE_EVENT_SELECT_FAVORITE_PRIMARY:
scene_manager_set_scene_state(app->scene_manager, DesktopSettingsAppSceneFavorite, 1);
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
consumed = true;
break;
case SCENE_EVENT_SELECT_FAVORITE_SECONDARY:
scene_manager_set_scene_state(app->scene_manager, DesktopSettingsAppSceneFavorite, 0);
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
consumed = true;
break;
Expand Down
32 changes: 28 additions & 4 deletions applications/desktop/scenes/desktop_scene_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,40 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
consumed = true;
break;

case DesktopMainEventOpenFavorite:
case DesktopMainEventOpenPowerOff: {
LoaderStatus status = loader_start(desktop->loader, "Power", "off");
if(status != LoaderStatusOk) {
FURI_LOG_E(TAG, "loader_start failed: %d", status);
}
consumed = true;
break;
}

case DesktopMainEventOpenFavoritePrimary:
LOAD_DESKTOP_SETTINGS(&desktop->settings);
if(desktop->settings.favorite_primary < FLIPPER_APPS_COUNT) {
LoaderStatus status = loader_start(
desktop->loader, FLIPPER_APPS[desktop->settings.favorite_primary].name, NULL);
if(status != LoaderStatusOk) {
FURI_LOG_E(TAG, "loader_start failed: %d", status);
}
} else {
FURI_LOG_E(TAG, "Can't find primary favorite application");
}
consumed = true;
break;
case DesktopMainEventOpenFavoriteSecondary:
LOAD_DESKTOP_SETTINGS(&desktop->settings);
if(desktop->settings.favorite < FLIPPER_APPS_COUNT) {
if(desktop->settings.favorite_secondary < FLIPPER_APPS_COUNT) {
LoaderStatus status = loader_start(
desktop->loader, FLIPPER_APPS[desktop->settings.favorite].name, NULL);
desktop->loader,
FLIPPER_APPS[desktop->settings.favorite_secondary].name,
NULL);
if(status != LoaderStatusOk) {
FURI_LOG_E(TAG, "loader_start failed: %d", status);
}
} else {
FURI_LOG_E(TAG, "Can't find favorite application");
FURI_LOG_E(TAG, "Can't find secondary favorite application");
}
consumed = true;
break;
Expand Down
4 changes: 3 additions & 1 deletion applications/desktop/views/desktop_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
typedef enum {
DesktopMainEventOpenLockMenu,
DesktopMainEventOpenArchive,
DesktopMainEventOpenFavorite,
DesktopMainEventOpenFavoritePrimary,
DesktopMainEventOpenFavoriteSecondary,
DesktopMainEventOpenMenu,
DesktopMainEventOpenDebug,
DesktopMainEventOpenPassport, /**< Broken, don't use it */
DesktopMainEventOpenPowerOff,

DesktopLockedEventUnlocked,
DesktopLockedEventUpdate,
Expand Down
31 changes: 30 additions & 1 deletion applications/desktop/views/desktop_view_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ struct DesktopMainView {
View* view;
DesktopMainViewCallback callback;
void* context;
TimerHandle_t poweroff_timer;
};

#define DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT 5000

static void desktop_main_poweroff_timer_callback(TimerHandle_t timer) {
DesktopMainView* main_view = pvTimerGetTimerID(timer);
main_view->callback(DesktopMainEventOpenPowerOff, main_view->context);
}

void desktop_main_set_callback(
DesktopMainView* main_view,
DesktopMainViewCallback callback,
Expand Down Expand Up @@ -44,13 +52,26 @@ bool desktop_main_input(InputEvent* event, void* context) {
} else if(event->key == InputKeyDown) {
main_view->callback(DesktopMainEventOpenArchive, main_view->context);
} else if(event->key == InputKeyLeft) {
main_view->callback(DesktopMainEventOpenFavorite, main_view->context);
main_view->callback(DesktopMainEventOpenFavoritePrimary, main_view->context);
} else if(event->key == InputKeyRight) {
main_view->callback(DesktopMainEventOpenPassport, main_view->context);
}
} else if(event->type == InputTypeLong) {
if(event->key == InputKeyDown) {
main_view->callback(DesktopMainEventOpenDebug, main_view->context);
} else if(event->key == InputKeyLeft) {
main_view->callback(DesktopMainEventOpenFavoriteSecondary, main_view->context);
}
}

if(event->key == InputKeyBack) {
if(event->type == InputTypePress) {
xTimerChangePeriod(
main_view->poweroff_timer,
pdMS_TO_TICKS(DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT),
portMAX_DELAY);
} else if(event->type == InputTypeRelease) {
xTimerStop(main_view->poweroff_timer, portMAX_DELAY);
}
}

Expand All @@ -65,11 +86,19 @@ DesktopMainView* desktop_main_alloc() {
view_set_context(main_view->view, main_view);
view_set_input_callback(main_view->view, desktop_main_input);

main_view->poweroff_timer = xTimerCreate(
NULL,
pdMS_TO_TICKS(DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT),
pdFALSE,
main_view,
desktop_main_poweroff_timer_callback);

return main_view;
}

void desktop_main_free(DesktopMainView* main_view) {
furi_assert(main_view);
view_free(main_view->view);
osTimerDelete(main_view->poweroff_timer);
free(main_view);
}
37 changes: 34 additions & 3 deletions applications/ibutton/ibutton.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,47 @@
#include <toolbox/path.h>
#include <flipper_format/flipper_format.h>

static const NotificationSequence sequence_blink_start_cyan = {
&message_blink_start_10,
&message_blink_set_color_cyan,
&message_do_not_reset,
NULL,
};

static const NotificationSequence sequence_blink_start_magenta = {
&message_blink_start_10,
&message_blink_set_color_magenta,
&message_do_not_reset,
NULL,
};

static const NotificationSequence sequence_blink_set_yellow = {
&message_blink_set_color_yellow,
NULL,
};

static const NotificationSequence sequence_blink_set_magenta = {
&message_blink_set_color_magenta,
NULL,
};

static const NotificationSequence sequence_blink_stop = {
&message_blink_stop,
NULL,
};

static const NotificationSequence* ibutton_notification_sequences[] = {
&sequence_error,
&sequence_success,
&sequence_blink_cyan_10,
&sequence_blink_magenta_10,
&sequence_blink_yellow_10,
&sequence_blink_start_cyan,
&sequence_blink_start_magenta,
&sequence_blink_set_yellow,
&sequence_blink_set_magenta,
&sequence_set_red_255,
&sequence_reset_red,
&sequence_set_green_255,
&sequence_reset_green,
&sequence_blink_stop,
};

static void ibutton_make_app_folder(iButton* ibutton) {
Expand Down
6 changes: 4 additions & 2 deletions applications/ibutton/ibutton_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ typedef enum {
typedef enum {
iButtonNotificationMessageError,
iButtonNotificationMessageSuccess,
iButtonNotificationMessageRead,
iButtonNotificationMessageEmulate,
iButtonNotificationMessageReadStart,
iButtonNotificationMessageEmulateStart,
iButtonNotificationMessageYellowBlink,
iButtonNotificationMessageEmulateBlink,
iButtonNotificationMessageRedOn,
iButtonNotificationMessageRedOff,
iButtonNotificationMessageGreenOn,
iButtonNotificationMessageGreenOff,
iButtonNotificationMessageBlinkStop,
} iButtonNotificationMessage;

bool ibutton_file_select(iButton* ibutton);
Expand Down
5 changes: 4 additions & 1 deletion applications/ibutton/scenes/ibutton_scene_emulate.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "../ibutton_i.h"
#include "furi/log.h"
#include <dolphin/dolphin.h>
#include <toolbox/path.h>

Expand Down Expand Up @@ -85,6 +86,8 @@ void ibutton_scene_emulate_on_enter(void* context) {
ibutton_worker_emulate_start(ibutton->key_worker, key);

string_clear(key_name);

ibutton_notification_message(ibutton, iButtonNotificationMessageEmulateStart);
}

bool ibutton_scene_emulate_on_event(void* context, SceneManagerEvent event) {
Expand All @@ -93,7 +96,6 @@ bool ibutton_scene_emulate_on_event(void* context, SceneManagerEvent event) {

if(event.type == SceneManagerEventTypeTick) {
consumed = true;
ibutton_notification_message(ibutton, iButtonNotificationMessageEmulate);
} else if(event.type == SceneManagerEventTypeCustom) {
consumed = true;
if(event.event == iButtonCustomEventWorkerEmulated) {
Expand All @@ -111,4 +113,5 @@ void ibutton_scene_emulate_on_exit(void* context) {
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
popup_set_icon(popup, 0, 0, NULL);
ibutton_notification_message(ibutton, iButtonNotificationMessageBlinkStop);
}
5 changes: 4 additions & 1 deletion applications/ibutton/scenes/ibutton_scene_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ void ibutton_scene_read_on_enter(void* context) {

ibutton_worker_read_set_callback(worker, ibutton_scene_read_callback, ibutton);
ibutton_worker_read_start(worker, key);

ibutton_notification_message(ibutton, iButtonNotificationMessageReadStart);
}

bool ibutton_scene_read_on_event(void* context, SceneManagerEvent event) {
Expand All @@ -31,7 +33,6 @@ bool ibutton_scene_read_on_event(void* context, SceneManagerEvent event) {

if(event.type == SceneManagerEventTypeTick) {
consumed = true;
ibutton_notification_message(ibutton, iButtonNotificationMessageRead);
} else if(event.type == SceneManagerEventTypeCustom) {
consumed = true;
if(event.event == iButtonCustomEventWorkerRead) {
Expand Down Expand Up @@ -69,4 +70,6 @@ void ibutton_scene_read_on_exit(void* context) {
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
popup_set_icon(popup, 0, 0, NULL);

ibutton_notification_message(ibutton, iButtonNotificationMessageBlinkStop);
}
Loading

0 comments on commit ae95d75

Please sign in to comment.