mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 19:48:35 -07:00
Merge branch 'ofw_dev' into nfcrefactoring
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <furi.h>
|
||||
#include <FreeRTOS.h>
|
||||
#include <portmacro.h>
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
#include "../desktop_i.h"
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "dolphin/dolphin.h"
|
||||
#include "dolphin/helpers/dolphin_state.h"
|
||||
#include "dolphin_i.h"
|
||||
#include "portmacro.h"
|
||||
#include "projdefs.h"
|
||||
#include <furi_hal.h>
|
||||
#include <stdint.h>
|
||||
@@ -45,8 +44,8 @@ void dolphin_flush(Dolphin* dolphin) {
|
||||
dolphin_event_send_wait(dolphin, &event);
|
||||
}
|
||||
|
||||
void dolphin_butthurt_timer_callback(TimerHandle_t xTimer) {
|
||||
Dolphin* dolphin = pvTimerGetTimerID(xTimer);
|
||||
void dolphin_butthurt_timer_callback(void* context) {
|
||||
Dolphin* dolphin = context;
|
||||
furi_assert(dolphin);
|
||||
|
||||
DolphinEvent event;
|
||||
@@ -54,8 +53,8 @@ void dolphin_butthurt_timer_callback(TimerHandle_t xTimer) {
|
||||
dolphin_event_send_async(dolphin, &event);
|
||||
}
|
||||
|
||||
void dolphin_flush_timer_callback(TimerHandle_t xTimer) {
|
||||
Dolphin* dolphin = pvTimerGetTimerID(xTimer);
|
||||
void dolphin_flush_timer_callback(void* context) {
|
||||
Dolphin* dolphin = context;
|
||||
furi_assert(dolphin);
|
||||
|
||||
DolphinEvent event;
|
||||
@@ -63,11 +62,11 @@ void dolphin_flush_timer_callback(TimerHandle_t xTimer) {
|
||||
dolphin_event_send_async(dolphin, &event);
|
||||
}
|
||||
|
||||
void dolphin_clear_limits_timer_callback(TimerHandle_t xTimer) {
|
||||
Dolphin* dolphin = pvTimerGetTimerID(xTimer);
|
||||
void dolphin_clear_limits_timer_callback(void* context) {
|
||||
Dolphin* dolphin = context;
|
||||
furi_assert(dolphin);
|
||||
|
||||
xTimerChangePeriod(dolphin->clear_limits_timer, HOURS_IN_TICKS(24), portMAX_DELAY);
|
||||
furi_timer_start(dolphin->clear_limits_timer, HOURS_IN_TICKS(24));
|
||||
|
||||
DolphinEvent event;
|
||||
event.type = DolphinEventTypeClearLimits;
|
||||
@@ -81,11 +80,11 @@ Dolphin* dolphin_alloc() {
|
||||
dolphin->event_queue = furi_message_queue_alloc(8, sizeof(DolphinEvent));
|
||||
dolphin->pubsub = furi_pubsub_alloc();
|
||||
dolphin->butthurt_timer =
|
||||
xTimerCreate(NULL, HOURS_IN_TICKS(24), pdTRUE, dolphin, dolphin_butthurt_timer_callback);
|
||||
furi_timer_alloc(dolphin_butthurt_timer_callback, FuriTimerTypePeriodic, dolphin);
|
||||
dolphin->flush_timer =
|
||||
xTimerCreate(NULL, 30 * 1000, pdFALSE, dolphin, dolphin_flush_timer_callback);
|
||||
dolphin->clear_limits_timer = xTimerCreate(
|
||||
NULL, HOURS_IN_TICKS(24), pdTRUE, dolphin, dolphin_clear_limits_timer_callback);
|
||||
furi_timer_alloc(dolphin_flush_timer_callback, FuriTimerTypeOnce, dolphin);
|
||||
dolphin->clear_limits_timer =
|
||||
furi_timer_alloc(dolphin_clear_limits_timer_callback, FuriTimerTypePeriodic, dolphin);
|
||||
|
||||
return dolphin;
|
||||
}
|
||||
@@ -125,14 +124,14 @@ FuriPubSub* dolphin_get_pubsub(Dolphin* dolphin) {
|
||||
|
||||
static void dolphin_update_clear_limits_timer_period(Dolphin* dolphin) {
|
||||
furi_assert(dolphin);
|
||||
TickType_t now_ticks = xTaskGetTickCount();
|
||||
TickType_t timer_expires_at = xTimerGetExpiryTime(dolphin->clear_limits_timer);
|
||||
uint32_t now_ticks = furi_get_tick();
|
||||
uint32_t timer_expires_at = furi_timer_get_expire_time(dolphin->clear_limits_timer);
|
||||
|
||||
if((timer_expires_at - now_ticks) > HOURS_IN_TICKS(0.1)) {
|
||||
FuriHalRtcDateTime date;
|
||||
furi_hal_rtc_get_datetime(&date);
|
||||
TickType_t now_time_in_ms = ((date.hour * 60 + date.minute) * 60 + date.second) * 1000;
|
||||
TickType_t time_to_clear_limits = 0;
|
||||
uint32_t now_time_in_ms = ((date.hour * 60 + date.minute) * 60 + date.second) * 1000;
|
||||
uint32_t time_to_clear_limits = 0;
|
||||
|
||||
if(date.hour < 5) {
|
||||
time_to_clear_limits = HOURS_IN_TICKS(5) - now_time_in_ms;
|
||||
@@ -140,7 +139,7 @@ static void dolphin_update_clear_limits_timer_period(Dolphin* dolphin) {
|
||||
time_to_clear_limits = HOURS_IN_TICKS(24 + 5) - now_time_in_ms;
|
||||
}
|
||||
|
||||
xTimerChangePeriod(dolphin->clear_limits_timer, time_to_clear_limits, portMAX_DELAY);
|
||||
furi_timer_start(dolphin->clear_limits_timer, time_to_clear_limits);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,9 +155,9 @@ int32_t dolphin_srv(void* p) {
|
||||
furi_record_create(RECORD_DOLPHIN, dolphin);
|
||||
|
||||
dolphin_state_load(dolphin->state);
|
||||
xTimerReset(dolphin->butthurt_timer, portMAX_DELAY);
|
||||
furi_timer_restart(dolphin->butthurt_timer, HOURS_IN_TICKS(2 * 24));
|
||||
dolphin_update_clear_limits_timer_period(dolphin);
|
||||
xTimerReset(dolphin->clear_limits_timer, portMAX_DELAY);
|
||||
furi_timer_restart(dolphin->clear_limits_timer, HOURS_IN_TICKS(24));
|
||||
|
||||
DolphinEvent event;
|
||||
while(1) {
|
||||
@@ -168,8 +167,8 @@ int32_t dolphin_srv(void* p) {
|
||||
dolphin_state_on_deed(dolphin->state, event.deed);
|
||||
DolphinPubsubEvent event = DolphinPubsubEventUpdate;
|
||||
furi_pubsub_publish(dolphin->pubsub, &event);
|
||||
xTimerReset(dolphin->butthurt_timer, portMAX_DELAY);
|
||||
xTimerReset(dolphin->flush_timer, portMAX_DELAY);
|
||||
furi_timer_restart(dolphin->butthurt_timer, HOURS_IN_TICKS(2 * 24));
|
||||
furi_timer_restart(dolphin->flush_timer, 30 * 1000);
|
||||
} else if(event.type == DolphinEventTypeStats) {
|
||||
event.stats->icounter = dolphin->state->data.icounter;
|
||||
event.stats->butthurt = dolphin->state->data.butthurt;
|
||||
|
||||
@@ -30,9 +30,9 @@ struct Dolphin {
|
||||
// Queue
|
||||
FuriMessageQueue* event_queue;
|
||||
FuriPubSub* pubsub;
|
||||
TimerHandle_t butthurt_timer;
|
||||
TimerHandle_t flush_timer;
|
||||
TimerHandle_t clear_limits_timer;
|
||||
FuriTimer* butthurt_timer;
|
||||
FuriTimer* flush_timer;
|
||||
FuriTimer* clear_limits_timer;
|
||||
};
|
||||
|
||||
Dolphin* dolphin_alloc();
|
||||
|
||||
@@ -143,7 +143,7 @@ void canvas_set_font(Canvas* canvas, Font font) {
|
||||
} else if(font == FontBatteryPercent) {
|
||||
u8g2_SetFont(&canvas->fb, u8g2_font_5x7_tf); //u8g2_font_micro_tr);
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ void canvas_draw_str_aligned(
|
||||
x -= (u8g2_GetStrWidth(&canvas->fb, str) / 2);
|
||||
break;
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ void canvas_draw_str_aligned(
|
||||
y += (u8g2_GetAscent(&canvas->fb) / 2);
|
||||
break;
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -555,7 +555,7 @@ void canvas_set_orientation(Canvas* canvas, CanvasOrientation orientation) {
|
||||
rotate_cb = U8G2_R1;
|
||||
break;
|
||||
default:
|
||||
furi_assert(0);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
if(need_swap) FURI_SWAP(canvas->width, canvas->height);
|
||||
|
||||
@@ -232,7 +232,7 @@ static size_t
|
||||
} else if(horizontal == AlignRight) {
|
||||
px_left = x;
|
||||
} else {
|
||||
furi_assert(0);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
if(len_px > px_left) {
|
||||
|
||||
@@ -15,7 +15,6 @@ IconAnimation* icon_animation_alloc(const Icon* icon) {
|
||||
void icon_animation_free(IconAnimation* instance) {
|
||||
furi_assert(instance);
|
||||
icon_animation_stop(instance);
|
||||
while(xTimerIsTimerActive(instance->timer) == pdTRUE) furi_delay_tick(1);
|
||||
furi_timer_free(instance->timer);
|
||||
free(instance);
|
||||
}
|
||||
@@ -67,10 +66,9 @@ void icon_animation_start(IconAnimation* instance) {
|
||||
instance->animating = true;
|
||||
furi_assert(instance->icon->frame_rate);
|
||||
furi_check(
|
||||
xTimerChangePeriod(
|
||||
furi_timer_start(
|
||||
instance->timer,
|
||||
(furi_kernel_get_tick_frequency() / instance->icon->frame_rate),
|
||||
portMAX_DELAY) == pdPASS);
|
||||
(furi_kernel_get_tick_frequency() / instance->icon->frame_rate)) == FuriStatusOk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +76,7 @@ void icon_animation_stop(IconAnimation* instance) {
|
||||
furi_assert(instance);
|
||||
if(instance->animating) {
|
||||
instance->animating = false;
|
||||
furi_check(xTimerStop(instance->timer, portMAX_DELAY) == pdPASS);
|
||||
furi_timer_stop(instance->timer);
|
||||
instance->frame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ static uint8_t byte_input_get_row_size(uint8_t row_index) {
|
||||
row_size = COUNT_OF(keyboard_keys_row_2);
|
||||
break;
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
return row_size;
|
||||
@@ -102,7 +102,7 @@ static const ByteInputKey* byte_input_get_row(uint8_t row_index) {
|
||||
row = keyboard_keys_row_2;
|
||||
break;
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
return row;
|
||||
|
||||
@@ -98,7 +98,7 @@ void popup_start_timer(void* context) {
|
||||
if(timer_period == 0) timer_period = 1;
|
||||
|
||||
if(furi_timer_start(popup->timer, timer_period) != FuriStatusOk) {
|
||||
furi_assert(0);
|
||||
furi_crash();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ static uint8_t get_row_size(uint8_t row_index) {
|
||||
row_size = COUNT_OF(keyboard_keys_row_3);
|
||||
break;
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
return row_size;
|
||||
@@ -125,7 +125,7 @@ static const TextInputKey* get_row(uint8_t row_index) {
|
||||
row = keyboard_keys_row_3;
|
||||
break;
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
return row;
|
||||
|
||||
@@ -82,7 +82,7 @@ void view_allocate_model(View* view, ViewModelType type, size_t size) {
|
||||
model->data = malloc(size);
|
||||
view->model = model;
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ void view_free_model(View* view) {
|
||||
free(model);
|
||||
view->model = NULL;
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ void view_dispatcher_attach_to_gui(
|
||||
} else if(type == ViewDispatcherTypeFullscreen) {
|
||||
gui_add_view_port(gui, view_dispatcher->view_port, GuiLayerFullscreen);
|
||||
} else {
|
||||
furi_check(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
view_dispatcher->gui = gui;
|
||||
}
|
||||
|
||||
@@ -6,20 +6,6 @@
|
||||
|
||||
static Input* input = NULL;
|
||||
|
||||
inline static void input_timer_start(FuriTimer* timer_id, uint32_t ticks) {
|
||||
TimerHandle_t hTimer = (TimerHandle_t)timer_id;
|
||||
furi_check(xTimerChangePeriod(hTimer, ticks, portMAX_DELAY) == pdPASS);
|
||||
}
|
||||
|
||||
inline static void input_timer_stop(FuriTimer* timer_id) {
|
||||
TimerHandle_t hTimer = (TimerHandle_t)timer_id;
|
||||
furi_check(xTimerStop(hTimer, portMAX_DELAY) == pdPASS);
|
||||
// xTimerStop is not actually stopping timer,
|
||||
// Instead it places stop event into timer queue
|
||||
// This code ensures that timer is stopped
|
||||
while(xTimerIsTimerActive(hTimer) == pdTRUE) furi_delay_tick(1);
|
||||
}
|
||||
|
||||
void input_press_timer_callback(void* arg) {
|
||||
InputPinState* input_pin = arg;
|
||||
InputEvent event;
|
||||
@@ -123,10 +109,12 @@ int32_t input_srv(void* p) {
|
||||
input->counter++;
|
||||
input->pin_states[i].counter = input->counter;
|
||||
event.sequence_counter = input->pin_states[i].counter;
|
||||
input_timer_start(input->pin_states[i].press_timer, INPUT_PRESS_TICKS);
|
||||
furi_timer_start(input->pin_states[i].press_timer, INPUT_PRESS_TICKS);
|
||||
} else {
|
||||
event.sequence_counter = input->pin_states[i].counter;
|
||||
input_timer_stop(input->pin_states[i].press_timer);
|
||||
furi_timer_stop(input->pin_states[i].press_timer);
|
||||
while(furi_timer_is_running(input->pin_states[i].press_timer))
|
||||
furi_delay_tick(1);
|
||||
if(input->pin_states[i].press_counter < INPUT_LONG_PRESS_COUNTS) {
|
||||
event.type = InputTypeShort;
|
||||
furi_pubsub_publish(input->event_pubsub, &event);
|
||||
|
||||
@@ -179,7 +179,7 @@ static FlipperInternalApplication const* loader_find_application_by_name_in_list
|
||||
const FlipperInternalApplication* list,
|
||||
const uint32_t n_apps) {
|
||||
for(size_t i = 0; i < n_apps; i++) {
|
||||
if(strcmp(name, list[i].name) == 0) {
|
||||
if((strcmp(name, list[i].name) == 0) || (strcmp(name, list[i].appid) == 0)) {
|
||||
return &list[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ typedef struct {
|
||||
/**
|
||||
* @brief Start application
|
||||
* @param[in] instance loader instance
|
||||
* @param[in] name application name
|
||||
* @param[in] name application name or id
|
||||
* @param[in] args application arguments
|
||||
* @param[out] error_message detailed error message, can be NULL
|
||||
* @return LoaderStatus
|
||||
@@ -42,7 +42,7 @@ LoaderStatus
|
||||
/**
|
||||
* @brief Start application with GUI error message
|
||||
* @param[in] instance loader instance
|
||||
* @param[in] name application name
|
||||
* @param[in] name application name or id
|
||||
* @param[in] args application arguments
|
||||
* @return LoaderStatus
|
||||
*/
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <storage.pb.h>
|
||||
#include <flipper.pb.h>
|
||||
#include <portmacro.h>
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
@@ -162,7 +161,7 @@ void rpc_session_set_terminated_callback(
|
||||
* odd: client sends close request and sends command after.
|
||||
*/
|
||||
size_t
|
||||
rpc_session_feed(RpcSession* session, uint8_t* encoded_bytes, size_t size, TickType_t timeout) {
|
||||
rpc_session_feed(RpcSession* session, uint8_t* encoded_bytes, size_t size, uint32_t timeout) {
|
||||
furi_assert(session);
|
||||
furi_assert(encoded_bytes);
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ void rpc_session_set_terminated_callback(
|
||||
*
|
||||
* @return actually consumed bytes
|
||||
*/
|
||||
size_t rpc_session_feed(RpcSession* session, uint8_t* buffer, size_t size, TickType_t timeout);
|
||||
size_t rpc_session_feed(RpcSession* session, uint8_t* buffer, size_t size, uint32_t timeout);
|
||||
|
||||
/** Get available size of RPC buffer
|
||||
*
|
||||
|
||||
@@ -62,7 +62,7 @@ static void rpc_system_app_start_process(const PB_Main* request, void* context)
|
||||
} else if(status == LoaderStatusOk) {
|
||||
result = PB_CommandStatus_OK;
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
} else {
|
||||
result = PB_CommandStatus_ERROR_INVALID_PARAMETERS;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <furi.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <furi_hal.h>
|
||||
#include <semphr.h>
|
||||
|
||||
#define TAG "RpcCli"
|
||||
|
||||
|
||||
@@ -333,11 +333,9 @@ static void storage_cli_write_chunk(Cli* cli, FuriString* path, FuriString* args
|
||||
if(buffer_size) {
|
||||
uint8_t* buffer = malloc(buffer_size);
|
||||
|
||||
for(uint32_t i = 0; i < buffer_size; i++) {
|
||||
buffer[i] = cli_getc(cli);
|
||||
}
|
||||
size_t read_bytes = cli_read(cli, buffer, buffer_size);
|
||||
|
||||
uint16_t written_size = storage_file_write(file, buffer, buffer_size);
|
||||
uint16_t written_size = storage_file_write(file, buffer, read_bytes);
|
||||
|
||||
if(written_size != buffer_size) {
|
||||
storage_cli_print_error(storage_file_get_error(file));
|
||||
|
||||
Reference in New Issue
Block a user