firmware: Add repeating animations
This commit is contained in:
		@@ -14,6 +14,7 @@ static lv_style_t s_hero, s_subtitle;
 | 
			
		||||
static lv_obj_t *o_container = NULL;
 | 
			
		||||
 | 
			
		||||
static lv_anim_timeline_t *at_active = NULL;
 | 
			
		||||
static lv_anim_timeline_t *at_active_rep = NULL;
 | 
			
		||||
static lv_obj_t *o_active = NULL;
 | 
			
		||||
static bool state_ready = true;
 | 
			
		||||
 | 
			
		||||
@@ -51,6 +52,10 @@ static void setup_next_state() {
 | 
			
		||||
    lv_anim_timeline_delete(at_active);
 | 
			
		||||
    at_active = NULL;
 | 
			
		||||
  }
 | 
			
		||||
  if (at_active_rep) {
 | 
			
		||||
    lv_anim_timeline_delete(at_active_rep);
 | 
			
		||||
    at_active_rep = NULL;
 | 
			
		||||
  }
 | 
			
		||||
  if (o_active) {
 | 
			
		||||
    lv_obj_delete(o_active);
 | 
			
		||||
    o_active = NULL;
 | 
			
		||||
@@ -63,6 +68,8 @@ static void setup_next_state() {
 | 
			
		||||
  lv_obj_set_size(o_active, lv_pct(100), lv_pct(100));
 | 
			
		||||
 | 
			
		||||
  at_active = lv_anim_timeline_create();
 | 
			
		||||
  at_active_rep = lv_anim_timeline_create();
 | 
			
		||||
  lv_anim_timeline_set_repeat_count(at_active_rep, LV_ANIM_REPEAT_INFINITE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool val_ui_state_ready() {
 | 
			
		||||
@@ -70,6 +77,7 @@ bool val_ui_state_ready() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void anim_state_ready_cb(lv_anim_t *anim) {
 | 
			
		||||
  lv_anim_timeline_start(at_active_rep);
 | 
			
		||||
  state_ready = true;
 | 
			
		||||
}
 | 
			
		||||
static void anim_x_cb(void *var, int32_t v) {
 | 
			
		||||
@@ -194,6 +202,32 @@ void val_ui_menu(bool was_idle) {
 | 
			
		||||
 | 
			
		||||
  lv_anim_timeline_add(at_active, 0, &a_title);
 | 
			
		||||
  lv_anim_timeline_add(at_active, 0, &a_sub);
 | 
			
		||||
 | 
			
		||||
  // Repeating loop swing back and forth
 | 
			
		||||
  lv_anim_t a_title_swing;
 | 
			
		||||
  lv_anim_init(&a_title_swing);
 | 
			
		||||
  lv_anim_set_early_apply(&a_title_swing, false);
 | 
			
		||||
  lv_anim_set_var(&a_title_swing, l_main);
 | 
			
		||||
  lv_anim_set_exec_cb(&a_title_swing, anim_x_cb);
 | 
			
		||||
 | 
			
		||||
  // Left
 | 
			
		||||
  lv_anim_set_path_cb(&a_title_swing, lv_anim_path_ease_out);
 | 
			
		||||
  lv_anim_set_values(&a_title_swing, 0, -10);
 | 
			
		||||
  lv_anim_set_duration(&a_title_swing, 500);
 | 
			
		||||
  lv_anim_timeline_add(at_active_rep, 0, &a_title_swing);
 | 
			
		||||
 | 
			
		||||
  // Left to right
 | 
			
		||||
  lv_anim_set_path_cb(&a_title_swing, lv_anim_path_ease_in_out);
 | 
			
		||||
  lv_anim_set_values(&a_title_swing, -10, 10);
 | 
			
		||||
  lv_anim_set_duration(&a_title_swing, 1000);
 | 
			
		||||
  lv_anim_timeline_add(at_active_rep, 500, &a_title_swing);
 | 
			
		||||
 | 
			
		||||
  // Right to centre
 | 
			
		||||
  lv_anim_set_path_cb(&a_title_swing, lv_anim_path_ease_in);
 | 
			
		||||
  lv_anim_set_values(&a_title_swing, 10, 0);
 | 
			
		||||
  lv_anim_set_duration(&a_title_swing, 500);
 | 
			
		||||
  lv_anim_timeline_add(at_active_rep, 1500, &a_title_swing);
 | 
			
		||||
 | 
			
		||||
  lv_anim_timeline_start(at_active);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user