Furi, FuriHal: remove FreeRTOS headers leaks (#3179)
* Furi: remove direct FreeRTOS timers use * Furi: eliminate FreeRTOS headers leak. What did it cost? Everything... * SubGhz: proper public api for protocols. Format Sources. * Furi: slightly less redundant declarations * Desktop: proper types in printf * Sync API Symbols * Furi: add timer reset and fix dolphin service, fix unit tests * Furi: proper timer restart method naming and correct behavior in timer stopped state. --------- Co-authored-by: hedger <hedger@nanode.su>
This commit is contained in:
@@ -71,7 +71,7 @@ static void direct_draw_run(DirectDraw* instance) {
|
||||
size_t counter = 0;
|
||||
float fps = 0;
|
||||
|
||||
vTaskPrioritySet(furi_thread_get_current_id(), FuriThreadPriorityIdle);
|
||||
furi_thread_set_current_priority(FuriThreadPriorityIdle);
|
||||
|
||||
do {
|
||||
size_t elapsed = DWT->CYCCNT - start;
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include <cli/cli.h>
|
||||
#include <loader/loader.h>
|
||||
#include <protobuf_version.h>
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include <semphr.h>
|
||||
|
||||
LIST_DEF(MsgList, PB_Main, M_POD_OPLIST)
|
||||
@@ -36,7 +38,7 @@ typedef struct {
|
||||
FuriStreamBuffer* output_stream;
|
||||
SemaphoreHandle_t close_session_semaphore;
|
||||
SemaphoreHandle_t terminate_semaphore;
|
||||
TickType_t timeout;
|
||||
uint32_t timeout;
|
||||
} RpcSessionContext;
|
||||
|
||||
static RpcSessionContext rpc_session[TEST_RPC_SESSIONS];
|
||||
@@ -544,7 +546,7 @@ static bool test_rpc_pb_stream_read(pb_istream_t* istream, pb_byte_t* buf, size_
|
||||
RpcSessionContext* session_context = istream->state;
|
||||
size_t bytes_received = 0;
|
||||
|
||||
TickType_t now = xTaskGetTickCount();
|
||||
uint32_t now = furi_get_tick();
|
||||
int32_t time_left = session_context->timeout - now;
|
||||
time_left = MAX(time_left, 0);
|
||||
bytes_received =
|
||||
@@ -688,7 +690,7 @@ static void test_rpc_decode_and_compare(MsgList_t expected_msg_list, uint8_t ses
|
||||
furi_check(!MsgList_empty_p(expected_msg_list));
|
||||
furi_check(session < TEST_RPC_SESSIONS);
|
||||
|
||||
rpc_session[session].timeout = xTaskGetTickCount() + MAX_RECEIVE_OUTPUT_TIMEOUT;
|
||||
rpc_session[session].timeout = furi_get_tick() + MAX_RECEIVE_OUTPUT_TIMEOUT;
|
||||
pb_istream_t istream = {
|
||||
.callback = test_rpc_pb_stream_read,
|
||||
.state = &rpc_session[session],
|
||||
@@ -712,7 +714,7 @@ static void test_rpc_decode_and_compare(MsgList_t expected_msg_list, uint8_t ses
|
||||
pb_release(&PB_Main_msg, &result);
|
||||
}
|
||||
|
||||
rpc_session[session].timeout = xTaskGetTickCount() + 50;
|
||||
rpc_session[session].timeout = furi_get_tick() + 50;
|
||||
if(pb_decode_ex(&istream, &PB_Main_msg, &result, PB_DECODE_DELIMITED)) {
|
||||
mu_fail("decoded more than expected");
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ const UnitTest unit_tests[] = {
|
||||
void minunit_print_progress() {
|
||||
static const char progress[] = {'\\', '|', '/', '-'};
|
||||
static uint8_t progress_counter = 0;
|
||||
static TickType_t last_tick = 0;
|
||||
TickType_t current_tick = xTaskGetTickCount();
|
||||
static uint32_t last_tick = 0;
|
||||
uint32_t current_tick = furi_get_tick();
|
||||
if(current_tick - last_tick > 20) {
|
||||
last_tick = current_tick;
|
||||
printf("[%c]\033[3D", progress[++progress_counter % COUNT_OF(progress)]);
|
||||
|
||||
@@ -384,18 +384,17 @@ void infrared_play_notification_message(
|
||||
}
|
||||
|
||||
void infrared_show_loading_popup(const InfraredApp* infrared, bool show) {
|
||||
TaskHandle_t timer_task = xTaskGetHandle(configTIMER_SERVICE_TASK_NAME);
|
||||
ViewStack* view_stack = infrared->view_stack;
|
||||
Loading* loading = infrared->loading;
|
||||
|
||||
if(show) {
|
||||
// Raise timer priority so that animations can play
|
||||
vTaskPrioritySet(timer_task, configMAX_PRIORITIES - 1);
|
||||
furi_timer_set_thread_priority(FuriTimerThreadPriorityElevated);
|
||||
view_stack_add_view(view_stack, loading_get_view(loading));
|
||||
} else {
|
||||
view_stack_remove_view(view_stack, loading_get_view(loading));
|
||||
// Restore default timer priority
|
||||
vTaskPrioritySet(timer_task, configTIMER_TASK_PRIORITY);
|
||||
furi_timer_set_thread_priority(FuriTimerThreadPriorityNormal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -411,15 +411,14 @@ bool nfc_load_from_file_select(NfcApp* instance) {
|
||||
|
||||
void nfc_show_loading_popup(void* context, bool show) {
|
||||
NfcApp* nfc = context;
|
||||
TaskHandle_t timer_task = xTaskGetHandle(configTIMER_SERVICE_TASK_NAME);
|
||||
|
||||
if(show) {
|
||||
// Raise timer priority so that animations can play
|
||||
vTaskPrioritySet(timer_task, configMAX_PRIORITIES - 1);
|
||||
furi_timer_set_thread_priority(FuriTimerThreadPriorityElevated);
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewLoading);
|
||||
} else {
|
||||
// Restore default timer priority
|
||||
vTaskPrioritySet(timer_task, configTIMER_TASK_PRIORITY);
|
||||
furi_timer_set_thread_priority(FuriTimerThreadPriorityNormal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ void subghz_view_receiver_set_lock(SubGhzViewReceiver* subghz_receiver, bool loc
|
||||
SubGhzViewReceiverModel * model,
|
||||
{ model->bar_show = SubGhzViewReceiverBarShowLock; },
|
||||
true);
|
||||
furi_timer_start(subghz_receiver->timer, pdMS_TO_TICKS(1000));
|
||||
furi_timer_start(subghz_receiver->timer, 1000);
|
||||
} else {
|
||||
with_view_model(
|
||||
subghz_receiver->view,
|
||||
@@ -316,7 +316,7 @@ bool subghz_view_receiver_input(InputEvent* event, void* context) {
|
||||
{ model->bar_show = SubGhzViewReceiverBarShowToUnlockPress; },
|
||||
true);
|
||||
if(subghz_receiver->lock_count == 0) {
|
||||
furi_timer_start(subghz_receiver->timer, pdMS_TO_TICKS(1000));
|
||||
furi_timer_start(subghz_receiver->timer, 1000);
|
||||
}
|
||||
if(event->key == InputKeyBack && event->type == InputTypeShort) {
|
||||
subghz_receiver->lock_count++;
|
||||
@@ -330,7 +330,7 @@ bool subghz_view_receiver_input(InputEvent* event, void* context) {
|
||||
{ model->bar_show = SubGhzViewReceiverBarShowUnlock; },
|
||||
true);
|
||||
//subghz_receiver->lock = false;
|
||||
furi_timer_start(subghz_receiver->timer, pdMS_TO_TICKS(650));
|
||||
furi_timer_start(subghz_receiver->timer, 650);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -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,7 +449,7 @@ 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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -154,7 +154,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;
|
||||
@@ -215,7 +215,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) {
|
||||
@@ -355,7 +355,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"
|
||||
|
||||
@@ -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 5000
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -90,12 +90,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,12 +106,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 {
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
@@ -80,12 +79,12 @@ Dolphin* dolphin_alloc() {
|
||||
dolphin->state = dolphin_state_alloc();
|
||||
dolphin->event_queue = furi_message_queue_alloc(8, sizeof(DolphinEvent));
|
||||
dolphin->pubsub = furi_pubsub_alloc();
|
||||
dolphin->butthurt_timer = xTimerCreate(
|
||||
NULL, HOURS_IN_TICKS(2 * 24), pdTRUE, dolphin, dolphin_butthurt_timer_callback);
|
||||
dolphin->butthurt_timer =
|
||||
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_stop(dolphin->butthurt_timer);
|
||||
dolphin_update_clear_limits_timer_period(dolphin);
|
||||
xTimerReset(dolphin->clear_limits_timer, portMAX_DELAY);
|
||||
furi_timer_stop(dolphin->clear_limits_timer);
|
||||
|
||||
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);
|
||||
furi_timer_restart(dolphin->flush_timer);
|
||||
} 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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <furi.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <furi_hal.h>
|
||||
#include <semphr.h>
|
||||
|
||||
#define TAG "RpcCli"
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
#include <portmacro.h>
|
||||
#include <stdint.h>
|
||||
|
||||
static bool updater_custom_event_callback(void* context, uint32_t event) {
|
||||
|
||||
Reference in New Issue
Block a user