mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-29 00:09:19 +03:00
update custom apps / use furi
This commit is contained in:
parent
ad970c6c6d
commit
0b27881bae
@ -304,18 +304,18 @@ static void arkanoid_draw_callback(Canvas* const canvas, void* ctx) {
|
||||
release_mutex((ValueMutex*)ctx, arkanoid_state);
|
||||
}
|
||||
|
||||
static void arkanoid_input_callback(InputEvent* input_event, osMessageQueueId_t event_queue) {
|
||||
static void arkanoid_input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) {
|
||||
furi_assert(event_queue);
|
||||
|
||||
GameEvent event = {.type = EventTypeKey, .input = *input_event};
|
||||
osMessageQueuePut(event_queue, &event, 0, osWaitForever);
|
||||
furi_message_queue_put(event_queue, &event, FuriWaitForever);
|
||||
}
|
||||
|
||||
static void arkanoid_update_timer_callback(osMessageQueueId_t event_queue) {
|
||||
static void arkanoid_update_timer_callback(FuriMessageQueue* event_queue) {
|
||||
furi_assert(event_queue);
|
||||
|
||||
GameEvent event = {.type = EventTypeTick};
|
||||
osMessageQueuePut(event_queue, &event, 0, 0);
|
||||
furi_message_queue_put(event_queue, &event, 0);
|
||||
}
|
||||
|
||||
int32_t arkanoid_game_app(void* p) {
|
||||
@ -323,7 +323,7 @@ int32_t arkanoid_game_app(void* p) {
|
||||
// Set random seed from interrupts
|
||||
srand(DWT->CYCCNT);
|
||||
|
||||
osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(GameEvent), NULL);
|
||||
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(GameEvent));
|
||||
|
||||
ArkanoidState* arkanoid_state = malloc(sizeof(ArkanoidState));
|
||||
arkanoid_state_init(arkanoid_state);
|
||||
@ -340,9 +340,9 @@ int32_t arkanoid_game_app(void* p) {
|
||||
view_port_draw_callback_set(view_port, arkanoid_draw_callback, &state_mutex);
|
||||
view_port_input_callback_set(view_port, arkanoid_input_callback, event_queue);
|
||||
|
||||
osTimerId_t timer =
|
||||
osTimerNew(arkanoid_update_timer_callback, osTimerPeriodic, event_queue, NULL);
|
||||
osTimerStart(timer, osKernelGetTickFreq() / 22);
|
||||
FuriTimer* timer =
|
||||
furi_timer_alloc(arkanoid_update_timer_callback, FuriTimerTypePeriodic, event_queue);
|
||||
furi_timer_start(timer, furi_kernel_get_tick_frequency() / 22);
|
||||
|
||||
// Open GUI and register view_port
|
||||
Gui* gui = furi_record_open("gui");
|
||||
@ -350,10 +350,10 @@ int32_t arkanoid_game_app(void* p) {
|
||||
|
||||
GameEvent event;
|
||||
for(bool processing = true; processing;) {
|
||||
osStatus_t event_status = osMessageQueueGet(event_queue, &event, NULL, 100);
|
||||
FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100);
|
||||
ArkanoidState* arkanoid_state = (ArkanoidState*)acquire_mutex_block(&state_mutex);
|
||||
|
||||
if(event_status == osOK) {
|
||||
if(event_status == FuriStatusOk) {
|
||||
// Key events
|
||||
if(event.type == EventTypeKey) {
|
||||
if(event.input.type == InputTypePress || event.input.type == InputTypeLong ||
|
||||
@ -402,11 +402,14 @@ int32_t arkanoid_game_app(void* p) {
|
||||
release_mutex(&state_mutex, arkanoid_state);
|
||||
}
|
||||
|
||||
furi_timer_free(timer);
|
||||
view_port_enabled_set(view_port, false);
|
||||
gui_remove_view_port(gui, view_port);
|
||||
furi_record_close("gui");
|
||||
view_port_free(view_port);
|
||||
osMessageQueueDelete(event_queue);
|
||||
furi_message_queue_free(event_queue);
|
||||
delete_mutex(&state_mutex);
|
||||
free(arkanoid_state);
|
||||
|
||||
return 0;
|
||||
}
|
@ -26,10 +26,10 @@ typedef struct {
|
||||
FuriHalRtcDateTime datetime;
|
||||
} ClockState;
|
||||
|
||||
static void clock_input_callback(InputEvent* input_event, osMessageQueueId_t event_queue) {
|
||||
static void clock_input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) {
|
||||
furi_assert(event_queue);
|
||||
PluginEvent event = {.type = EventTypeKey, .input = *input_event};
|
||||
osMessageQueuePut(event_queue, &event, 0, osWaitForever);
|
||||
furi_message_queue_put(event_queue, &event, FuriWaitForever);
|
||||
}
|
||||
|
||||
static void clock_render_callback(Canvas* const canvas, void* ctx) {
|
||||
@ -260,7 +260,7 @@ const NotificationSequence clock_alert_startStop = {
|
||||
// Runs every 1000ms by default
|
||||
static void clock_tick(void* ctx) {
|
||||
furi_assert(ctx);
|
||||
osMessageQueueId_t event_queue = ctx;
|
||||
FuriMessageQueue* event_queue = ctx;
|
||||
PluginEvent event = {.type = EventTypeTick};
|
||||
if(timerStarted) {
|
||||
timerSecs = timerSecs + 1;
|
||||
@ -310,7 +310,7 @@ static void clock_tick(void* ctx) {
|
||||
}
|
||||
}
|
||||
// It's OK to loose this event if system overloaded
|
||||
osMessageQueuePut(event_queue, &event, 0, 0);
|
||||
furi_message_queue_put(event_queue, &event, 0);
|
||||
}
|
||||
|
||||
int32_t clock_app(void* p) {
|
||||
@ -318,7 +318,7 @@ int32_t clock_app(void* p) {
|
||||
timerStarted = false;
|
||||
timerSecs = 0;
|
||||
songSelect = 2;
|
||||
osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(PluginEvent), NULL);
|
||||
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent));
|
||||
ClockState* plugin_state = malloc(sizeof(ClockState));
|
||||
clock_state_init(plugin_state);
|
||||
ValueMutex state_mutex;
|
||||
@ -331,17 +331,17 @@ int32_t clock_app(void* p) {
|
||||
ViewPort* view_port = view_port_alloc();
|
||||
view_port_draw_callback_set(view_port, clock_render_callback, &state_mutex);
|
||||
view_port_input_callback_set(view_port, clock_input_callback, event_queue);
|
||||
osTimerId_t timer = osTimerNew(clock_tick, osTimerPeriodic, event_queue, NULL);
|
||||
osTimerStart(timer, osKernelGetTickFreq());
|
||||
FuriTimer* timer = furi_timer_alloc(clock_tick, FuriTimerTypePeriodic, event_queue);
|
||||
furi_timer_start(timer, furi_kernel_get_tick_frequency());
|
||||
// Open GUI and register view_port
|
||||
Gui* gui = furi_record_open("gui");
|
||||
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
|
||||
// Main loop
|
||||
PluginEvent event;
|
||||
for(bool processing = true; processing;) {
|
||||
osStatus_t event_status = osMessageQueueGet(event_queue, &event, NULL, 100);
|
||||
FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100);
|
||||
ClockState* plugin_state = (ClockState*)acquire_mutex_block(&state_mutex);
|
||||
if(event_status == osOK) {
|
||||
if(event_status == FuriStatusOk) {
|
||||
// press events
|
||||
if(event.type == EventTypeKey) {
|
||||
if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
|
||||
@ -394,11 +394,13 @@ int32_t clock_app(void* p) {
|
||||
view_port_update(view_port);
|
||||
release_mutex(&state_mutex, plugin_state);
|
||||
}
|
||||
osTimerDelete(timer);
|
||||
furi_timer_free(timer);
|
||||
view_port_enabled_set(view_port, false);
|
||||
gui_remove_view_port(gui, view_port);
|
||||
furi_record_close("gui");
|
||||
view_port_free(view_port);
|
||||
osMessageQueueDelete(event_queue);
|
||||
furi_message_queue_free(event_queue);
|
||||
delete_mutex(&state_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
@ -78,7 +78,7 @@ static int32_t music_player_worker_thread_callback(void* context) {
|
||||
|
||||
furi_hal_speaker_stop();
|
||||
furi_hal_speaker_start(frequency, volume);
|
||||
while(instance->should_work && furi_hal_get_tick() < next_tick) {
|
||||
while(instance->should_work && furi_get_tick() < next_tick) {
|
||||
volume *= 1.0000000;
|
||||
furi_hal_speaker_set_volume(volume);
|
||||
furi_delay_ms(2);
|
||||
|
@ -28,9 +28,9 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
SpectrumAnalyzerModel* model;
|
||||
osMutexId_t* model_mutex;
|
||||
FuriMutex* model_mutex;
|
||||
|
||||
osMessageQueueId_t event_queue;
|
||||
FuriMessageQueue* event_queue;
|
||||
|
||||
ViewPort* view_port;
|
||||
Gui* gui;
|
||||
@ -89,7 +89,7 @@ void spectrum_analyzer_draw_scale(Canvas* canvas, const SpectrumAnalyzerModel* m
|
||||
|
||||
static void spectrum_analyzer_render_callback(Canvas* const canvas, void* ctx) {
|
||||
SpectrumAnalyzer* spectrum_analyzer = ctx;
|
||||
//furi_check(osMutexAcquire(spectrum_analyzer->model_mutex, osWaitForever) == osOK);
|
||||
//furi_check(furi_mutex_acquire(spectrum_analyzer->model_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
SpectrumAnalyzerModel* model = spectrum_analyzer->model;
|
||||
|
||||
@ -167,7 +167,7 @@ static void spectrum_analyzer_render_callback(Canvas* const canvas, void* ctx) {
|
||||
canvas_draw_str_aligned(canvas, 127, 0, AlignRight, AlignTop, temp_str);
|
||||
}
|
||||
|
||||
//osMutexRelease(spectrum_analyzer->model_mutex);
|
||||
//furi_mutex_release(spectrum_analyzer->model_mutex);
|
||||
|
||||
// FURI_LOG_D("Spectrum", "model->vscroll %u", model->vscroll);
|
||||
}
|
||||
@ -176,7 +176,7 @@ static void spectrum_analyzer_input_callback(InputEvent* input_event, void* ctx)
|
||||
SpectrumAnalyzer* spectrum_analyzer = ctx;
|
||||
// Only handle short presses
|
||||
if(input_event->type == InputTypeShort) {
|
||||
osMessageQueuePut(spectrum_analyzer->event_queue, input_event, 0, osWaitForever);
|
||||
furi_message_queue_put(spectrum_analyzer->event_queue, input_event, FuriWaitForever);
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ static void spectrum_analyzer_worker_callback(
|
||||
uint8_t max_rssi_channel,
|
||||
void* context) {
|
||||
SpectrumAnalyzer* spectrum_analyzer = context;
|
||||
furi_check(osMutexAcquire(spectrum_analyzer->model_mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(spectrum_analyzer->model_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
SpectrumAnalyzerModel* model = (SpectrumAnalyzerModel*)spectrum_analyzer->model;
|
||||
memcpy(model->channel_ss, (uint8_t*)channel_ss, sizeof(uint8_t) * NUM_CHANNELS);
|
||||
@ -195,7 +195,7 @@ static void spectrum_analyzer_worker_callback(
|
||||
model->max_rssi_dec = max_rssi_dec;
|
||||
model->max_rssi_channel = max_rssi_channel;
|
||||
|
||||
osMutexRelease(spectrum_analyzer->model_mutex);
|
||||
furi_mutex_release(spectrum_analyzer->model_mutex);
|
||||
view_port_update(spectrum_analyzer->view_port);
|
||||
}
|
||||
|
||||
@ -354,8 +354,8 @@ SpectrumAnalyzer* spectrum_analyzer_alloc() {
|
||||
|
||||
model->vscroll = DEFAULT_VSCROLL;
|
||||
|
||||
instance->model_mutex = osMutexNew(NULL);
|
||||
instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL);
|
||||
instance->model_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
instance->event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
|
||||
|
||||
instance->worker = spectrum_analyzer_worker_alloc();
|
||||
|
||||
@ -382,9 +382,9 @@ void spectrum_analyzer_free(SpectrumAnalyzer* instance) {
|
||||
|
||||
spectrum_analyzer_worker_free(instance->worker);
|
||||
|
||||
osMessageQueueDelete(instance->event_queue);
|
||||
furi_message_queue_free(instance->event_queue);
|
||||
|
||||
osMutexDelete(instance->model_mutex);
|
||||
furi_mutex_free(instance->model_mutex);
|
||||
|
||||
free(instance->model);
|
||||
free(instance);
|
||||
@ -400,15 +400,15 @@ int32_t spectrum_analyzer_app(void* p) {
|
||||
InputEvent input;
|
||||
|
||||
FURI_LOG_D("Spectrum", "Main Loop - Starting worker");
|
||||
furi_hal_delay_ms(50);
|
||||
furi_delay_ms(50);
|
||||
|
||||
spectrum_analyzer_worker_start(spectrum_analyzer->worker);
|
||||
|
||||
FURI_LOG_D("Spectrum", "Main Loop - Wait on queue");
|
||||
furi_hal_delay_ms(50);
|
||||
furi_delay_ms(50);
|
||||
|
||||
while(osMessageQueueGet(spectrum_analyzer->event_queue, &input, NULL, osWaitForever) == osOK) {
|
||||
furi_check(osMutexAcquire(spectrum_analyzer->model_mutex, osWaitForever) == osOK);
|
||||
while(furi_message_queue_get(spectrum_analyzer->event_queue, &input, FuriWaitForever) == FuriStatusOk) {
|
||||
furi_check(furi_mutex_acquire(spectrum_analyzer->model_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
FURI_LOG_D("Spectrum", "Main Loop - Input: %u", input.key);
|
||||
|
||||
@ -480,7 +480,7 @@ int32_t spectrum_analyzer_app(void* p) {
|
||||
model->mode_change = true;
|
||||
view_port_update(spectrum_analyzer->view_port);
|
||||
|
||||
furi_hal_delay_ms(1000);
|
||||
furi_delay_ms(1000);
|
||||
|
||||
model->mode_change = false;
|
||||
spectrum_analyzer_calculate_frequencies(model);
|
||||
@ -493,7 +493,7 @@ int32_t spectrum_analyzer_app(void* p) {
|
||||
break;
|
||||
}
|
||||
|
||||
osMutexRelease(spectrum_analyzer->model_mutex);
|
||||
furi_mutex_release(spectrum_analyzer->model_mutex);
|
||||
view_port_update(spectrum_analyzer->view_port);
|
||||
if(exit_loop == true) break;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ static int32_t spectrum_analyzer_worker_thread(void* context) {
|
||||
};
|
||||
|
||||
while(instance->should_work) {
|
||||
furi_hal_delay_ms(50);
|
||||
furi_delay_ms(50);
|
||||
|
||||
// FURI_LOG_T("SpectrumWorker", "spectrum_analyzer_worker_thread: Worker Loop");
|
||||
furi_hal_subghz_idle();
|
||||
@ -93,7 +93,7 @@ static int32_t spectrum_analyzer_worker_thread(void* context) {
|
||||
furi_hal_subghz_set_frequency(instance->channel0_frequency + (ch * instance->spacing));
|
||||
|
||||
furi_hal_subghz_rx();
|
||||
furi_hal_delay_ms(3);
|
||||
furi_delay_ms(3);
|
||||
|
||||
// dec dBm
|
||||
//max_ss = 127 -> -10.5
|
||||
|
@ -66,7 +66,7 @@ typedef struct {
|
||||
uint16_t numLines;
|
||||
uint16_t fallSpeed;
|
||||
GameState gameState;
|
||||
osTimerId_t timer;
|
||||
FuriTimer* timer;
|
||||
} TetrisState;
|
||||
|
||||
typedef enum {
|
||||
@ -158,11 +158,11 @@ static void tetris_game_render_callback(Canvas* const canvas, void* ctx) {
|
||||
release_mutex((ValueMutex*)ctx, tetris_state);
|
||||
}
|
||||
|
||||
static void tetris_game_input_callback(InputEvent* input_event, osMessageQueueId_t event_queue) {
|
||||
static void tetris_game_input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) {
|
||||
furi_assert(event_queue);
|
||||
|
||||
TetrisEvent event = {.type = EventTypeKey, .input = *input_event};
|
||||
osMessageQueuePut(event_queue, &event, 0, osWaitForever);
|
||||
furi_message_queue_put(event_queue, &event, FuriWaitForever);
|
||||
}
|
||||
|
||||
static void tetris_game_init_state(TetrisState* tetris_state) {
|
||||
@ -173,7 +173,7 @@ static void tetris_game_init_state(TetrisState* tetris_state) {
|
||||
|
||||
memcpy(&tetris_state->currPiece, &shapes[rand() % 7], sizeof(tetris_state->currPiece));
|
||||
|
||||
osTimerStart(tetris_state->timer, tetris_state->fallSpeed);
|
||||
furi_timer_start(tetris_state->timer, tetris_state->fallSpeed);
|
||||
}
|
||||
|
||||
static void tetris_game_remove_curr_piece(TetrisState* tetris_state) {
|
||||
@ -282,11 +282,11 @@ static bool tetris_game_piece_at_bottom(TetrisState* tetris_state, Piece* newPie
|
||||
return false;
|
||||
}
|
||||
|
||||
static void tetris_game_update_timer_callback(osMessageQueueId_t event_queue) {
|
||||
static void tetris_game_update_timer_callback(FuriMessageQueue* event_queue) {
|
||||
furi_assert(event_queue);
|
||||
|
||||
TetrisEvent event = {.type = EventTypeTick};
|
||||
osMessageQueuePut(event_queue, &event, 0, osWaitForever);
|
||||
furi_message_queue_put(event_queue, &event, FuriWaitForever);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -297,7 +297,7 @@ static void
|
||||
|
||||
if(wasDownMove) {
|
||||
if(tetris_game_piece_at_bottom(tetris_state, newPiece)) {
|
||||
osTimerStop(tetris_state->timer);
|
||||
furi_timer_stop(tetris_state->timer);
|
||||
|
||||
tetris_game_render_curr_piece(tetris_state);
|
||||
uint8_t numLines = 0;
|
||||
@ -332,7 +332,7 @@ static void
|
||||
tetris_state->gameState = GameStateGameOver;
|
||||
} else {
|
||||
memcpy(&tetris_state->currPiece, spawnedPiece, sizeof(tetris_state->currPiece));
|
||||
osTimerStart(tetris_state->timer, tetris_state->fallSpeed);
|
||||
furi_timer_start(tetris_state->timer, tetris_state->fallSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -347,7 +347,7 @@ static void
|
||||
int32_t tetris_game_app() {
|
||||
srand(DWT->CYCCNT);
|
||||
|
||||
osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(TetrisEvent), NULL);
|
||||
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(TetrisEvent));
|
||||
|
||||
TetrisState* tetris_state = malloc(sizeof(TetrisState));
|
||||
|
||||
@ -376,7 +376,7 @@ int32_t tetris_game_app() {
|
||||
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
|
||||
|
||||
tetris_state->timer =
|
||||
osTimerNew(tetris_game_update_timer_callback, osTimerPeriodic, event_queue, NULL);
|
||||
furi_timer_alloc(tetris_game_update_timer_callback, FuriTimerTypePeriodic, event_queue);
|
||||
tetris_game_init_state(tetris_state);
|
||||
|
||||
TetrisEvent event;
|
||||
@ -386,7 +386,7 @@ int32_t tetris_game_app() {
|
||||
|
||||
for(bool processing = true; processing;) {
|
||||
// This 10U implicitly sets the game loop speed. downRepeatCounter relies on this value
|
||||
osStatus_t event_status = osMessageQueueGet(event_queue, &event, NULL, 10U);
|
||||
FuriStatus event_status = furi_message_queue_get(event_queue, &event, 10U);
|
||||
|
||||
TetrisState* tetris_state = (TetrisState*)acquire_mutex_block(&state_mutex);
|
||||
|
||||
@ -405,7 +405,7 @@ int32_t tetris_game_app() {
|
||||
}
|
||||
}
|
||||
|
||||
if(event_status == osOK) {
|
||||
if(event_status == FuriStatusOk) {
|
||||
if(event.type == EventTypeKey) {
|
||||
if(event.input.type == InputTypePress || event.input.type == InputTypeLong ||
|
||||
event.input.type == InputTypeRepeat) {
|
||||
@ -456,12 +456,12 @@ int32_t tetris_game_app() {
|
||||
release_mutex(&state_mutex, tetris_state);
|
||||
}
|
||||
|
||||
osTimerDelete(tetris_state->timer);
|
||||
furi_timer_free(tetris_state->timer);
|
||||
view_port_enabled_set(view_port, false);
|
||||
gui_remove_view_port(gui, view_port);
|
||||
furi_record_close("gui");
|
||||
view_port_free(view_port);
|
||||
osMessageQueueDelete(event_queue);
|
||||
furi_message_queue_free(event_queue);
|
||||
delete_mutex(&state_mutex);
|
||||
vTaskPrioritySet(timer_task, origTimerPrio);
|
||||
free(newPiece);
|
||||
|
@ -32,7 +32,7 @@ typedef enum { GameStatePlaying, GameStateGameOver } GameState;
|
||||
|
||||
typedef struct {
|
||||
GameState game_state;
|
||||
osTimerId_t timer;
|
||||
FuriTimer* timer;
|
||||
} TicTacToeState;
|
||||
|
||||
typedef struct {
|
||||
@ -253,23 +253,23 @@ static void tictactoe_draw_callback(Canvas* const canvas, void* ctx) {
|
||||
release_mutex((ValueMutex*)ctx, tictactoe_state);
|
||||
}
|
||||
|
||||
static void tictactoe_input_callback(InputEvent* input_event, osMessageQueueId_t event_queue) {
|
||||
static void tictactoe_input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) {
|
||||
furi_assert(event_queue);
|
||||
|
||||
GameEvent event = {.type = EventTypeKey, .input = *input_event};
|
||||
osMessageQueuePut(event_queue, &event, 0, osWaitForever);
|
||||
furi_message_queue_put(event_queue, &event, FuriWaitForever);
|
||||
}
|
||||
|
||||
static void tictactoe_update_timer_callback(osMessageQueueId_t event_queue) {
|
||||
static void tictactoe_update_timer_callback(FuriMessageQueue* event_queue) {
|
||||
furi_assert(event_queue);
|
||||
|
||||
GameEvent event = {.type = EventTypeTick};
|
||||
osMessageQueuePut(event_queue, &event, 0, 0);
|
||||
furi_message_queue_put(event_queue, &event, 0);
|
||||
}
|
||||
|
||||
int32_t tictactoe_game_app(void* p) {
|
||||
UNUSED(p);
|
||||
osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(GameEvent), NULL);
|
||||
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(GameEvent));
|
||||
|
||||
TicTacToeState* tictactoe_state = malloc(sizeof(TicTacToeState));
|
||||
|
||||
@ -277,7 +277,7 @@ int32_t tictactoe_game_app(void* p) {
|
||||
if(!init_mutex(&state_mutex, tictactoe_state, sizeof(TicTacToeState))) {
|
||||
FURI_LOG_E(TAG, "Cannot create mutex\r\n");
|
||||
free(tictactoe_state);
|
||||
osMessageQueueDelete(event_queue);
|
||||
furi_message_queue_free(event_queue);
|
||||
return 255;
|
||||
}
|
||||
|
||||
@ -287,8 +287,8 @@ int32_t tictactoe_game_app(void* p) {
|
||||
view_port_input_callback_set(view_port, tictactoe_input_callback, event_queue);
|
||||
|
||||
tictactoe_state->timer =
|
||||
osTimerNew(tictactoe_update_timer_callback, osTimerPeriodic, event_queue, NULL);
|
||||
osTimerStart(tictactoe_state->timer, osKernelGetTickFreq() / 22);
|
||||
furi_timer_alloc(tictactoe_update_timer_callback, FuriTimerTypePeriodic, event_queue);
|
||||
furi_timer_start(tictactoe_state->timer, furi_kernel_get_tick_frequency() / 22);
|
||||
|
||||
tictactoe_state_init(tictactoe_state);
|
||||
|
||||
@ -298,10 +298,10 @@ int32_t tictactoe_game_app(void* p) {
|
||||
|
||||
GameEvent event;
|
||||
for(bool processing = true; processing;) {
|
||||
osStatus_t event_status = osMessageQueueGet(event_queue, &event, NULL, 100);
|
||||
FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100);
|
||||
TicTacToeState* tictactoe_state = (TicTacToeState*)acquire_mutex_block(&state_mutex);
|
||||
|
||||
if(event_status == osOK) {
|
||||
if(event_status == FuriStatusOk) {
|
||||
// Key events
|
||||
if(event.type == EventTypeKey) {
|
||||
if(event.input.type == InputTypePress) {
|
||||
@ -336,12 +336,12 @@ int32_t tictactoe_game_app(void* p) {
|
||||
release_mutex(&state_mutex, tictactoe_state);
|
||||
}
|
||||
|
||||
osTimerDelete(tictactoe_state->timer);
|
||||
furi_timer_free(tictactoe_state->timer);
|
||||
view_port_enabled_set(view_port, false);
|
||||
gui_remove_view_port(gui, view_port);
|
||||
furi_record_close("gui");
|
||||
view_port_free(view_port);
|
||||
osMessageQueueDelete(event_queue);
|
||||
furi_message_queue_free(event_queue);
|
||||
delete_mutex(&state_mutex);
|
||||
free(tictactoe_state);
|
||||
|
||||
|
@ -15,9 +15,9 @@
|
||||
#define TAG "UniRF Remix"
|
||||
|
||||
typedef struct {
|
||||
osMutexId_t* model_mutex;
|
||||
FuriMutex* model_mutex;
|
||||
|
||||
osMessageQueueId_t input_queue;
|
||||
FuriMessageQueue* input_queue;
|
||||
|
||||
ViewPort* view_port;
|
||||
Gui* gui;
|
||||
@ -710,7 +710,7 @@ static void unirfremix_send_signal(
|
||||
notification_message(notification, &sequence_blink_magenta_10);
|
||||
printf("Sending...");
|
||||
fflush(stdout);
|
||||
osDelay(333);
|
||||
furi_delay_ms(300);
|
||||
}
|
||||
|
||||
furi_record_close("notification");
|
||||
@ -729,7 +729,7 @@ static void unirfremix_send_signal(
|
||||
}
|
||||
|
||||
static void unirfremix_process_signal(UniRFRemix* app, string_t signal) {
|
||||
osMutexRelease(app->model_mutex);
|
||||
furi_mutex_release(app->model_mutex);
|
||||
view_port_update(app->view_port);
|
||||
|
||||
FURI_LOG_I(TAG, "signal = %s", string_get_cstr(signal));
|
||||
@ -772,7 +772,7 @@ static void unirfremix_process_signal(UniRFRemix* app, string_t signal) {
|
||||
|
||||
static void render_callback(Canvas* canvas, void* ctx) {
|
||||
UniRFRemix* app = ctx;
|
||||
furi_check(osMutexAcquire(app->model_mutex, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(app->model_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
//setup different canvas settings
|
||||
if(app->file_result == 1) {
|
||||
@ -857,21 +857,21 @@ static void render_callback(Canvas* canvas, void* ctx) {
|
||||
canvas, 125, 62, AlignRight, AlignBottom, int_to_char(app->repeat));
|
||||
}
|
||||
|
||||
osMutexRelease(app->model_mutex);
|
||||
furi_mutex_release(app->model_mutex);
|
||||
}
|
||||
|
||||
static void input_callback(InputEvent* input_event, void* ctx) {
|
||||
UniRFRemix* app = ctx;
|
||||
|
||||
osMessageQueuePut(app->input_queue, input_event, 0, osWaitForever);
|
||||
furi_message_queue_put(app->input_queue, input_event, FuriWaitForever);
|
||||
}
|
||||
|
||||
UniRFRemix* unirfremix_alloc() {
|
||||
UniRFRemix* app = malloc(sizeof(UniRFRemix));
|
||||
|
||||
app->model_mutex = osMutexNew(NULL);
|
||||
app->model_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
|
||||
app->input_queue = osMessageQueueNew(32, sizeof(InputEvent), NULL);
|
||||
app->input_queue = furi_message_queue_alloc(32, sizeof(InputEvent));
|
||||
|
||||
app->view_port = view_port_alloc();
|
||||
view_port_draw_callback_set(app->view_port, render_callback, app);
|
||||
@ -902,9 +902,9 @@ void unirfremix_free(UniRFRemix* app) {
|
||||
furi_record_close("gui");
|
||||
view_port_free(app->view_port);
|
||||
|
||||
osMessageQueueDelete(app->input_queue);
|
||||
furi_message_queue_free(app->input_queue);
|
||||
|
||||
osMutexDelete(app->model_mutex);
|
||||
furi_mutex_free(app->model_mutex);
|
||||
|
||||
free(app);
|
||||
}
|
||||
@ -952,13 +952,13 @@ int32_t unirfremix_app(void* p) {
|
||||
app->button = 0;
|
||||
|
||||
//refresh screen to update variables before processing main screen or error screens
|
||||
osMutexRelease(app->model_mutex);
|
||||
furi_mutex_release(app->model_mutex);
|
||||
view_port_update(app->view_port);
|
||||
|
||||
//input detect loop start
|
||||
InputEvent input;
|
||||
while(1) {
|
||||
furi_check(osMessageQueueGet(app->input_queue, &input, NULL, osWaitForever) == osOK);
|
||||
furi_check(furi_message_queue_get(app->input_queue, &input, FuriWaitForever) == FuriStatusOk);
|
||||
FURI_LOG_I(
|
||||
TAG,
|
||||
"key: %s type: %s",
|
||||
@ -1080,11 +1080,11 @@ int32_t unirfremix_app(void* p) {
|
||||
}
|
||||
|
||||
if(exit_loop == true) {
|
||||
osMutexRelease(app->model_mutex);
|
||||
furi_mutex_release(app->model_mutex);
|
||||
break;
|
||||
}
|
||||
|
||||
osMutexRelease(app->model_mutex);
|
||||
furi_mutex_release(app->model_mutex);
|
||||
view_port_update(app->view_port);
|
||||
}
|
||||
} else {
|
||||
@ -1093,7 +1093,7 @@ int32_t unirfremix_app(void* p) {
|
||||
|
||||
InputEvent input;
|
||||
while(1) {
|
||||
furi_check(osMessageQueueGet(app->input_queue, &input, NULL, osWaitForever) == osOK);
|
||||
furi_check(furi_message_queue_get(app->input_queue, &input, FuriWaitForever) == FuriStatusOk);
|
||||
FURI_LOG_I(
|
||||
TAG,
|
||||
"key: %s type: %s",
|
||||
@ -1119,11 +1119,11 @@ int32_t unirfremix_app(void* p) {
|
||||
}
|
||||
|
||||
if(exit_loop == true) {
|
||||
osMutexRelease(app->model_mutex);
|
||||
furi_mutex_release(app->model_mutex);
|
||||
break;
|
||||
}
|
||||
|
||||
osMutexRelease(app->model_mutex);
|
||||
furi_mutex_release(app->model_mutex);
|
||||
view_port_update(app->view_port);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user