-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
132 lines (103 loc) · 2.54 KB
/
main.cpp
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include <QCoreApplication>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdbool.h>
#include <linux/input.h>
#include <linux/kd.h>
#include <time.h>
#include <signal.h>
#include "tslib.h"
#include "abeofbdirectdraw.h"
#include <errno.h>
#include <termios.h>
#include "abeoserialport.h"
#include "error.h"
#include "abeotouchscreen.h"
#include <vector>
#include <string.h>
using namespace std;
#define RANDX (rand()%SCR_W)
#define RANDY (rand()%SCR_H)
#define RANDCOLOR RGB16(rand()%255,rand()%255,rand()%255)
void parse_cmd(char* cmd){
// int idx=0;
// char c;
// vector<string> tokens;
// string* t = new string("");
// while(1){
// c=cmd[idx++];
// if(c==0)break;
// if(c=='(' || c==',' || c==')'){
// tokens.push_back(*t);
// t = new string("");
// }
// else *t+=c;
// }
// for(int i=0;i<tokens.size();i++)
// printf("TOKEN[%d] = %s\n",i,tokens[i]);
}
void show_stripe(AbeoFBDirectDraw * afb, int gap, int time){
afb->set_color(Black);
afb->clear();
afb->set_color(White);
for(int i=0;i<afb->width();i+=gap){
afb->line(i,0,i,afb->height());
}
afb->update();
usleep(time);
}
int main(int argc, char *argv[])
{
AbeoFBDirectDraw afb;
AbeoSerialPort asp;
AbeoTouchScreen ats;
afb.init("/dev/fb0","/dev/tty1");
ats.init("/dev/input/event1");
afb.set_mode(1);
// ats.calib(&afb);
//while(1){}
//DRAW STUFF
// clrscr(fbp,White);
int line_cnt=100;
printf("Drawing %d lines randomly...\n",line_cnt);
clock_t t;
t=clock();
for(int k=0;k<10;k++){
for(int i=5;i<100;i+=5){
show_stripe(&afb,i,50000);
}
}
// afb.set_color(Black);
// afb.clear();
// //init serial
// asp.init("/dev/ttyO1");
// string a("a");
// afb.set_color(White);
// //getting command
// char cmd[255];
// char c;
// int idx=0;
// do{
// c = asp.read_char();
// asp.write_char(c);
// if(c=='\n' || c=='\r'){
// cmd[idx]=0;
// break;
// }else cmd[idx++]=c;
// }while(1);
// afb.text(cmd,100,100);
//unmap memory and close framebuffer
t = clock() - t;
float elapse_sec=t/(float)CLOCKS_PER_SEC;
printf ("Elapsed time=%f second, performance = %f lines per second\n",elapse_sec,line_cnt/elapse_sec);
//getchar();
//afb.release();
printf("DONE!\n");
return 0;
}