Add a cycle animations setting (#98)

This commit is contained in:
Clara K
2023-01-16 22:31:40 +01:00
committed by GitHub
4 changed files with 55 additions and 6 deletions
@@ -197,10 +197,13 @@ static void animation_manager_start_new_idle(AnimationManager* animation_manager
StorageAnimation* new_animation = animation_manager_select_idle_animation(animation_manager);
animation_manager_replace_current_animation(animation_manager, new_animation);
const BubbleAnimation* bubble_animation =
animation_storage_get_bubble_animation(animation_manager->current_animation);
// 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) {
@@ -508,10 +511,13 @@ void animation_manager_load_and_continue_animation(AnimationManager* animation_m
animation_manager->idle_animation_timer,
animation_manager->freezed_animation_time_left);
} else {
const BubbleAnimation* animation = animation_storage_get_bubble_animation(
animation_manager->current_animation);
// 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 {
+5
View File
@@ -322,6 +322,11 @@ int32_t desktop_srv(void* p) {
DESKTOP_SETTINGS_SAVE(&desktop->settings);
}
if(!desktop->settings.cycle_animations_s) {
desktop->settings.cycle_animations_s = 3601;
DESKTOP_SETTINGS_SAVE(&desktop->settings);
}
desktop_main_set_sfw_mode_state(desktop->main_view, desktop->settings.sfw_mode);
scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain);
@@ -64,4 +64,5 @@ typedef struct {
uint8_t displayBatteryPercentage;
bool is_sfwmode;
uint8_t sfw_mode;
uint32_t cycle_animations_s;
} DesktopSettings;
@@ -39,6 +39,23 @@ const uint32_t displayBatteryPercentage_value[BATTERY_VIEW_COUNT] = {
uint8_t origBattDisp_value = 0;
#define CYCLE_ANIMATIONS_COUNT 10
const char* const cycle_animations_text[CYCLE_ANIMATIONS_COUNT] = {
"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] =
{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;
view_dispatcher_send_custom_event(app->view_dispatcher, index);
@@ -60,6 +77,14 @@ static void desktop_settings_scene_start_battery_view_changed(VariableItem* item
app->settings.displayBatteryPercentage = index;
}
static void desktop_settings_scene_start_cycle_animations_changed(VariableItem* item) {
DesktopSettingsApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, cycle_animations_text[index]);
app->settings.cycle_animations_s = cycle_animations_value[index];
}
void desktop_settings_scene_start_on_enter(void* context) {
DesktopSettingsApp* app = context;
VariableItemList* variable_item_list = app->variable_item_list;
@@ -102,6 +127,18 @@ void desktop_settings_scene_start_on_enter(void* context) {
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, battery_view_count_text[value_index]);
item = variable_item_list_add(
variable_item_list,
"Cycle Animations",
CYCLE_ANIMATIONS_COUNT,
desktop_settings_scene_start_cycle_animations_changed,
app);
value_index = value_index_uint32(
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]);
variable_item_list_set_enter_callback(
variable_item_list, desktop_settings_scene_start_var_list_enter_callback, app);
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewVarItemList);