forked from shackspace/blinkenpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
92 lines (63 loc) · 1.29 KB
/
main.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/spi/spidev.h>
#include <string.h>
#include <math.h>
#include "rgblib.h"
#include "screenlib.h"
int i;
double ctr;
extern unsigned char buffer[];
#define STEP 0.3;
int main(int argc, char *argv[]){
ctr = 0;
spi_init();
char *text;
int donum = -1;
if (argc >= 2){
text = argv[argc-1];
}
else{
text = "29c3";
}
if (argc == 3){
donum = argv[1][0]-'0'+1;
printf("doing only %d times\n", donum-1);
}
ctr=0;
while (0){
for (i=0;i<LED_NUM;i++){
buffer[i*3+0] = 63*(0.0+sin(((double)ctr*8+i+32*(i%WIDTH))/50.0));
buffer[i*3+1] = 63*(0.0+sin(((double)ctr*8+i+32*(i%WIDTH))/50.0+3.14159*2/3));
buffer[i*3+2] = 63*(0.0+sin(((double)ctr*8+i+32*(i%WIDTH))/50.0+3.14159*4/3));
}
ctr++;
blit();
update();
}
while(donum != 0){
unsigned int tctr = 0;
while (text[tctr]){
draw_char((ctr-strlen(text)*6) + tctr*6,text[tctr]);
tctr++;
}
blit();
update();
ctr-= STEP;
if (ctr <= 0){
ctr = strlen(text)*6+WIDTH;
if (donum > 0) donum--;
}
//if (strlen(text)*4<WIDTH){
// if (ctr > WIDTH-1) ctr = 0;
//}
//else{
// if (ctr > strlen(text)*4 + WIDTH) ctr = 0;
//}
//usleep(3000);
}
}