mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-08 23:08:10 -07:00
Merge branch 'dev' of https://github.com/claracrazy/flipper-xtreme into dev
This commit is contained in:
+1
-4
@@ -28,9 +28,7 @@
|
||||
#define MAXPOWERUPS 3 /* Max powerups allowed on screen */
|
||||
#define POWERUPSTTL 400 /* Max powerup time to live, in ticks. */
|
||||
#define SHIP_HIT_ANIMATION_LEN 15
|
||||
// Tick runs in thread, cant use APP_DATA_PATH()
|
||||
#define SAVING_DIRECTORY EXT_PATH("apps_data/asteroids")
|
||||
#define SAVING_FILENAME SAVING_DIRECTORY "/game_asteroids.save"
|
||||
#define SAVING_FILENAME APP_DATA_PATH("game_asteroids.save")
|
||||
#ifndef PI
|
||||
#define PI 3.14159265358979f
|
||||
#endif
|
||||
@@ -1147,7 +1145,6 @@ void game_tick(void* ctx) {
|
||||
|
||||
bool load_game(AsteroidsApp* app) {
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
storage_common_mkdir(storage, SAVING_DIRECTORY);
|
||||
storage_common_migrate(storage, EXT_PATH("apps/Games/game_asteroids.save"), SAVING_FILENAME);
|
||||
|
||||
File* file = storage_file_alloc(storage);
|
||||
|
||||
+3
-9
@@ -18,8 +18,7 @@
|
||||
#include "includes/game_state.h"
|
||||
|
||||
#define TAG "Jetpack Joyride"
|
||||
#define SAVING_DIRECTORY "/ext/apps/Games"
|
||||
#define SAVING_FILENAME SAVING_DIRECTORY "/jetpack.save"
|
||||
#define SAVING_FILENAME APP_DATA_PATH("jetpack.save")
|
||||
static GameState* global_state;
|
||||
|
||||
typedef enum {
|
||||
@@ -41,6 +40,7 @@ static SaveGame save_game;
|
||||
|
||||
static bool storage_game_state_load() {
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
storage_common_migrate(storage, EXT_PATH("apps/Games/jetpack.save"), SAVING_FILENAME);
|
||||
File* file = storage_file_alloc(storage);
|
||||
|
||||
uint16_t bytes_readed = 0;
|
||||
@@ -55,12 +55,6 @@ static bool storage_game_state_load() {
|
||||
static void storage_game_state_save() {
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
if(storage_common_stat(storage, SAVING_DIRECTORY, NULL) == FSE_NOT_EXIST) {
|
||||
if(!storage_simply_mkdir(storage, SAVING_DIRECTORY)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
File* file = storage_file_alloc(storage);
|
||||
if(storage_file_open(file, SAVING_FILENAME, FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
|
||||
storage_file_write(file, &save_game, sizeof(SaveGame));
|
||||
@@ -376,4 +370,4 @@ free_and_exit:
|
||||
furi_message_queue_free(event_queue);
|
||||
|
||||
return return_code;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1686,6 +1686,7 @@ Function,+,furi_thread_suspend,void,FuriThreadId
|
||||
Function,+,furi_thread_yield,void,
|
||||
Function,+,furi_timer_alloc,FuriTimer*,"FuriTimerCallback, FuriTimerType, void*"
|
||||
Function,+,furi_timer_free,void,FuriTimer*
|
||||
Function,-,furi_timer_get_current_name,const char*,
|
||||
Function,+,furi_timer_is_running,uint32_t,FuriTimer*
|
||||
Function,+,furi_timer_pending_callback,void,"FuriTimerPendigCallback, void*, uint32_t"
|
||||
Function,+,furi_timer_start,FuriStatus,"FuriTimer*, uint32_t"
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#include "thread.h"
|
||||
#include "thread_i.h"
|
||||
#include "timer.h"
|
||||
#include "kernel.h"
|
||||
#include "memmgr.h"
|
||||
#include "memmgr_heap.h"
|
||||
@@ -9,6 +10,7 @@
|
||||
#include "string.h"
|
||||
|
||||
#include <task.h>
|
||||
#include <timers.h>
|
||||
#include "log.h"
|
||||
#include <furi_hal_rtc.h>
|
||||
#include <furi_hal_console.h>
|
||||
@@ -511,6 +513,11 @@ const char* furi_thread_get_appid(FuriThreadId thread_id) {
|
||||
FuriThread* thread = (FuriThread*)pvTaskGetThreadLocalStoragePointer(hTask, 0);
|
||||
if(thread) {
|
||||
appid = thread->appid;
|
||||
} else if(hTask == xTimerGetTimerDaemonTaskHandle()) {
|
||||
const char* timer = furi_timer_get_current_name();
|
||||
if(timer) {
|
||||
appid = timer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-2
@@ -1,4 +1,5 @@
|
||||
#include "timer.h"
|
||||
#include "thread.h"
|
||||
#include "check.h"
|
||||
#include "memmgr.h"
|
||||
#include "kernel.h"
|
||||
@@ -6,11 +7,17 @@
|
||||
#include <FreeRTOS.h>
|
||||
#include <timers.h>
|
||||
|
||||
const char* current_timer_name = NULL;
|
||||
|
||||
typedef struct {
|
||||
FuriTimerCallback func;
|
||||
void* context;
|
||||
} TimerCallback_t;
|
||||
|
||||
const char* furi_timer_get_current_name() {
|
||||
return current_timer_name;
|
||||
}
|
||||
|
||||
static void TimerCallback(TimerHandle_t hTimer) {
|
||||
TimerCallback_t* callb;
|
||||
|
||||
@@ -21,7 +28,9 @@ static void TimerCallback(TimerHandle_t hTimer) {
|
||||
callb = (TimerCallback_t*)((uint32_t)callb & ~1U);
|
||||
|
||||
if(callb != NULL) {
|
||||
current_timer_name = pcTimerGetName(hTimer);
|
||||
callb->func(callb->context);
|
||||
current_timer_name = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,11 +56,14 @@ FuriTimer* furi_timer_alloc(FuriTimerCallback func, FuriTimerType type, void* co
|
||||
reload = pdTRUE;
|
||||
}
|
||||
|
||||
// Timer name so thread appid works in timers, and so does APP_DATA_PATH()
|
||||
const char* name = furi_thread_get_appid(furi_thread_get_current_id());
|
||||
|
||||
/* Store callback memory dynamic allocation flag */
|
||||
callb = (TimerCallback_t*)((uint32_t)callb | 1U);
|
||||
// TimerCallback function is always provided as a callback and is used to call application
|
||||
// specified function with its context both stored in structure callb.
|
||||
hTimer = xTimerCreate(NULL, 1, reload, callb, TimerCallback);
|
||||
hTimer = xTimerCreate(name, 1, reload, callb, TimerCallback);
|
||||
furi_check(hTimer);
|
||||
|
||||
/* Return timer ID */
|
||||
@@ -133,4 +145,4 @@ void furi_timer_pending_callback(FuriTimerPendigCallback callback, void* context
|
||||
ret = xTimerPendFunctionCall(callback, context, arg, FuriWaitForever);
|
||||
}
|
||||
furi_check(ret == pdPASS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,12 @@ typedef void (*FuriTimerPendigCallback)(void* context, uint32_t arg);
|
||||
|
||||
void furi_timer_pending_callback(FuriTimerPendigCallback callback, void* context, uint32_t arg);
|
||||
|
||||
/** Get currently executing timer name
|
||||
*
|
||||
* @return The pointer to the timer name, or NULL
|
||||
*/
|
||||
const char* furi_timer_get_current_name();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user