forked from crondog/arch-flo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
refresher.c
66 lines (53 loc) · 1.38 KB
/
refresher.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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <getopt.h>
#include <time.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <linux/fb.h>
struct fb_info{
int fd;
void *ptr;
struct fb_var_screeninfo var;
struct fb_fix_screeninfo fix;
};
void fb_getinfo(struct fb_info *fb_info){
printf("fb res %dx%d virtual %dx%d, line_len %d\n",
fb_info->var.xres, fb_info->var.yres,
fb_info->var.xres_virtual, fb_info->var.yres_virtual,
fb_info->fix.line_length);
printf("dim %dmm x %dmm\n", fb_info->var.width, fb_info->var.height);
printf("xoffset %d yoffset %d\n", fb_info->var.xoffset, fb_info->var.yoffset);
}
int fb_open(struct fb_info *fb_info){
int fd = open("/dev/fb0", O_RDWR);
if(fd < 0){
printf("Failed to open fb\n");
return 1;
}
memset(fb_info, 0, sizeof(struct fb_info));
fb_info->fd = fd;
return 0;
}
void flip_buffer(struct fb_info *fb_info, int n){
if( ioctl(fb_info->fd, FBIOPAN_DISPLAY, &fb_info->var) < 0 ){
perror("Failed FBIOPAN_DISPLAY");
}
}
int main(int argc, char *argv[]){
setpriority(PRIO_PROCESS, 0, -20);
struct fb_info fb_info;
fb_open(&fb_info);
while(1){
flip_buffer(&fb_info,0);
usleep(16666);
}
return 0;
}