mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 00:28:36 -07:00
Rework xtreme settings and assets implementation
This commit is contained in:
@@ -6,7 +6,6 @@ App(
|
||||
"crypto_start",
|
||||
"rpc_start",
|
||||
"bt",
|
||||
"xtreme",
|
||||
"desktop",
|
||||
"loader",
|
||||
"power",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <notification/notification_messages.h>
|
||||
#include <gui/elements.h>
|
||||
#include <assets_icons.h>
|
||||
#include "xtreme/assets.h"
|
||||
#include <xtreme.h>
|
||||
|
||||
#define TAG "BtSrv"
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "animation_storage.h"
|
||||
#include "animation_manager.h"
|
||||
|
||||
#include "xtreme/assets.h"
|
||||
#include <xtreme.h>
|
||||
|
||||
#define TAG "AnimationManager"
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "animation_storage_i.h"
|
||||
#include <assets_dolphin_internal.h>
|
||||
#include <assets_dolphin_blocking.h>
|
||||
#include "xtreme/assets.h"
|
||||
#include <xtreme.h>
|
||||
#define ANIMATION_META_FILE "meta.txt"
|
||||
#define BASE_ANIMATION_DIR EXT_PATH("dolphin")
|
||||
#define TAG "AnimationStorage"
|
||||
@@ -20,7 +20,7 @@
|
||||
#define ANIMATION_MANIFEST_FILE ANIMATION_DIR "/manifest.txt"
|
||||
|
||||
*/
|
||||
// 59 Max length = strlen("/ext/dolphin_custom//Anims") + MAX_PACK_NAME_LEN + 1 (Null terminator)
|
||||
// 59 Max length = strlen("/ext/dolphin_custom//Anims") + XTREME_ASSETS_PACK_NAME_LEN + 1 (Null terminator)
|
||||
char ANIMATION_DIR[59];
|
||||
// 72 Max length = ANIMATION_DIR + strlen("/manifest.txt")
|
||||
char ANIMATION_MANIFEST_FILE[72];
|
||||
@@ -36,7 +36,7 @@ void animation_handler_select_manifest(bool force_stock) {
|
||||
FuriString* manifest = furi_string_alloc();
|
||||
bool use_asset_pack = !force_stock && xtreme_settings->asset_pack[0] != '\0';
|
||||
if(use_asset_pack) {
|
||||
furi_string_printf(anim_dir, "%s/%s/Anims", PACKS_DIR, xtreme_settings->asset_pack);
|
||||
furi_string_printf(anim_dir, "%s/%s/Anims", XTREME_ASSETS_PATH, xtreme_settings->asset_pack);
|
||||
furi_string_printf(manifest, "%s/manifest.txt", furi_string_get_cstr(anim_dir));
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
if(storage_common_stat(storage, furi_string_get_cstr(manifest), NULL) == FSE_OK) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "desktop/views/desktop_view_pin_timeout.h"
|
||||
#include "desktop_i.h"
|
||||
#include "helpers/pin_lock.h"
|
||||
#include <xtreme/private.h>
|
||||
|
||||
#define TAG "Desktop"
|
||||
|
||||
@@ -347,6 +348,10 @@ int32_t desktop_srv(void* p) {
|
||||
furi_hal_rtc_reset_flag(FuriHalRtcFlagResetPin);
|
||||
}
|
||||
|
||||
// furi_delay_ms(1000);
|
||||
XTREME_SETTINGS_LOAD();
|
||||
XTREME_ASSETS_LOAD();
|
||||
|
||||
Desktop* desktop = desktop_alloc();
|
||||
|
||||
bool loaded = DESKTOP_SETTINGS_LOAD(&desktop->settings);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "../desktop_i.h"
|
||||
#include <cli/cli.h>
|
||||
#include <cli/cli_vcp.h>
|
||||
#include <xtreme/settings.h>
|
||||
#include <xtreme.h>
|
||||
|
||||
static const NotificationSequence sequence_pin_fail = {
|
||||
&message_display_backlight_on,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <furi_hal.h>
|
||||
|
||||
#include "../desktop_i.h"
|
||||
#include "xtreme/assets.h"
|
||||
#include <xtreme.h>
|
||||
|
||||
#define DesktopFaultEventExit 0x00FF00FF
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <loader/loader.h>
|
||||
// #include <loader/loader_i.h>
|
||||
#include <xtreme/settings.h>
|
||||
#include <xtreme.h>
|
||||
|
||||
#include "../desktop_i.h"
|
||||
#include <desktop/desktop_settings.h>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <furi.h>
|
||||
#include <gui/elements.h>
|
||||
#include <assets_icons.h>
|
||||
#include <xtreme/settings.h>
|
||||
#include <xtreme.h>
|
||||
#include <furi_hal_rtc.h>
|
||||
|
||||
#include "../desktop_i.h"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <assets_icons.h>
|
||||
#include <portmacro.h>
|
||||
#include <locale/locale.h>
|
||||
#include <xtreme/assets.h>
|
||||
#include <xtreme.h>
|
||||
|
||||
#include <desktop/desktop_settings.h>
|
||||
#include "../desktop_i.h"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <furi_hal.h>
|
||||
#include <stdint.h>
|
||||
#include <furi.h>
|
||||
#include <xtreme/settings.h>
|
||||
#include <xtreme.h>
|
||||
#define DOLPHIN_LOCK_EVENT_FLAG (0x1)
|
||||
|
||||
#define TAG "Dolphin"
|
||||
|
||||
@@ -7,7 +7,6 @@ App(
|
||||
requires=[
|
||||
"input",
|
||||
"notification",
|
||||
"xtreme",
|
||||
],
|
||||
stack_size=2 * 1024,
|
||||
order=70,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <furi_hal_rtc.h>
|
||||
#include <stdint.h>
|
||||
#include <u8g2_glue.h>
|
||||
#include <xtreme/settings.h>
|
||||
#include <xtreme.h>
|
||||
|
||||
const CanvasFontParameters canvas_font_params[FontTotalNumber] = {
|
||||
[FontPrimary] = {.leading_default = 12, .leading_min = 11, .height = 8, .descender = 2},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "xtreme/settings.h"
|
||||
#include <xtreme.h>
|
||||
#include "gui_i.h"
|
||||
#include <assets_icons.h>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <core/log.h>
|
||||
#include "m-algo.h"
|
||||
#include <m-array.h>
|
||||
#include "xtreme/settings.h"
|
||||
#include <xtreme.h>
|
||||
|
||||
#define LIST_ITEMS 5u
|
||||
#define MAX_LEN_PX 110
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <gui/icon_animation_i.h>
|
||||
#include <furi.h>
|
||||
#include <m-array.h>
|
||||
#include <xtreme/settings.h>
|
||||
#include <xtreme.h>
|
||||
#include <m-string.h>
|
||||
|
||||
struct Menu {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <gui/icon_i.h>
|
||||
#include <core/dangerous_defines.h>
|
||||
#include <toolbox/stream/file_stream.h>
|
||||
#include <xtreme/settings.h>
|
||||
#include <xtreme.h>
|
||||
#include <gui/modules/file_browser.h>
|
||||
|
||||
#define TAG "LoaderSrv"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
#include "xtreme/settings.h"
|
||||
#include <xtreme.h>
|
||||
|
||||
#define POWER_OFF_TIMEOUT 90
|
||||
#define TAG "Power"
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
App(
|
||||
appid="xtreme",
|
||||
name="Xtreme",
|
||||
apptype=FlipperAppType.SERVICE,
|
||||
entry_point="xtreme_srv",
|
||||
cdefines=["SRV_XTREME"],
|
||||
requires=["storage"],
|
||||
stack_size=2 * 1024,
|
||||
order=46,
|
||||
sdk_headers=[
|
||||
"settings.h",
|
||||
"assets.h",
|
||||
],
|
||||
)
|
||||
@@ -1,181 +0,0 @@
|
||||
#include "assets.h"
|
||||
#include <assets_icons.h>
|
||||
#include <core/dangerous_defines.h>
|
||||
|
||||
#define TAG "XtremeAssets"
|
||||
|
||||
#define ICONS_FMT PACKS_DIR "/%s/Icons/%s"
|
||||
|
||||
XtremeAssets* xtreme_assets = NULL;
|
||||
|
||||
void anim(const Icon** replace, const char* name, FuriString* path, File* file) {
|
||||
do {
|
||||
furi_string_printf(path, ICONS_FMT "/meta", XTREME_SETTINGS()->asset_pack, name);
|
||||
if(!storage_file_open(file, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING))
|
||||
break;
|
||||
int32_t width, height, frame_rate, frame_count;
|
||||
storage_file_read(file, &width, 4);
|
||||
storage_file_read(file, &height, 4);
|
||||
storage_file_read(file, &frame_rate, 4);
|
||||
storage_file_read(file, &frame_count, 4);
|
||||
storage_file_close(file);
|
||||
|
||||
Icon* icon = malloc(sizeof(Icon));
|
||||
FURI_CONST_ASSIGN(icon->width, width);
|
||||
FURI_CONST_ASSIGN(icon->height, height);
|
||||
FURI_CONST_ASSIGN(icon->frame_rate, frame_rate);
|
||||
FURI_CONST_ASSIGN(icon->frame_count, frame_count);
|
||||
icon->frames = malloc(sizeof(const uint8_t*) * icon->frame_count);
|
||||
const char* pack = XTREME_SETTINGS()->asset_pack;
|
||||
|
||||
bool ok = true;
|
||||
for(int i = 0; i < icon->frame_count; ++i) {
|
||||
FURI_CONST_ASSIGN_PTR(icon->frames[i], 0);
|
||||
if(ok) {
|
||||
ok = false;
|
||||
furi_string_printf(path, ICONS_FMT "/frame_%02d.bm", pack, name, i);
|
||||
do {
|
||||
if(!storage_file_open(
|
||||
file, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING))
|
||||
break;
|
||||
|
||||
uint64_t size = storage_file_size(file);
|
||||
FURI_CONST_ASSIGN_PTR(icon->frames[i], malloc(size));
|
||||
if(storage_file_read(file, (void*)icon->frames[i], size) == size) ok = true;
|
||||
storage_file_close(file);
|
||||
} while(0);
|
||||
}
|
||||
}
|
||||
if(!ok) {
|
||||
for(int i = 0; i < icon->frame_count; ++i) {
|
||||
if(icon->frames[i]) {
|
||||
free((void*)icon->frames[i]);
|
||||
}
|
||||
}
|
||||
free((void*)icon->frames);
|
||||
free(icon);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
*replace = icon;
|
||||
} while(false);
|
||||
}
|
||||
|
||||
void icon(const Icon** replace, const char* name, FuriString* path, File* file) {
|
||||
furi_string_printf(path, ICONS_FMT ".bmx", XTREME_SETTINGS()->asset_pack, name);
|
||||
if(storage_file_open(file, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
uint64_t size = storage_file_size(file) - 8;
|
||||
int32_t width, height;
|
||||
storage_file_read(file, &width, 4);
|
||||
storage_file_read(file, &height, 4);
|
||||
|
||||
Icon* icon = malloc(sizeof(Icon));
|
||||
FURI_CONST_ASSIGN(icon->frame_count, 1);
|
||||
FURI_CONST_ASSIGN(icon->frame_rate, 0);
|
||||
FURI_CONST_ASSIGN(icon->width, width);
|
||||
FURI_CONST_ASSIGN(icon->height, height);
|
||||
icon->frames = malloc(sizeof(const uint8_t*));
|
||||
FURI_CONST_ASSIGN_PTR(icon->frames[0], malloc(size));
|
||||
storage_file_read(file, (void*)icon->frames[0], size);
|
||||
*replace = icon;
|
||||
|
||||
storage_file_close(file);
|
||||
}
|
||||
}
|
||||
|
||||
void swap(XtremeAssets* x, FuriString* p, File* f) {
|
||||
anim(&x->A_Levelup_128x64, "Animations/Levelup_128x64", p, f);
|
||||
icon(&x->I_BLE_Pairing_128x64, "BLE/BLE_Pairing_128x64", p, f);
|
||||
icon(&x->I_DolphinCommon_56x48, "Dolphin/DolphinCommon_56x48", p, f);
|
||||
icon(&x->I_DolphinMafia_115x62, "iButton/DolphinMafia_115x62", p, f);
|
||||
icon(&x->I_DolphinNice_96x59, "iButton/DolphinNice_96x59", p, f);
|
||||
icon(&x->I_DolphinWait_61x59, "iButton/DolphinWait_61x59", p, f);
|
||||
icon(&x->I_iButtonDolphinVerySuccess_108x52, "iButton/iButtonDolphinVerySuccess_108x52", p, f);
|
||||
icon(&x->I_DolphinReadingSuccess_59x63, "Infrared/DolphinReadingSuccess_59x63", p, f);
|
||||
icon(&x->I_Lockscreen, "Interface/Lockscreen", p, f);
|
||||
icon(&x->I_WarningDolphin_45x42, "Interface/WarningDolphin_45x42", p, f);
|
||||
icon(&x->I_NFC_dolphin_emulation_47x61, "NFC/NFC_dolphin_emulation_47x61", p, f);
|
||||
icon(&x->I_passport_bad_46x49, "Passport/passport_bad_46x49", p, f);
|
||||
icon(&x->I_passport_DB, "Passport/passport_DB", p, f);
|
||||
icon(&x->I_passport_happy_46x49, "Passport/passport_happy_46x49", p, f);
|
||||
icon(&x->I_passport_okay_46x49, "Passport/passport_okay_46x49", p, f);
|
||||
icon(&x->I_RFIDDolphinReceive_97x61, "RFID/RFIDDolphinReceive_97x61", p, f);
|
||||
icon(&x->I_RFIDDolphinSend_97x61, "RFID/RFIDDolphinSend_97x61", p, f);
|
||||
icon(&x->I_RFIDDolphinSuccess_108x57, "RFID/RFIDDolphinSuccess_108x57", p, f);
|
||||
icon(&x->I_Cry_dolph_55x52, "Settings/Cry_dolph_55x52", p, f);
|
||||
icon(&x->I_Fishing_123x52, "SubGhz/Fishing_123x52", p, f);
|
||||
icon(&x->I_Scanning_123x52, "SubGhz/Scanning_123x52", p, f);
|
||||
icon(&x->I_Auth_62x31, "U2F/Auth_62x31", p, f);
|
||||
icon(&x->I_Connect_me_62x31, "U2F/Connect_me_62x31", p, f);
|
||||
icon(&x->I_Connected_62x31, "U2F/Connected_62x31", p, f);
|
||||
icon(&x->I_Error_62x31, "U2F/Error_62x31", p, f);
|
||||
}
|
||||
|
||||
void XTREME_ASSETS_LOAD() {
|
||||
if(xtreme_assets != NULL) return;
|
||||
|
||||
xtreme_assets = malloc(sizeof(XtremeAssets));
|
||||
|
||||
xtreme_assets->A_Levelup_128x64 = &A_Levelup_128x64;
|
||||
xtreme_assets->I_BLE_Pairing_128x64 = &I_BLE_Pairing_128x64;
|
||||
xtreme_assets->I_DolphinCommon_56x48 = &I_DolphinCommon_56x48;
|
||||
xtreme_assets->I_DolphinMafia_115x62 = &I_DolphinMafia_115x62;
|
||||
xtreme_assets->I_DolphinNice_96x59 = &I_DolphinNice_96x59;
|
||||
xtreme_assets->I_DolphinWait_61x59 = &I_DolphinWait_61x59;
|
||||
xtreme_assets->I_iButtonDolphinVerySuccess_108x52 = &I_iButtonDolphinVerySuccess_108x52;
|
||||
xtreme_assets->I_DolphinReadingSuccess_59x63 = &I_DolphinReadingSuccess_59x63;
|
||||
xtreme_assets->I_Lockscreen = &I_Lockscreen;
|
||||
xtreme_assets->I_WarningDolphin_45x42 = &I_WarningDolphin_45x42;
|
||||
xtreme_assets->I_NFC_dolphin_emulation_47x61 = &I_NFC_dolphin_emulation_47x61;
|
||||
xtreme_assets->I_passport_bad_46x49 = &I_passport_bad_46x49;
|
||||
xtreme_assets->I_passport_DB = &I_passport_DB;
|
||||
xtreme_assets->I_passport_happy_46x49 = &I_passport_happy_46x49;
|
||||
xtreme_assets->I_passport_okay_46x49 = &I_passport_okay_46x49;
|
||||
xtreme_assets->I_RFIDDolphinReceive_97x61 = &I_RFIDDolphinReceive_97x61;
|
||||
xtreme_assets->I_RFIDDolphinSend_97x61 = &I_RFIDDolphinSend_97x61;
|
||||
xtreme_assets->I_RFIDDolphinSuccess_108x57 = &I_RFIDDolphinSuccess_108x57;
|
||||
xtreme_assets->I_Cry_dolph_55x52 = &I_Cry_dolph_55x52;
|
||||
xtreme_assets->I_Fishing_123x52 = &I_Fishing_123x52;
|
||||
xtreme_assets->I_Scanning_123x52 = &I_Scanning_123x52;
|
||||
xtreme_assets->I_Auth_62x31 = &I_Auth_62x31;
|
||||
xtreme_assets->I_Connect_me_62x31 = &I_Connect_me_62x31;
|
||||
xtreme_assets->I_Connected_62x31 = &I_Connected_62x31;
|
||||
xtreme_assets->I_Error_62x31 = &I_Error_62x31;
|
||||
|
||||
if(!furi_hal_is_normal_boot()) {
|
||||
FURI_LOG_W(TAG, "Load skipped. Device is in special startup mode.");
|
||||
return;
|
||||
}
|
||||
|
||||
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
|
||||
if(xtreme_settings->asset_pack[0] == '\0') return;
|
||||
xtreme_assets->is_nsfw = strncmp(xtreme_settings->asset_pack, "NSFW", strlen("NSFW")) == 0;
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
int32_t timeout = 5000;
|
||||
while(timeout > 0) {
|
||||
if(storage_sd_status(storage) == FSE_OK) break;
|
||||
furi_delay_ms(250);
|
||||
timeout -= 250;
|
||||
}
|
||||
|
||||
FileInfo info;
|
||||
FuriString* path = furi_string_alloc();
|
||||
furi_string_printf(path, PACKS_DIR "/%s", xtreme_settings->asset_pack);
|
||||
if(storage_common_stat(storage, furi_string_get_cstr(path), &info) == FSE_OK &&
|
||||
info.flags & FSF_DIRECTORY) {
|
||||
File* file = storage_file_alloc(storage);
|
||||
swap(xtreme_assets, path, file);
|
||||
storage_file_free(file);
|
||||
}
|
||||
furi_string_free(path);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
XtremeAssets* XTREME_ASSETS() {
|
||||
if(xtreme_assets == NULL) {
|
||||
XTREME_ASSETS_LOAD();
|
||||
}
|
||||
return xtreme_assets;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "settings.h"
|
||||
#include <gui/icon_i.h>
|
||||
#include <toolbox/path.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PACKS_DIR EXT_PATH("dolphin_custom")
|
||||
|
||||
typedef struct {
|
||||
bool is_nsfw;
|
||||
const Icon* A_Levelup_128x64;
|
||||
const Icon* I_BLE_Pairing_128x64;
|
||||
const Icon* I_DolphinCommon_56x48;
|
||||
const Icon* I_DolphinMafia_115x62;
|
||||
const Icon* I_DolphinNice_96x59;
|
||||
const Icon* I_DolphinWait_61x59;
|
||||
const Icon* I_iButtonDolphinVerySuccess_108x52;
|
||||
const Icon* I_DolphinReadingSuccess_59x63;
|
||||
const Icon* I_Lockscreen;
|
||||
const Icon* I_WarningDolphin_45x42;
|
||||
const Icon* I_NFC_dolphin_emulation_47x61;
|
||||
const Icon* I_passport_bad_46x49;
|
||||
const Icon* I_passport_DB;
|
||||
const Icon* I_passport_happy_46x49;
|
||||
const Icon* I_passport_okay_46x49;
|
||||
const Icon* I_RFIDDolphinReceive_97x61;
|
||||
const Icon* I_RFIDDolphinSend_97x61;
|
||||
const Icon* I_RFIDDolphinSuccess_108x57;
|
||||
const Icon* I_Cry_dolph_55x52;
|
||||
const Icon* I_Fishing_123x52;
|
||||
const Icon* I_Scanning_123x52;
|
||||
const Icon* I_Auth_62x31;
|
||||
const Icon* I_Connect_me_62x31;
|
||||
const Icon* I_Connected_62x31;
|
||||
const Icon* I_Error_62x31;
|
||||
} XtremeAssets;
|
||||
|
||||
void XTREME_ASSETS_LOAD();
|
||||
|
||||
XtremeAssets* XTREME_ASSETS();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,145 +0,0 @@
|
||||
#include "settings.h"
|
||||
|
||||
#include <lib/flipper_format/flipper_format.h>
|
||||
|
||||
#define TAG "XtremeSettings"
|
||||
|
||||
XtremeSettings* xtreme_settings = NULL;
|
||||
|
||||
XtremeSettings* XTREME_SETTINGS() {
|
||||
if(xtreme_settings == NULL) {
|
||||
XTREME_SETTINGS_LOAD();
|
||||
}
|
||||
return xtreme_settings;
|
||||
}
|
||||
|
||||
void XTREME_SETTINGS_LOAD() {
|
||||
if(xtreme_settings == NULL) {
|
||||
xtreme_settings = malloc(sizeof(XtremeSettings));
|
||||
|
||||
// Set default values
|
||||
memset(xtreme_settings, 0, sizeof(XtremeSettings));
|
||||
strlcpy(xtreme_settings->asset_pack, "", MAX_PACK_NAME_LEN); // SFW
|
||||
xtreme_settings->anim_speed = 100; // 100%
|
||||
xtreme_settings->cycle_anims = 0; // Meta.txt
|
||||
xtreme_settings->unlock_anims = false; // OFF
|
||||
xtreme_settings->fallback_anim = true; // ON
|
||||
xtreme_settings->wii_menu = true; // ON
|
||||
xtreme_settings->bad_pins_format = false; // OFF
|
||||
xtreme_settings->lockscreen_time = true; // ON
|
||||
xtreme_settings->lockscreen_seconds = false; // OFF
|
||||
xtreme_settings->lockscreen_date = true; // ON
|
||||
xtreme_settings->lockscreen_statusbar = true; // ON
|
||||
xtreme_settings->lockscreen_prompt = true; // ON
|
||||
xtreme_settings->battery_icon = BatteryIconBarPercent; // Bar %
|
||||
xtreme_settings->status_icons = true; // ON
|
||||
xtreme_settings->bar_borders = true; // ON
|
||||
xtreme_settings->bar_background = false; // OFF
|
||||
xtreme_settings->sort_dirs_first = true; // ON
|
||||
xtreme_settings->dark_mode = false; // OFF
|
||||
xtreme_settings->bad_bt = false; // USB
|
||||
xtreme_settings->bad_bt_remember = false; // OFF
|
||||
xtreme_settings->butthurt_timer = 43200; // 12 H
|
||||
xtreme_settings->rgb_backlight = false; // OFF
|
||||
|
||||
if(!furi_hal_is_normal_boot()) {
|
||||
FURI_LOG_W(TAG, "Load skipped. Device is in special startup mode.");
|
||||
return;
|
||||
}
|
||||
|
||||
XtremeSettings* x = xtreme_settings;
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
if(flipper_format_file_open_existing(file, XTREME_SETTINGS_PATH)) {
|
||||
FuriString* string = furi_string_alloc();
|
||||
if(flipper_format_read_string(file, "asset_pack", string)) {
|
||||
strlcpy(x->asset_pack, furi_string_get_cstr(string), MAX_PACK_NAME_LEN);
|
||||
}
|
||||
furi_string_free(string);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_uint32(file, "anim_speed", &x->anim_speed, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_int32(file, "cycle_anims", &x->cycle_anims, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_bool(file, "unlock_anims", &x->unlock_anims, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_bool(file, "fallback_anim", &x->fallback_anim, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_bool(file, "wii_menu", &x->wii_menu, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_bool(file, "bad_pins_format", &x->bad_pins_format, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_bool(file, "lockscreen_time", &x->lockscreen_time, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_bool(file, "lockscreen_seconds", &x->lockscreen_seconds, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_bool(file, "lockscreen_date", &x->lockscreen_date, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_bool(file, "lockscreen_statusbar", &x->lockscreen_statusbar, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_bool(file, "lockscreen_prompt", &x->lockscreen_prompt, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_uint32(file, "battery_icon", (uint32_t*)&x->battery_icon, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_bool(file, "status_icons", &x->status_icons, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_bool(file, "bar_borders", &x->bar_borders, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_bool(file, "bar_background", &x->bar_background, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_bool(file, "sort_dirs_first", &x->sort_dirs_first, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_bool(file, "dark_mode", &x->dark_mode, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_bool(file, "bad_bt", &x->bad_bt, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_bool(file, "bad_bt_remember", &x->bad_bt_remember, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_int32(file, "butthurt_timer", &x->butthurt_timer, 1);
|
||||
flipper_format_rewind(file);
|
||||
flipper_format_read_bool(file, "rgb_backlight", &x->rgb_backlight, 1);
|
||||
}
|
||||
flipper_format_free(file);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
}
|
||||
|
||||
void XTREME_SETTINGS_SAVE() {
|
||||
if(xtreme_settings == NULL) {
|
||||
XTREME_SETTINGS_LOAD();
|
||||
}
|
||||
|
||||
if(!furi_hal_is_normal_boot()) {
|
||||
return;
|
||||
}
|
||||
|
||||
XtremeSettings* x = xtreme_settings;
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
if(flipper_format_file_open_always(file, XTREME_SETTINGS_PATH)) {
|
||||
flipper_format_write_string_cstr(file, "asset_pack", x->asset_pack);
|
||||
flipper_format_write_uint32(file, "anim_speed", &x->anim_speed, 1);
|
||||
flipper_format_write_int32(file, "cycle_anims", &x->cycle_anims, 1);
|
||||
flipper_format_write_bool(file, "unlock_anims", &x->unlock_anims, 1);
|
||||
flipper_format_write_bool(file, "fallback_anim", &x->fallback_anim, 1);
|
||||
flipper_format_write_bool(file, "wii_menu", &x->wii_menu, 1);
|
||||
flipper_format_write_bool(file, "bad_pins_format", &x->bad_pins_format, 1);
|
||||
flipper_format_write_bool(file, "lockscreen_time", &x->lockscreen_time, 1);
|
||||
flipper_format_write_bool(file, "lockscreen_seconds", &x->lockscreen_seconds, 1);
|
||||
flipper_format_write_bool(file, "lockscreen_date", &x->lockscreen_date, 1);
|
||||
flipper_format_write_bool(file, "lockscreen_statusbar", &x->lockscreen_statusbar, 1);
|
||||
flipper_format_write_bool(file, "lockscreen_prompt", &x->lockscreen_prompt, 1);
|
||||
flipper_format_write_uint32(file, "battery_icon", (uint32_t*)&x->battery_icon, 1);
|
||||
flipper_format_write_bool(file, "status_icons", &x->status_icons, 1);
|
||||
flipper_format_write_bool(file, "bar_borders", &x->bar_borders, 1);
|
||||
flipper_format_write_bool(file, "bar_background", &x->bar_background, 1);
|
||||
flipper_format_write_bool(file, "sort_dirs_first", &x->sort_dirs_first, 1);
|
||||
flipper_format_write_bool(file, "dark_mode", &x->dark_mode, 1);
|
||||
flipper_format_write_bool(file, "bad_bt", &x->bad_bt, 1);
|
||||
flipper_format_write_bool(file, "bad_bt_remember", &x->bad_bt_remember, 1);
|
||||
flipper_format_write_int32(file, "butthurt_timer", &x->butthurt_timer, 1);
|
||||
flipper_format_write_bool(file, "rgb_backlight", &x->rgb_backlight, 1);
|
||||
}
|
||||
flipper_format_free(file);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <furi_hal.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <storage/storage.h>
|
||||
#include <power/power_service/power.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MAX_PACK_NAME_LEN 32
|
||||
|
||||
#define XTREME_SETTINGS_PATH CFG_PATH("xtreme_settings.txt")
|
||||
|
||||
#define XTREME_APPS_PATH CFG_PATH("xtreme_apps.txt")
|
||||
|
||||
typedef struct {
|
||||
char asset_pack[MAX_PACK_NAME_LEN];
|
||||
uint32_t anim_speed;
|
||||
int32_t cycle_anims;
|
||||
bool unlock_anims;
|
||||
bool fallback_anim;
|
||||
bool wii_menu;
|
||||
bool bad_pins_format;
|
||||
bool lockscreen_time;
|
||||
bool lockscreen_seconds;
|
||||
bool lockscreen_date;
|
||||
bool lockscreen_statusbar;
|
||||
bool lockscreen_prompt;
|
||||
BatteryIcon battery_icon;
|
||||
bool status_icons;
|
||||
bool bar_borders;
|
||||
bool bar_background;
|
||||
bool sort_dirs_first;
|
||||
bool dark_mode;
|
||||
bool bad_bt;
|
||||
bool bad_bt_remember;
|
||||
int32_t butthurt_timer;
|
||||
bool rgb_backlight;
|
||||
} XtremeSettings;
|
||||
|
||||
XtremeSettings* XTREME_SETTINGS();
|
||||
|
||||
void XTREME_SETTINGS_LOAD();
|
||||
|
||||
void XTREME_SETTINGS_SAVE();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
#include "settings.h"
|
||||
#include "assets.h"
|
||||
|
||||
int32_t xtreme_srv(void* p) {
|
||||
UNUSED(p);
|
||||
|
||||
XTREME_SETTINGS_LOAD();
|
||||
XTREME_ASSETS_LOAD();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user