Skip to content

Commit

Permalink
Improve animation algorithm & refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
nroggeman-ledger committed Nov 29, 2024
1 parent 8976ff9 commit 59f9125
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lib_nbgl/include/nbgl_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ typedef struct PACKED__ nbgl_icon_details_s {
*
*/
typedef enum {
LOOP_PARSING, ///< 1, 2, 3, 1, 2, 3...
BACK_AND_FORTH_PARSING ///< 1, 2, 3, 2, 1, 2, 3...
LOOP_PARSING, ///< 0, 1, 2, 0, 1, 2, ...
BACK_AND_FORTH_PARSING ///< 0, 1, 2, 1, 2, 0, ...
} nbgl_parsingType_t;

/**
Expand Down
29 changes: 14 additions & 15 deletions lib_nbgl/src/nbgl_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,28 +497,27 @@ static void animTickerCallback(void)
}
}
else {
// Flip incrementAnim when reaching upper or lower limit
if ((layout->incrementAnim)
&& (layout->iconIdxInAnim >= layout->animation->nbIcons - 1)) {
layout->incrementAnim = false;
}
else if (layout->iconIdxInAnim == 0) {
layout->incrementAnim = true;
}

// Increase / Decrease index according to incrementAnim
if (layout->incrementAnim) {
if (layout->iconIdxInAnim == (layout->animation->nbIcons - 1)) {
layout->iconIdxInAnim = (layout->animation->nbIcons - 2);
layout->incrementAnim = false;
}
else {
layout->iconIdxInAnim++;
}
layout->iconIdxInAnim++;
}
else {
if (layout->iconIdxInAnim == 0) {
layout->incrementAnim = true;
layout->iconIdxInAnim = 1;
}
else {
layout->iconIdxInAnim--;
}
layout->iconIdxInAnim--;
}
}
image->buffer = layout->animation->icons[layout->iconIdxInAnim];
nbgl_objDraw((nbgl_obj_t *) image);
nbgl_refreshSpecial(FULL_COLOR_PARTIAL_REFRESH);
nbgl_refreshSpecialWithPostRefresh(BLACK_AND_WHITE_FAST_REFRESH,
POST_REFRESH_FORCE_POWER_ON);
return;
}
}
Expand Down

0 comments on commit 59f9125

Please sign in to comment.