|
26 | 26 | // This many iterations times the slowdown factor to render the whole animation. |
27 | 27 | #define LOCK_ANIMATION_N_FRAMES (38) |
28 | 28 |
|
29 | | -// Since BIP39 unlock takes 2048 iterations, and the screen frame rate is 30 (SCREEN_FRAME_RATE, |
30 | | -// render is called only every 30th iteration), if we want both to finish at the same time, the |
31 | | -// slowdown factor becomes the following: |
32 | | -// (1.1f * (2048 / ((float)LOCK_ANIMATION_N_FRAMES * (float)SCREEN_FRAME_RATE))) |
| 29 | +// Since BIP39 unlock takes 2048*2 iterations (it is performed twice), and the screen frame rate is |
| 30 | +// 30 (SCREEN_FRAME_RATE, render is called only every 30th iteration), if we want both to finish at |
| 31 | +// the same time, the slowdown factor becomes the following: |
| 32 | +// (1.1f * (2048*2 / ((float)LOCK_ANIMATION_N_FRAMES * (float)SCREEN_FRAME_RATE))) |
33 | 33 | // 10% is added so the animation takes a bit longer than the actual unlock. |
34 | | -// The above value is 1.9761, we simply round up to 2. |
35 | | -#define SLOWDOWN_FACTOR (2) |
| 34 | +// The above value is 3.95, we simply round up to 4. |
| 35 | +#define SLOWDOWN_FACTOR (4) |
36 | 36 |
|
37 | 37 | #define LOCK_ANIMATION_FRAME_WIDTH (28) |
38 | 38 | #define LOCK_ANIMATION_FRAME_HEIGHT (25) |
@@ -137,7 +137,7 @@ static const uint8_t LOCK_ANIMATION[LOCK_ANIMATION_ACTUAL_N_FRAMES][LOCK_ANIMATI |
137 | 137 | */ |
138 | 138 | static const uint8_t* _get_frame(int frame_idx) |
139 | 139 | { |
140 | | - if (frame_idx >= LOCK_ANIMATION_N_FRAMES) { |
| 140 | + if (frame_idx >= LOCK_ANIMATION_N_FRAMES + LOCK_ANIMATION_FRAMES_STOP_TIME) { |
141 | 141 | Abort("Invalid lock animation frame requested."); |
142 | 142 | } |
143 | 143 | /* First part of the animation: Closed lock for LOCK_ANIMATION_FRAMES_STOP_TIME frames. */ |
@@ -166,7 +166,7 @@ static void _render(component_t* component) |
166 | 166 | data_t* data = (data_t*)component->data; |
167 | 167 | int frame = data->frame / SLOWDOWN_FACTOR; |
168 | 168 |
|
169 | | - if (frame >= LOCK_ANIMATION_N_FRAMES) { |
| 169 | + if (frame >= LOCK_ANIMATION_N_FRAMES + LOCK_ANIMATION_FRAMES_STOP_TIME) { |
170 | 170 | /* End of the animation */ |
171 | 171 | if (data->on_done) { |
172 | 172 | data->on_done(data->on_done_param); |
|
0 commit comments