mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 15:28:36 -07:00
Fix xtreme settings values handling
This commit is contained in:
@@ -17,7 +17,7 @@ void favorite_timeout_callback(void* _ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void favorite_timeout_run(ViewDispatcher* view_dispatcher, SceneManager* scene_manager) {
|
void favorite_timeout_run(ViewDispatcher* view_dispatcher, SceneManager* scene_manager) {
|
||||||
int32_t timeout = XTREME_SETTINGS()->favorite_timeout;
|
uint32_t timeout = XTREME_SETTINGS()->favorite_timeout;
|
||||||
if(timeout == 0) {
|
if(timeout == 0) {
|
||||||
view_dispatcher_run(view_dispatcher);
|
view_dispatcher_run(view_dispatcher);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ static void xtreme_app_scene_interface_graphics_asset_pack_changed(VariableItem*
|
|||||||
|
|
||||||
const char* const anim_speed_names[] =
|
const char* const anim_speed_names[] =
|
||||||
{"25%", "50%", "75%", "100%", "125%", "150%", "175%", "200%", "225%", "250%", "275%", "300%"};
|
{"25%", "50%", "75%", "100%", "125%", "150%", "175%", "200%", "225%", "250%", "275%", "300%"};
|
||||||
const int32_t anim_speed_values[COUNT_OF(anim_speed_names)] =
|
const uint32_t anim_speed_values[COUNT_OF(anim_speed_names)] =
|
||||||
{25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300};
|
{25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300};
|
||||||
static void xtreme_app_scene_interface_graphics_anim_speed_changed(VariableItem* item) {
|
static void xtreme_app_scene_interface_graphics_anim_speed_changed(VariableItem* item) {
|
||||||
XtremeApp* app = variable_item_get_context(item);
|
XtremeApp* app = variable_item_get_context(item);
|
||||||
@@ -104,8 +104,8 @@ void xtreme_app_scene_interface_graphics_on_enter(void* context) {
|
|||||||
COUNT_OF(anim_speed_names),
|
COUNT_OF(anim_speed_names),
|
||||||
xtreme_app_scene_interface_graphics_anim_speed_changed,
|
xtreme_app_scene_interface_graphics_anim_speed_changed,
|
||||||
app);
|
app);
|
||||||
value_index = value_index_int32(
|
value_index = value_index_uint32(
|
||||||
xtreme_settings->anim_speed, anim_speed_values, COUNT_OF(anim_speed_names));
|
xtreme_settings->anim_speed, anim_speed_values, COUNT_OF(anim_speed_values));
|
||||||
variable_item_set_current_value_index(item, value_index);
|
variable_item_set_current_value_index(item, value_index);
|
||||||
variable_item_set_current_value_text(item, anim_speed_names[value_index]);
|
variable_item_set_current_value_text(item, anim_speed_names[value_index]);
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ void xtreme_app_scene_interface_graphics_on_enter(void* context) {
|
|||||||
xtreme_app_scene_interface_graphics_cycle_anims_changed,
|
xtreme_app_scene_interface_graphics_cycle_anims_changed,
|
||||||
app);
|
app);
|
||||||
value_index = value_index_int32(
|
value_index = value_index_int32(
|
||||||
xtreme_settings->cycle_anims, cycle_anims_values, COUNT_OF(cycle_anims_names));
|
xtreme_settings->cycle_anims, cycle_anims_values, COUNT_OF(cycle_anims_values));
|
||||||
variable_item_set_current_value_index(item, value_index);
|
variable_item_set_current_value_index(item, value_index);
|
||||||
variable_item_set_current_value_text(item, cycle_anims_names[value_index]);
|
variable_item_set_current_value_text(item, cycle_anims_names[value_index]);
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ void xtreme_app_scene_interface_statusbar_var_item_list_callback(void* context,
|
|||||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* const battery_icon_names[] =
|
const char* const battery_icon_names[BatteryIconCount] =
|
||||||
{"OFF", "Bar", "%", "Inv. %", "Retro 3", "Retro 5", "Bar %"};
|
{"OFF", "Bar", "%", "Inv. %", "Retro 3", "Retro 5", "Bar %"};
|
||||||
static void xtreme_app_scene_interface_statusbar_battery_icon_changed(VariableItem* item) {
|
static void xtreme_app_scene_interface_statusbar_battery_icon_changed(VariableItem* item) {
|
||||||
XtremeApp* app = variable_item_get_context(item);
|
XtremeApp* app = variable_item_get_context(item);
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ static void xtreme_app_scene_misc_dolphin_angry_changed(VariableItem* item) {
|
|||||||
|
|
||||||
const char* const butthurt_timer_names[] =
|
const char* const butthurt_timer_names[] =
|
||||||
{"OFF", "30 M", "1 H", "2 H", "4 H", "6 H", "8 H", "12 H", "24 H", "48 H"};
|
{"OFF", "30 M", "1 H", "2 H", "4 H", "6 H", "8 H", "12 H", "24 H", "48 H"};
|
||||||
const int32_t butthurt_timer_values[COUNT_OF(butthurt_timer_names)] =
|
const uint32_t butthurt_timer_values[COUNT_OF(butthurt_timer_names)] =
|
||||||
{-1, 1800, 3600, 7200, 14400, 21600, 28800, 43200, 86400, 172800};
|
{0, 1800, 3600, 7200, 14400, 21600, 28800, 43200, 86400, 172800};
|
||||||
static void xtreme_app_scene_misc_butthurt_timer_changed(VariableItem* item) {
|
static void xtreme_app_scene_misc_butthurt_timer_changed(VariableItem* item) {
|
||||||
XtremeApp* app = variable_item_get_context(item);
|
XtremeApp* app = variable_item_get_context(item);
|
||||||
uint8_t index = variable_item_get_current_value_index(item);
|
uint8_t index = variable_item_get_current_value_index(item);
|
||||||
@@ -103,8 +103,8 @@ void xtreme_app_scene_misc_on_enter(void* context) {
|
|||||||
COUNT_OF(butthurt_timer_names),
|
COUNT_OF(butthurt_timer_names),
|
||||||
xtreme_app_scene_misc_butthurt_timer_changed,
|
xtreme_app_scene_misc_butthurt_timer_changed,
|
||||||
app);
|
app);
|
||||||
value_index = value_index_int32(
|
value_index = value_index_uint32(
|
||||||
xtreme_settings->butthurt_timer, butthurt_timer_values, COUNT_OF(butthurt_timer_names));
|
xtreme_settings->butthurt_timer, butthurt_timer_values, COUNT_OF(butthurt_timer_values));
|
||||||
variable_item_set_current_value_index(item, value_index);
|
variable_item_set_current_value_index(item, value_index);
|
||||||
variable_item_set_current_value_text(item, butthurt_timer_names[value_index]);
|
variable_item_set_current_value_text(item, butthurt_timer_names[value_index]);
|
||||||
|
|
||||||
|
|||||||
@@ -521,7 +521,7 @@ static BubbleAnimation* animation_storage_load_animation(const char* name) {
|
|||||||
if(!flipper_format_read_uint32(ff, "Active cycles", &u32value, 1)) break; //-V779
|
if(!flipper_format_read_uint32(ff, "Active cycles", &u32value, 1)) break; //-V779
|
||||||
animation->active_cycles = u32value;
|
animation->active_cycles = u32value;
|
||||||
if(!flipper_format_read_uint32(ff, "Frame rate", &u32value, 1)) break;
|
if(!flipper_format_read_uint32(ff, "Frame rate", &u32value, 1)) break;
|
||||||
uint16_t anim_speed = XTREME_SETTINGS()->anim_speed;
|
uint32_t anim_speed = XTREME_SETTINGS()->anim_speed;
|
||||||
u32value = (u32value * anim_speed) / 100;
|
u32value = (u32value * anim_speed) / 100;
|
||||||
FURI_CONST_ASSIGN(animation->icon_animation.frame_rate, u32value < 1 ? 1 : u32value);
|
FURI_CONST_ASSIGN(animation->icon_animation.frame_rate, u32value < 1 ? 1 : u32value);
|
||||||
if(!flipper_format_read_uint32(ff, "Duration", &u32value, 1)) break;
|
if(!flipper_format_read_uint32(ff, "Duration", &u32value, 1)) break;
|
||||||
|
|||||||
@@ -80,10 +80,10 @@ Dolphin* dolphin_alloc() {
|
|||||||
dolphin->state = dolphin_state_alloc();
|
dolphin->state = dolphin_state_alloc();
|
||||||
dolphin->event_queue = furi_message_queue_alloc(8, sizeof(DolphinEvent));
|
dolphin->event_queue = furi_message_queue_alloc(8, sizeof(DolphinEvent));
|
||||||
dolphin->pubsub = furi_pubsub_alloc();
|
dolphin->pubsub = furi_pubsub_alloc();
|
||||||
int32_t butthurt = XTREME_SETTINGS()->butthurt_timer;
|
uint32_t butthurt_timer = XTREME_SETTINGS()->butthurt_timer;
|
||||||
dolphin->butthurt_timer = xTimerCreate(
|
dolphin->butthurt_timer = xTimerCreate(
|
||||||
NULL,
|
NULL,
|
||||||
(butthurt > 0) ? (butthurt * 1000) : -1,
|
butthurt_timer ? ((int32_t)butthurt_timer * 1000) : -1,
|
||||||
pdTRUE,
|
pdTRUE,
|
||||||
dolphin,
|
dolphin,
|
||||||
dolphin_butthurt_timer_callback);
|
dolphin_butthurt_timer_callback);
|
||||||
|
|||||||
@@ -473,7 +473,8 @@ static void power_check_battery_level_change(Power* power) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void power_check_charge_cap(Power* power) {
|
static void power_check_charge_cap(Power* power) {
|
||||||
if(power->info.charge >= XTREME_SETTINGS()->charge_cap) {
|
uint32_t cap = XTREME_SETTINGS()->charge_cap;
|
||||||
|
if(power->info.charge >= cap && cap < 100) {
|
||||||
if(!power->info.is_charge_capped) { // Suppress charging if charge reaches custom cap
|
if(!power->info.is_charge_capped) { // Suppress charging if charge reaches custom cap
|
||||||
power->info.is_charge_capped = true;
|
power->info.is_charge_capped = true;
|
||||||
furi_hal_power_suppress_charge_enter();
|
furi_hal_power_suppress_charge_enter();
|
||||||
|
|||||||
@@ -46,54 +46,107 @@ void XTREME_SETTINGS_LOAD() {
|
|||||||
x->is_nsfw = strncmp(x->asset_pack, "NSFW", strlen("NSFW")) == 0;
|
x->is_nsfw = strncmp(x->asset_pack, "NSFW", strlen("NSFW")) == 0;
|
||||||
}
|
}
|
||||||
furi_string_free(string);
|
furi_string_free(string);
|
||||||
|
uint32_t u;
|
||||||
|
int32_t i;
|
||||||
|
bool b;
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_uint32(file, "anim_speed", &x->anim_speed, 1);
|
if(flipper_format_read_uint32(file, "anim_speed", &u, 1)) {
|
||||||
|
x->anim_speed = CLAMP(u, 300U, 25U);
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_int32(file, "cycle_anims", &x->cycle_anims, 1);
|
if(flipper_format_read_int32(file, "cycle_anims", &i, 1)) {
|
||||||
|
x->cycle_anims = CLAMP(i, 86400, -1);
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "unlock_anims", &x->unlock_anims, 1);
|
if(flipper_format_read_bool(file, "unlock_anims", &b, 1)) {
|
||||||
|
x->unlock_anims = b;
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "fallback_anim", &x->fallback_anim, 1);
|
if(flipper_format_read_bool(file, "fallback_anim", &b, 1)) {
|
||||||
|
x->fallback_anim = b;
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "wii_menu", &x->wii_menu, 1);
|
if(flipper_format_read_bool(file, "wii_menu", &b, 1)) {
|
||||||
|
x->wii_menu = b;
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "bad_pins_format", &x->bad_pins_format, 1);
|
if(flipper_format_read_bool(file, "bad_pins_format", &b, 1)) {
|
||||||
|
x->bad_pins_format = b;
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "lock_on_boot", &x->lock_on_boot, 1);
|
if(flipper_format_read_bool(file, "lock_on_boot", &b, 1)) {
|
||||||
|
x->lock_on_boot = b;
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "lockscreen_time", &x->lockscreen_time, 1);
|
if(flipper_format_read_bool(file, "lockscreen_time", &b, 1)) {
|
||||||
|
x->lockscreen_time = b;
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "lockscreen_seconds", &x->lockscreen_seconds, 1);
|
if(flipper_format_read_bool(file, "lockscreen_seconds", &b, 1)) {
|
||||||
|
x->lockscreen_seconds = b;
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "lockscreen_date", &x->lockscreen_date, 1);
|
if(flipper_format_read_bool(file, "lockscreen_date", &b, 1)) {
|
||||||
|
x->lockscreen_date = b;
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "lockscreen_statusbar", &x->lockscreen_statusbar, 1);
|
if(flipper_format_read_bool(file, "lockscreen_statusbar", &b, 1)) {
|
||||||
|
x->lockscreen_statusbar = b;
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "lockscreen_prompt", &x->lockscreen_prompt, 1);
|
if(flipper_format_read_bool(file, "lockscreen_prompt", &b, 1)) {
|
||||||
|
x->lockscreen_prompt = b;
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_uint32(file, "battery_icon", (uint32_t*)&x->battery_icon, 1);
|
if(flipper_format_read_uint32(file, "battery_icon", &u, 1)) {
|
||||||
|
x->battery_icon = CLAMP(u, BatteryIconCount - 1U, 0U);
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "status_icons", &x->status_icons, 1);
|
if(flipper_format_read_bool(file, "status_icons", &b, 1)) {
|
||||||
|
x->status_icons = b;
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "bar_borders", &x->bar_borders, 1);
|
if(flipper_format_read_bool(file, "bar_borders", &b, 1)) {
|
||||||
|
x->bar_borders = b;
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "bar_background", &x->bar_background, 1);
|
if(flipper_format_read_bool(file, "bar_background", &b, 1)) {
|
||||||
|
x->bar_background = b;
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "sort_dirs_first", &x->sort_dirs_first, 1);
|
if(flipper_format_read_bool(file, "sort_dirs_first", &b, 1)) {
|
||||||
|
x->sort_dirs_first = b;
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "dark_mode", &x->dark_mode, 1);
|
if(flipper_format_read_bool(file, "dark_mode", &b, 1)) {
|
||||||
|
{
|
||||||
|
x->dark_mode = b;
|
||||||
|
}
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_uint32(file, "favorite_timeout", &x->favorite_timeout, 1);
|
if(flipper_format_read_uint32(file, "favorite_timeout", &u, 1)) {
|
||||||
|
x->favorite_timeout = CLAMP(u, 60U, 0U);
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "bad_bt", &x->bad_bt, 1);
|
if(flipper_format_read_bool(file, "bad_bt", &b, 1)) {
|
||||||
|
x->bad_bt = b;
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "bad_bt_remember", &x->bad_bt_remember, 1);
|
if(flipper_format_read_bool(file, "bad_bt_remember", &b, 1)) {
|
||||||
|
x->bad_bt_remember = b;
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_int32(file, "butthurt_timer", &x->butthurt_timer, 1);
|
if(flipper_format_read_uint32(file, "butthurt_timer", &u, 1)) {
|
||||||
|
x->butthurt_timer = CLAMP(u, 172800U, 0U);
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_uint32(file, "charge_cap", &x->charge_cap, 1);
|
if(flipper_format_read_uint32(file, "charge_cap", &u, 1)) {
|
||||||
|
x->charge_cap = CLAMP(u, 100U, 5U);
|
||||||
|
}
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
flipper_format_read_bool(file, "rgb_backlight", &x->rgb_backlight, 1);
|
if(flipper_format_read_bool(file, "rgb_backlight", &b, 1)) {
|
||||||
|
x->rgb_backlight = b;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
flipper_format_free(file);
|
flipper_format_free(file);
|
||||||
furi_record_close(RECORD_STORAGE);
|
furi_record_close(RECORD_STORAGE);
|
||||||
@@ -128,7 +181,7 @@ void XTREME_SETTINGS_SAVE() {
|
|||||||
flipper_format_write_uint32(file, "favorite_timeout", &x->favorite_timeout, 1);
|
flipper_format_write_uint32(file, "favorite_timeout", &x->favorite_timeout, 1);
|
||||||
flipper_format_write_bool(file, "bad_bt", &x->bad_bt, 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_bool(file, "bad_bt_remember", &x->bad_bt_remember, 1);
|
||||||
flipper_format_write_int32(file, "butthurt_timer", &x->butthurt_timer, 1);
|
flipper_format_write_uint32(file, "butthurt_timer", &x->butthurt_timer, 1);
|
||||||
flipper_format_write_uint32(file, "charge_cap", &x->charge_cap, 1);
|
flipper_format_write_uint32(file, "charge_cap", &x->charge_cap, 1);
|
||||||
flipper_format_write_bool(file, "rgb_backlight", &x->rgb_backlight, 1);
|
flipper_format_write_bool(file, "rgb_backlight", &x->rgb_backlight, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ typedef struct {
|
|||||||
uint32_t favorite_timeout;
|
uint32_t favorite_timeout;
|
||||||
bool bad_bt;
|
bool bad_bt;
|
||||||
bool bad_bt_remember;
|
bool bad_bt_remember;
|
||||||
int32_t butthurt_timer;
|
uint32_t butthurt_timer;
|
||||||
uint32_t charge_cap;
|
uint32_t charge_cap;
|
||||||
bool rgb_backlight;
|
bool rgb_backlight;
|
||||||
} XtremeSettings;
|
} XtremeSettings;
|
||||||
|
|||||||
Reference in New Issue
Block a user