Add anim cycle 30s, 1m and manifest

This commit is contained in:
Willy-JL
2023-01-17 01:22:19 +00:00
parent a8725999c7
commit 01b1ea123b
4 changed files with 26 additions and 21 deletions

View File

@@ -197,12 +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;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
furi_timer_start(animation_manager->idle_animation_timer, (settings->cycle_animations_s - 1) * 1000);
int32_t duration_s = settings->cycle_animation_s == -1 ? bubble_animation->duration : (settings->cycle_animation_s - 1);
furi_timer_start(animation_manager->idle_animation_timer, duration_s * 1000);
free(settings);
}
@@ -511,12 +512,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);
int32_t duration_s = settings->cycle_animation_s == -1 ? animation->duration : (settings->cycle_animation_s - 1);
furi_timer_start(
animation_manager->idle_animation_timer, (settings->cycle_animations_s - 1) * 1000);
animation_manager->idle_animation_timer, duration_s * 1000);
free(settings);
}
}

View File

@@ -322,8 +322,8 @@ int32_t desktop_srv(void* p) {
DESKTOP_SETTINGS_SAVE(&desktop->settings);
}
if(!desktop->settings.cycle_animations_s) {
desktop->settings.cycle_animations_s = 3601;
if(!desktop->settings.cycle_animation_s) {
desktop->settings.cycle_animation_s = 3601;
DESKTOP_SETTINGS_SAVE(&desktop->settings);
}

View File

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

View File

@@ -39,9 +39,12 @@ 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] = {
#define CYCLE_ANIMATION_COUNT 13
const char* const cycle_animation_text[CYCLE_ANIMATION_COUNT] = {
"OFF",
"Manifest",
"30 S",
"1 M",
"5 M",
"10 M",
"15 M",
@@ -53,8 +56,8 @@ const char* const cycle_animations_text[CYCLE_ANIMATIONS_COUNT] = {
"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};
const int32_t cycle_animation_value[CYCLE_ANIMATION_COUNT] =
{1, -1, 31, 61, 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;
@@ -77,12 +80,12 @@ 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) {
static void desktop_settings_scene_start_cycle_animation_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];
variable_item_set_current_value_text(item, cycle_animation_text[index]);
app->settings.cycle_animation_s = cycle_animation_value[index];
}
void desktop_settings_scene_start_on_enter(void* context) {
@@ -130,14 +133,14 @@ void desktop_settings_scene_start_on_enter(void* context) {
item = variable_item_list_add(
variable_item_list,
"Cycle Animation",
CYCLE_ANIMATIONS_COUNT,
desktop_settings_scene_start_cycle_animations_changed,
CYCLE_ANIMATION_COUNT,
desktop_settings_scene_start_cycle_animation_changed,
app);
value_index = value_index_uint32(
app->settings.cycle_animations_s, cycle_animations_value, CYCLE_ANIMATIONS_COUNT);
value_index = value_index_int32(
app->settings.cycle_animation_s, cycle_animation_value, CYCLE_ANIMATION_COUNT);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, cycle_animations_text[value_index]);
variable_item_set_current_value_text(item, cycle_animation_text[value_index]);
variable_item_list_set_enter_callback(
variable_item_list, desktop_settings_scene_start_var_list_enter_callback, app);