Merge branch 'ofw_dev' into nfcrefactoring

This commit is contained in:
MX
2023-11-01 21:07:33 +03:00
462 changed files with 2679 additions and 2077 deletions

View File

@@ -2,7 +2,6 @@
#include <stdint.h>
#include <furi.h>
#include <furi_hal.h>
#include <portmacro.h>
#include <dolphin/dolphin.h>
#include <power/power_service/power.h>
#include <storage/storage.h>
@@ -450,13 +449,13 @@ void animation_manager_unload_and_stall_animation(AnimationManager* animation_ma
animation_manager->state = AnimationManagerStateFreezedIdle;
animation_manager->freezed_animation_time_left =
xTimerGetExpiryTime(animation_manager->idle_animation_timer) - xTaskGetTickCount();
furi_timer_get_expire_time(animation_manager->idle_animation_timer) - furi_get_tick();
if(animation_manager->freezed_animation_time_left < 0) {
animation_manager->freezed_animation_time_left = 0;
}
furi_timer_stop(animation_manager->idle_animation_timer);
} else {
furi_assert(0);
furi_crash();
}
FURI_LOG_I(
@@ -528,7 +527,7 @@ void animation_manager_load_and_continue_animation(AnimationManager* animation_m
}
} else {
/* Unknown state is an error. But not in release version.*/
furi_assert(0);
furi_crash();
}
/* if can't restore previous animation - select new */
@@ -564,7 +563,7 @@ static void animation_manager_switch_to_one_shot_view(AnimationManager* animatio
} else if(stats.level == 2) {
one_shot_view_start_animation(animation_manager->one_shot_view, &A_Levelup2_128x64);
} else {
furi_assert(0);
furi_crash();
}
}

View File

