@@ -141,9 +141,11 @@ int ani_xbm_scrollup_inf(xbm_t *xbm, uint16_t *fb,
141
141
return ++ i ;
142
142
}
143
143
144
- void ani_scroll_x (bm_t * bm , uint16_t * fb , int dir )
144
+ int ani_scroll_x (bm_t * bm , uint16_t * fb , int dir )
145
145
{
146
- int x = mod (bm -> anim_step , bm -> width + LED_COLS ) - LED_COLS ;
146
+ int total_steps = bm -> width + LED_COLS ;
147
+ int step = mod (bm -> anim_step , total_steps );
148
+ int x = step - LED_COLS ;
147
149
bm -> anim_step += (dir ) ? -1 : 1 ;
148
150
149
151
for (int i = 0 ; i < LED_COLS ; i ++ ) {
@@ -153,16 +155,17 @@ void ani_scroll_x(bm_t *bm, uint16_t *fb, int dir)
153
155
}
154
156
fb [i ] = (i + x ) >= 0 ? bm -> buf [i + x ] : 0 ;
155
157
}
158
+ return mod (bm -> anim_step , total_steps ); // How many steps left until restart again
156
159
}
157
160
158
- void ani_scroll_left (bm_t * bm , uint16_t * fb )
161
+ int ani_scroll_left (bm_t * bm , uint16_t * fb )
159
162
{
160
- ani_scroll_x (bm , fb , 0 );
163
+ return ani_scroll_x (bm , fb , 0 );
161
164
}
162
165
163
- void ani_scroll_right (bm_t * bm , uint16_t * fb )
166
+ int ani_scroll_right (bm_t * bm , uint16_t * fb )
164
167
{
165
- ani_scroll_x (bm , fb , 1 );
168
+ return ani_scroll_x (bm , fb , 1 );
166
169
}
167
170
168
171
void ani_shift_y (bm_t * bm , uint16_t * fb , int y , int frame )
@@ -184,7 +187,8 @@ void ani_scroll_y(bm_t *bm, uint16_t *fb)
184
187
{
185
188
int frame_steps = LED_ROWS * 3 ; // in-still-out
186
189
int frames = ALIGN (bm -> width , LED_COLS ) / LED_COLS ;
187
- int frame = mod (bm -> anim_step , frame_steps * frames )/frame_steps ;
190
+ int total_steps = frame_steps * frames ;
191
+ int frame = mod (bm -> anim_step , total_steps )/frame_steps ;
188
192
189
193
int y = mod (bm -> anim_step , frame_steps );
190
194
@@ -197,16 +201,28 @@ void ani_scroll_y(bm_t *bm, uint16_t *fb)
197
201
}
198
202
}
199
203
200
- void ani_scroll_up (bm_t * bm , uint16_t * fb )
204
+ int ani_scroll_up (bm_t * bm , uint16_t * fb )
201
205
{
202
206
ani_scroll_y (bm , fb );
207
+
208
+ int frame_steps = LED_ROWS * 3 ; // in-still-out
209
+ int frames = ALIGN (bm -> width , LED_COLS ) / LED_COLS ;
210
+ int total_steps = frame_steps * frames ;
203
211
bm -> anim_step ++ ;
212
+
213
+ return mod (bm -> anim_step , total_steps );
204
214
}
205
215
206
- void ani_scroll_down (bm_t * bm , uint16_t * fb )
216
+ int ani_scroll_down (bm_t * bm , uint16_t * fb )
207
217
{
208
218
ani_scroll_y (bm , fb );
219
+
220
+ int frame_steps = LED_ROWS * 3 ; // in-still-out
221
+ int frames = ALIGN (bm -> width , LED_COLS ) / LED_COLS ;
222
+ int total_steps = frame_steps * frames ;
209
223
bm -> anim_step -- ;
224
+
225
+ return mod (bm -> anim_step , total_steps );
210
226
}
211
227
212
228
static void laser_in (bm_t * bm , uint16_t * fb , int step , int frame )
@@ -258,11 +274,12 @@ static void still(bm_t *bm, uint16_t *fb, int frame)
258
274
}
259
275
}
260
276
261
- void ani_laser (bm_t * bm , uint16_t * fb )
277
+ int ani_laser (bm_t * bm , uint16_t * fb )
262
278
{
263
279
int frame_steps = LED_COLS * 3 ; // in-still-out
264
280
int frames = ALIGN (bm -> width , LED_COLS ) / LED_COLS ;
265
- int frame = mod (bm -> anim_step , frame_steps * frames )/frame_steps ;
281
+ int total_steps = frame_steps * frames ;
282
+ int frame = mod (bm -> anim_step , total_steps )/frame_steps ;
266
283
267
284
int c = mod (bm -> anim_step , frame_steps );
268
285
bm -> anim_step ++ ;
@@ -273,6 +290,8 @@ void ani_laser(bm_t *bm, uint16_t *fb)
273
290
still (bm , fb , frame );
274
291
else
275
292
laser_out (bm , fb , c - LED_COLS * 2 , frame );
293
+
294
+ return mod (bm -> anim_step , total_steps );
276
295
}
277
296
278
297
static uint32_t b16dialate (uint16_t w , int from , int to )
@@ -332,11 +351,12 @@ static void snowflake_out(bm_t *bm, uint16_t *fb, int step, int frame)
332
351
}
333
352
}
334
353
335
- void ani_snowflake (bm_t * bm , uint16_t * fb )
354
+ int ani_snowflake (bm_t * bm , uint16_t * fb )
336
355
{
337
356
int frame_steps = LED_ROWS * 6 ; // in-still-out, each costs 2xLED_ROWS step
338
357
int frames = ALIGN (bm -> width , LED_COLS ) / LED_COLS ;
339
- int frame = mod (bm -> anim_step , frame_steps * frames )/frame_steps ;
358
+ int total_steps = frame_steps * frames ;
359
+ int frame = mod (bm -> anim_step , total_steps )/frame_steps ;
340
360
341
361
int c = mod (bm -> anim_step , frame_steps );
342
362
bm -> anim_step ++ ;
@@ -348,27 +368,35 @@ void ani_snowflake(bm_t *bm, uint16_t *fb)
348
368
} else {
349
369
snowflake_out (bm , fb , - (c - LED_ROWS * 4 ), frame );
350
370
}
371
+
372
+ return mod (bm -> anim_step , total_steps );
351
373
}
352
374
353
- void ani_animation (bm_t * bm , uint16_t * fb )
375
+ int ani_animation (bm_t * bm , uint16_t * fb )
354
376
{
355
377
int frame_steps = ANI_ANIMATION_STEPS ;
356
378
int frames = ALIGN (bm -> width , LED_COLS ) / LED_COLS ;
357
- int frame = mod (bm -> anim_step , frame_steps * frames )/frame_steps ;
379
+ int total_steps = frame_steps * frames ;
380
+ int frame = mod (bm -> anim_step , total_steps )/frame_steps ;
358
381
359
382
bm -> anim_step ++ ;
360
383
361
384
still (bm , fb , frame );
385
+
386
+ return mod (bm -> anim_step , total_steps );
362
387
}
363
388
364
- void ani_fixed (bm_t * bm , uint16_t * fb )
389
+ int ani_fixed (bm_t * bm , uint16_t * fb )
365
390
{
366
391
int frame_steps = ANI_FIXED_STEPS ;
367
392
int frames = ALIGN (bm -> width , LED_COLS ) / LED_COLS ;
368
- int frame = mod (bm -> anim_step , frame_steps * frames )/frame_steps ;
393
+ int total_steps = frame_steps * frames ;
394
+ int frame = mod (bm -> anim_step , total_steps )/frame_steps ;
369
395
370
396
bm -> anim_step ++ ;
371
397
still (bm , fb , frame );
398
+
399
+ return mod (bm -> anim_step , total_steps );
372
400
}
373
401
374
402
static void picture (bm_t * bm , uint16_t * fb , int step , int frame )
@@ -420,11 +448,12 @@ static void picture_out(bm_t *bm, uint16_t *fb, int step)
420
448
fb [hc - i ] = -1 ;
421
449
}
422
450
423
- void ani_picture (bm_t * bm , uint16_t * fb )
451
+ int ani_picture (bm_t * bm , uint16_t * fb )
424
452
{
425
453
int last_steps = LED_COLS / 2 ;
426
454
int frame_steps = LED_COLS ;
427
455
int frames = ALIGN (bm -> width , LED_COLS ) / LED_COLS + 1 ;
456
+ int total_steps = frame_steps * frames - last_steps ;
428
457
int frame = mod (bm -> anim_step , frame_steps * frames )/frame_steps ;
429
458
bm -> anim_step ++ ;
430
459
@@ -434,10 +463,13 @@ void ani_picture(bm_t *bm, uint16_t *fb)
434
463
/* picture_out() costs only half LED_COLS */
435
464
if (mod (bm -> anim_step , LED_COLS ) >= last_steps ) {
436
465
bm -> anim_step = 0 ;
466
+ return 0 ;
437
467
}
438
- return ;
468
+ return mod ( bm -> anim_step , total_steps ) ;
439
469
}
440
470
picture (bm , fb , bm -> anim_step , frame );
471
+
472
+ return mod (bm -> anim_step , total_steps );
441
473
}
442
474
443
475
void ani_marque (bm_t * bm , uint16_t * fb , int step )
0 commit comments