-
Notifications
You must be signed in to change notification settings - Fork 0
/
main2.c
45 lines (34 loc) · 1.18 KB
/
main2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <fcntl.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include "lib/common.h"
#include "lib/animation_player.h"
static uchar termCommands[] = { 27, 91, 72, 27, 91, 74 };
int main(void)
{
AnimationPlayer *player = ap_createAnimationPlayer();
//displayBuffer = displayBufferHead + displayBufferBody
//displayBufferHead: stores clear terminal commands
//displayBufferBody: stores animation frame
uchar displayBuffer[4096];
uchar *displayBufferHead = displayBuffer;
ssize_t displayBufferHeadLen = sizeof(termCommands);
for (int i = 0; i < displayBufferHeadLen; i++)
{
displayBufferHead[i] = termCommands[i];
}
uchar *displayBufferBody = displayBufferHead + displayBufferHeadLen;
ssize_t displayBufferBodyLen = sizeof(displayBuffer) - displayBufferHeadLen;
uchar *animationBuffer = displayBufferBody;
ssize_t animationBufferLen = displayBufferBodyLen;
while (ap_play(player, animationBuffer, &animationBufferLen) != -1)
{
write(1, displayBuffer, displayBufferHeadLen + animationBufferLen);
animationBufferLen = displayBufferBodyLen;
sleep(1);
}
ap_freeAnimationPlayer(player);
return 0;
}