Change cycle anims setting to control anim length

This commit is contained in:
Willy-JL
2023-01-16 20:02:40 +00:00
parent cf2a1265db
commit f2c1921638
4 changed files with 29 additions and 13 deletions

View File

@@ -118,12 +118,9 @@ static void animation_manager_check_blocking_callback(const void* message, void*
static void animation_manager_timer_callback(void* context) {
furi_assert(context);
AnimationManager* animation_manager = context;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(!settings->dont_cycle_animations && animation_manager->new_idle_callback) {
if(animation_manager->new_idle_callback) {
animation_manager->new_idle_callback(animation_manager->context);
}
free(settings);
}
static void animation_manager_interact_callback(void* context) {
@@ -203,7 +200,10 @@ static void animation_manager_start_new_idle(AnimationManager* animation_manager
const BubbleAnimation* bubble_animation =
animation_storage_get_bubble_animation(animation_manager->current_animation);
animation_manager->state = AnimationManagerStateIdle;
furi_timer_start(animation_manager->idle_animation_timer, bubble_animation->duration * 1000);
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
furi_timer_start(animation_manager->idle_animation_timer, (settings->cycle_animations_s - 1) * 1000);
free(settings);
}
static bool animation_manager_check_blocking(AnimationManager* animation_manager) {
@@ -513,8 +513,11 @@ void animation_manager_load_and_continue_animation(AnimationManager* animation_m
} else {
const BubbleAnimation* animation = animation_storage_get_bubble_animation(
animation_manager->current_animation);
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
furi_timer_start(
animation_manager->idle_animation_timer, animation->duration * 1000);
animation_manager->idle_animation_timer, (settings->cycle_animations_s - 1) * 1000);
free(settings);
}
}
} else {

View File

@@ -322,6 +322,10 @@ int32_t desktop_srv(void* p) {
DESKTOP_SETTINGS_SAVE(&desktop->settings);
}
if(!desktop->settings.cycle_animations_s) {
desktop->settings.cycle_animations_s = 3601;
}
desktop_main_set_sfw_mode_state(desktop->main_view, desktop->settings.sfw_mode);
scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain);

View File

@@ -64,5 +64,5 @@ typedef struct {
uint8_t displayBatteryPercentage;
bool is_sfwmode;
uint8_t sfw_mode;
uint8_t dont_cycle_animations;
uint8_t cycle_animations_s;
} DesktopSettings;

View File

@@ -39,13 +39,22 @@ const uint32_t displayBatteryPercentage_value[BATTERY_VIEW_COUNT] = {
uint8_t origBattDisp_value = 0;
#define CYCLE_ANIMATIONS_COUNT 2
#define CYCLE_ANIMATIONS_COUNT 10
const char* const cycle_animations_text[CYCLE_ANIMATIONS_COUNT] = {
"ON",
"OFF",
"5 M",
"10 M",
"15 M",
"30 M",
"1 H",
"2 H",
"6 H",
"12 H",
"24 H",
};
// Values are offset by 1 so that 0 is not a valid value and desktop.c can detect this to set a default value (3601 / 1 H)
const uint32_t cycle_animations_value[CYCLE_ANIMATIONS_COUNT] =
{0, 1};
{1, 301, 601, 901, 1801, 3601, 7201, 21601, 43201, 86401};
static void desktop_settings_scene_start_var_list_enter_callback(void* context, uint32_t index) {
DesktopSettingsApp* app = context;
@@ -73,7 +82,7 @@ static void desktop_settings_scene_start_cycle_animations_changed(VariableItem*
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, cycle_animations_text[index]);
app->settings.dont_cycle_animations = auto_lock_delay_value[index];
app->settings.cycle_animations_s = cycle_animations_value[index];
}
void desktop_settings_scene_start_on_enter(void* context) {
@@ -120,13 +129,13 @@ void desktop_settings_scene_start_on_enter(void* context) {
item = variable_item_list_add(
variable_item_list,
"Cycle animations",
"Cycle Animations",
CYCLE_ANIMATIONS_COUNT,
desktop_settings_scene_start_cycle_animations_changed,
app);
value_index = value_index_uint32(
app->settings.dont_cycle_animations, cycle_animations_value, CYCLE_ANIMATIONS_COUNT);
app->settings.cycle_animations_s, cycle_animations_value, CYCLE_ANIMATIONS_COUNT);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, cycle_animations_text[value_index]);