@@ -304,7 +304,7 @@ static bool animation_storage_load_frames(
if(file_info.size > max_filesize) {
FURI_LOG_E(
TAG,
"Filesize %lld, max: %d (width %d, height %d)",
"Filesize %llu, max: %zu (width %u, height %u)",
file_info.size,
max_filesize,
width,
@@ -329,7 +329,7 @@ static bool animation_storage_load_frames(
if(!frames_ok) {
FURI_LOG_E(
TAG,
"Load \'%s\' failed, %dx%d, size: %lld",
"Load \'%s\' failed, %ux%u, size: %llu",
furi_string_get_cstr(filename),
width,
height,

View File

@@ -23,7 +23,7 @@ typedef struct {
uint8_t active_bubbles;
uint8_t passive_bubbles;
uint8_t active_shift;
TickType_t active_ended_at;
uint32_t active_ended_at;
Icon* freeze_frame;
} BubbleAnimationViewModel;
@@ -152,7 +152,7 @@ static void bubble_animation_activate(BubbleAnimationView* view, bool force) {
if(model->current != NULL) {
if(!force) {
if((model->active_ended_at + model->current->active_cooldown * 1000) >
xTaskGetTickCount()) {
furi_get_tick()) {
activate = false;
} else if(model->active_shift) {
activate = false;
@@ -213,7 +213,7 @@ static void bubble_animation_next_frame(BubbleAnimationViewModel* model) {
model->active_cycle = 0;
model->current_frame = 0;
model->current_bubble = bubble_animation_pick_bubble(model, false);
model->active_ended_at = xTaskGetTickCount();
model->active_ended_at = furi_get_tick();
}
if(model->current_bubble) {
@@ -353,7 +353,7 @@ void bubble_animation_view_set_animation(
furi_assert(model);
model->current = new_animation;
model->active_ended_at = xTaskGetTickCount() - (model->current->active_cooldown * 1000);
model->active_ended_at = furi_get_tick() - (model->current->active_cooldown * 1000);
model->active_bubbles = 0;
model->passive_bubbles = 0;
for(int i = 0; i < new_animation->frame_bubble_sequences_count; ++i) {

View File

@@ -1,7 +1,6 @@
#include "one_shot_animation_view.h"
#include <furi.h>
#include <portmacro.h>
#include <gui/canvas.h>
#include <gui/view.h>
#include <gui/icon_i.h>
@@ -11,7 +10,7 @@ typedef void (*OneShotInteractCallback)(void*);
struct OneShotView {
View* view;
TimerHandle_t update_timer;
FuriTimer* update_timer;
OneShotInteractCallback interact_callback;
void* interact_callback_context;
};
@@ -22,8 +21,8 @@ typedef struct {
bool block_input;
} OneShotViewModel;
static void one_shot_view_update_timer_callback(TimerHandle_t xTimer) {
OneShotView* view = (void*)pvTimerGetTimerID(xTimer);
static void one_shot_view_update_timer_callback(void* context) {
OneShotView* view = context;
OneShotViewModel* model = view_get_model(view->view);
if((model->index + 1) < model->icon->frame_count) {
@@ -81,7 +80,7 @@ OneShotView* one_shot_view_alloc(void) {
OneShotView* view = malloc(sizeof(OneShotView));
view->view = view_alloc();
view->update_timer =
xTimerCreate(NULL, 1000, pdTRUE, view, one_shot_view_update_timer_callback);
furi_timer_alloc(one_shot_view_update_timer_callback, FuriTimerTypePeriodic, view);
view_allocate_model(view->view, ViewModelTypeLocking, sizeof(OneShotViewModel));
view_set_context(view->view, view);
@@ -94,7 +93,7 @@ OneShotView* one_shot_view_alloc(void) {
void one_shot_view_free(OneShotView* view) {
furi_assert(view);
xTimerDelete(view->update_timer, portMAX_DELAY);
furi_timer_free(view->update_timer);
view_free(view->view);
view->view = NULL;
free(view);
@@ -120,7 +119,7 @@ void one_shot_view_start_animation(OneShotView* view, const Icon* icon) {
model->icon = icon;
model->block_input = true;
view_commit_model(view->view, true);
xTimerChangePeriod(view->update_timer, 1000 / model->icon->frame_rate, portMAX_DELAY);
furi_timer_start(view->update_timer, 1000 / model->icon->frame_rate);
}
View* one_shot_view_get_view(OneShotView* view) {

View File

@@ -3,7 +3,6 @@
#include <gui/scene_manager.h>
#include <gui/view_stack.h>
#include <stdint.h>
#include <portmacro.h>
#include "../desktop.h"
#include "../desktop_i.h"

View File

@@ -3,7 +3,6 @@
#include <gui/scene_manager.h>
#include <gui/view_stack.h>
#include <stdint.h>
#include <portmacro.h>
#include <notification/notification.h>
#include <notification/notification_messages.h>
@@ -20,7 +19,7 @@
#define INPUT_PIN_VIEW_TIMEOUT 15000
typedef struct {
TimerHandle_t timer;
FuriTimer* timer;
} DesktopScenePinInputState;
static void desktop_scene_locked_light_red(bool value) {
@@ -33,17 +32,16 @@ static void desktop_scene_locked_light_red(bool value) {
furi_record_close(RECORD_NOTIFICATION);
}
static void
desktop_scene_pin_input_set_timer(Desktop* desktop, bool enable, TickType_t new_period) {
static void desktop_scene_pin_input_set_timer(Desktop* desktop, bool enable, uint32_t new_period) {
furi_assert(desktop);
DesktopScenePinInputState* state = (DesktopScenePinInputState*)scene_manager_get_scene_state(
desktop->scene_manager, DesktopScenePinInput);
furi_assert(state);
if(enable) {
xTimerChangePeriod(state->timer, new_period, portMAX_DELAY);
furi_timer_start(state->timer, new_period);
} else {
xTimerStop(state->timer, portMAX_DELAY);
furi_timer_stop(state->timer);
}
}
@@ -64,8 +62,8 @@ static void desktop_scene_pin_input_done_callback(const PinCode* pin_code, void*
}
}
static void desktop_scene_pin_input_timer_callback(TimerHandle_t timer) {
Desktop* desktop = pvTimerGetTimerID(timer);
static void desktop_scene_pin_input_timer_callback(void* context) {
Desktop* desktop = context;
view_dispatcher_send_custom_event(
desktop->view_dispatcher, DesktopPinInputEventResetWrongPinLabel);
@@ -84,7 +82,7 @@ void desktop_scene_pin_input_on_enter(void* context) {
DesktopScenePinInputState* state = malloc(sizeof(DesktopScenePinInputState));
state->timer =
xTimerCreate(NULL, 10000, pdFALSE, desktop, desktop_scene_pin_input_timer_callback);
furi_timer_alloc(desktop_scene_pin_input_timer_callback, FuriTimerTypeOnce, desktop);
scene_manager_set_scene_state(desktop->scene_manager, DesktopScenePinInput, (uint32_t)state);
desktop_view_pin_input_hide_pin(desktop->pin_input_view, true);
@@ -149,10 +147,7 @@ void desktop_scene_pin_input_on_exit(void* context) {
DesktopScenePinInputState* state = (DesktopScenePinInputState*)scene_manager_get_scene_state(
desktop->scene_manager, DesktopScenePinInput);
xTimerStop(state->timer, portMAX_DELAY);
while(xTimerIsTimerActive(state->timer)) {
furi_delay_tick(1);
}
xTimerDelete(state->timer, portMAX_DELAY);
furi_timer_free(state->timer);
free(state);
}

View File

@@ -1,6 +1,5 @@
#include <furi.h>
#include <FreeRTOS.h>
#include <portmacro.h>
#include <gui/scene_manager.h>
#include "../desktop_i.h"

View File

@@ -60,13 +60,13 @@ void desktop_lock_menu_draw_callback(Canvas* canvas, void* model) {
str = "Lock";
} else if(i == DesktopLockMenuIndexStealth) {
if(m->stealth_mode) {
str = "Sound Mode";
str = "Unmute";
} else {
str = "Stealth Mode";
str = "Mute";
}
} else if(i == DesktopLockMenuIndexDummy) { //-V547
if(m->dummy_mode) {
str = "Brainiac Mode";
str = "Default Mode";
} else {
str = "Dummy Mode";
}

View File

@@ -5,7 +5,6 @@
#include <gui/icon.h>
#include <gui/view.h>
#include <assets_icons.h>
#include <portmacro.h>
#include <desktop/desktop_settings.h>
#include "../desktop_i.h"
@@ -29,7 +28,7 @@ struct DesktopViewLocked {
DesktopViewLockedCallback callback;
void* context;
TimerHandle_t timer;
FuriTimer* timer;
uint8_t lock_count;
uint32_t lock_lastpress;
};
@@ -58,8 +57,8 @@ void desktop_view_locked_set_callback(
locked_view->context = context;
}
static void locked_view_timer_callback(TimerHandle_t timer) {
DesktopViewLocked* locked_view = pvTimerGetTimerID(timer);
static void locked_view_timer_callback(void* context) {
DesktopViewLocked* locked_view = context;
locked_view->callback(DesktopLockedEventUpdate, locked_view->context);
}
@@ -90,7 +89,7 @@ static void desktop_view_locked_update_hint_icon_timeout(DesktopViewLocked* lock
model->view_state = DesktopViewLockedStateLockedHintShown;
}
view_commit_model(locked_view->view, change_state);
xTimerChangePeriod(locked_view->timer, pdMS_TO_TICKS(LOCKED_HINT_TIMEOUT_MS), portMAX_DELAY);
furi_timer_start(locked_view->timer, LOCKED_HINT_TIMEOUT_MS);
}
void desktop_view_locked_update(DesktopViewLocked* locked_view) {
@@ -110,7 +109,7 @@ void desktop_view_locked_update(DesktopViewLocked* locked_view) {
view_commit_model(locked_view->view, true);
if(view_state != DesktopViewLockedStateDoorsClosing) {
xTimerStop(locked_view->timer, portMAX_DELAY);
furi_timer_stop(locked_view->timer);
}
}
@@ -148,7 +147,7 @@ static bool desktop_view_locked_input(InputEvent* event, void* context) {
furi_assert(context);
bool is_changed = false;
const uint32_t press_time = xTaskGetTickCount();
const uint32_t press_time = furi_get_tick();
DesktopViewLocked* locked_view = context;
DesktopViewLockedModel* model = view_get_model(locked_view->view);
if(model->view_state == DesktopViewLockedStateUnlockedHintShown &&
@@ -196,7 +195,7 @@ DesktopViewLocked* desktop_view_locked_alloc() {
DesktopViewLocked* locked_view = malloc(sizeof(DesktopViewLocked));
locked_view->view = view_alloc();
locked_view->timer =
xTimerCreate(NULL, 1000 / 16, pdTRUE, locked_view, locked_view_timer_callback);
furi_timer_alloc(locked_view_timer_callback, FuriTimerTypePeriodic, locked_view);
view_allocate_model(locked_view->view, ViewModelTypeLocking, sizeof(DesktopViewLockedModel));
view_set_context(locked_view->view, locked_view);
@@ -219,7 +218,7 @@ void desktop_view_locked_close_doors(DesktopViewLocked* locked_view) {
model->view_state = DesktopViewLockedStateDoorsClosing;
model->door_offset = DOOR_OFFSET_START;
view_commit_model(locked_view->view, true);
xTimerChangePeriod(locked_view->timer, pdMS_TO_TICKS(DOOR_MOVING_INTERVAL_MS), portMAX_DELAY);
furi_timer_start(locked_view->timer, DOOR_MOVING_INTERVAL_MS);
}
void desktop_view_locked_lock(DesktopViewLocked* locked_view, bool pin_locked) {
@@ -236,7 +235,7 @@ void desktop_view_locked_unlock(DesktopViewLocked* locked_view) {
model->view_state = DesktopViewLockedStateUnlockedHintShown;
model->pin_locked = false;
view_commit_model(locked_view->view, true);
xTimerChangePeriod(locked_view->timer, pdMS_TO_TICKS(UNLOCKED_HINT_TIMEOUT_MS), portMAX_DELAY);
furi_timer_start(locked_view->timer, UNLOCKED_HINT_TIMEOUT_MS);
}
bool desktop_view_locked_is_locked_hint_visible(DesktopViewLocked* locked_view) {

View File

@@ -13,14 +13,14 @@ struct DesktopMainView {
View* view;
DesktopMainViewCallback callback;
void* context;
TimerHandle_t poweroff_timer;
FuriTimer* poweroff_timer;
bool dummy_mode;
};
#define DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT 1300
static void desktop_main_poweroff_timer_callback(TimerHandle_t timer) {
DesktopMainView* main_view = pvTimerGetTimerID(timer);
static void desktop_main_poweroff_timer_callback(void* context) {
DesktopMainView* main_view = context;
main_view->callback(DesktopMainEventOpenPowerOff, main_view->context);
}
@@ -110,12 +110,9 @@ bool desktop_main_input_callback(InputEvent* event, void* context) {
if(event->key == InputKeyBack) {
if(event->type == InputTypePress) {
xTimerChangePeriod(
main_view->poweroff_timer,
pdMS_TO_TICKS(DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT),
portMAX_DELAY);
furi_timer_start(main_view->poweroff_timer, DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT);
} else if(event->type == InputTypeRelease) {
xTimerStop(main_view->poweroff_timer, portMAX_DELAY);
furi_timer_stop(main_view->poweroff_timer);
}
}
@@ -129,12 +126,8 @@ DesktopMainView* desktop_main_alloc() {
view_set_context(main_view->view, main_view);
view_set_input_callback(main_view->view, desktop_main_input_callback);
main_view->poweroff_timer = xTimerCreate(
NULL,
pdMS_TO_TICKS(DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT),
pdFALSE,
main_view,
desktop_main_poweroff_timer_callback);
main_view->poweroff_timer =
furi_timer_alloc(desktop_main_poweroff_timer_callback, FuriTimerTypeOnce, main_view);
return main_view;
}

View File

@@ -4,7 +4,6 @@
#include <gui/elements.h>
#include <assets_icons.h>
#include <stdint.h>
#include <portmacro.h>
#include "desktop_view_pin_input.h"
#include <desktop/desktop_settings.h>
@@ -21,7 +20,7 @@ struct DesktopViewPinInput {
DesktopViewPinInputCallback timeout_callback;
DesktopViewPinInputDoneCallback done_callback;
void* context;
TimerHandle_t timer;
FuriTimer* timer;
};
typedef struct {
@@ -78,7 +77,7 @@ static bool desktop_view_pin_input_input(InputEvent* event, void* context) {
}
break;
default:
furi_assert(0);
furi_crash();
break;
}
}
@@ -90,7 +89,7 @@ static bool desktop_view_pin_input_input(InputEvent* event, void* context) {
pin_input->back_callback(pin_input->context);
}
xTimerStart(pin_input->timer, 0);
furi_timer_start(pin_input->timer, NO_ACTIVITY_TIMEOUT);
return true;
}
@@ -129,7 +128,7 @@ static void desktop_view_pin_input_draw_cells(Canvas* canvas, DesktopViewPinInpu
canvas_draw_icon_ex(canvas, x + 2, y + 3, &I_Pin_arrow_up_7x9, IconRotation90);
break;
default:
furi_assert(0);
furi_crash();
break;
}
}
@@ -170,8 +169,8 @@ static void desktop_view_pin_input_draw(Canvas* canvas, void* context) {
}
}
void desktop_view_pin_input_timer_callback(TimerHandle_t timer) {
DesktopViewPinInput* pin_input = pvTimerGetTimerID(timer);
void desktop_view_pin_input_timer_callback(void* context) {
DesktopViewPinInput* pin_input = context;
if(pin_input->timeout_callback) {
pin_input->timeout_callback(pin_input->context);
@@ -180,12 +179,12 @@ void desktop_view_pin_input_timer_callback(TimerHandle_t timer) {
static void desktop_view_pin_input_enter(void* context) {
DesktopViewPinInput* pin_input = context;
xTimerStart(pin_input->timer, portMAX_DELAY);
furi_timer_start(pin_input->timer, NO_ACTIVITY_TIMEOUT);
}
static void desktop_view_pin_input_exit(void* context) {
DesktopViewPinInput* pin_input = context;
xTimerStop(pin_input->timer, portMAX_DELAY);
furi_timer_stop(pin_input->timer);
}
DesktopViewPinInput* desktop_view_pin_input_alloc(void) {
@@ -195,12 +194,8 @@ DesktopViewPinInput* desktop_view_pin_input_alloc(void) {
view_set_context(pin_input->view, pin_input);
view_set_draw_callback(pin_input->view, desktop_view_pin_input_draw);
view_set_input_callback(pin_input->view, desktop_view_pin_input_input);
pin_input->timer = xTimerCreate(
NULL,
pdMS_TO_TICKS(NO_ACTIVITY_TIMEOUT),
pdFALSE,
pin_input,
desktop_view_pin_input_timer_callback);
pin_input->timer =
furi_timer_alloc(desktop_view_pin_input_timer_callback, FuriTimerTypeOnce, pin_input);
view_set_enter_callback(pin_input->view, desktop_view_pin_input_enter);
view_set_exit_callback(pin_input->view, desktop_view_pin_input_exit);
@@ -216,11 +211,7 @@ DesktopViewPinInput* desktop_view_pin_input_alloc(void) {
void desktop_view_pin_input_free(DesktopViewPinInput* pin_input) {
furi_assert(pin_input);
xTimerStop(pin_input->timer, portMAX_DELAY);
while(xTimerIsTimerActive(pin_input->timer)) {
furi_delay_tick(1);
}
xTimerDelete(pin_input->timer, portMAX_DELAY);
furi_timer_free(pin_input->timer);
view_free(pin_input->view);
free(pin_input);

View File

@@ -3,7 +3,6 @@
#include <stdint.h>
#include <stdio.h>
#include <FreeRTOS.h>
#include <portmacro.h>
#include <projdefs.h>
#include <input/input.h>
#include <gui/canvas.h>
@@ -13,7 +12,7 @@
struct DesktopViewPinTimeout {
View* view;
TimerHandle_t timer;
FuriTimer* timer;
DesktopViewPinTimeoutDoneCallback callback;
void* context;
};
@@ -32,8 +31,8 @@ void desktop_view_pin_timeout_set_callback(
instance->context = context;
}
static void desktop_view_pin_timeout_timer_callback(TimerHandle_t timer) {
DesktopViewPinTimeout* instance = pvTimerGetTimerID(timer);
static void desktop_view_pin_timeout_timer_callback(void* context) {
DesktopViewPinTimeout* instance = context;
bool stop = false;
DesktopViewPinTimeoutModel* model = view_get_model(instance->view);
@@ -45,7 +44,7 @@ static void desktop_view_pin_timeout_timer_callback(TimerHandle_t timer) {
view_commit_model(instance->view, true);
if(stop) {
xTimerStop(instance->timer, portMAX_DELAY);
furi_timer_stop(instance->timer);
instance->callback(instance->context);
}
}
@@ -73,15 +72,15 @@ static void desktop_view_pin_timeout_draw(Canvas* canvas, void* _model) {
void desktop_view_pin_timeout_free(DesktopViewPinTimeout* instance) {
view_free(instance->view);
xTimerDelete(instance->timer, portMAX_DELAY);
furi_timer_free(instance->timer);
free(instance);
}
DesktopViewPinTimeout* desktop_view_pin_timeout_alloc(void) {
DesktopViewPinTimeout* instance = malloc(sizeof(DesktopViewPinTimeout));
instance->timer = xTimerCreate(
NULL, pdMS_TO_TICKS(1000), pdTRUE, instance, desktop_view_pin_timeout_timer_callback);
instance->timer =
furi_timer_alloc(desktop_view_pin_timeout_timer_callback, FuriTimerTypePeriodic, instance);
instance->view = view_alloc();
view_allocate_model(instance->view, ViewModelTypeLockFree, sizeof(DesktopViewPinTimeoutModel));
@@ -101,7 +100,7 @@ void desktop_view_pin_timeout_start(DesktopViewPinTimeout* instance, uint32_t ti
model->time_left = time_left;
view_commit_model(instance->view, true);
xTimerStart(instance->timer, portMAX_DELAY);
furi_timer_start(instance->timer, 1000);
}
View* desktop_view_pin_timeout_get_view(DesktopViewPinTimeout* instance) {