임베디드 LCD에 점찍기
하지만 난 안된다.... 좀더 들여다 봐야되겠다.
http://blog.naver.com/PostView.nhn?blogId=buniel1&logNo=60065575973&categoryNo=1&parentCategoryNo=1&viewDate=¤tPage=1&postListTopCurrentPage=&isAfterWrite=true&userTopListOpen=true&userTopListCount=20&userTopListManageOpen=false&userTopListCurrentPage=1
#include <unistd.h>
하지만 난 안된다.... 좀더 들여다 봐야되겠다.
http://blog.naver.com/PostView.nhn?blogId=buniel1&logNo=60065575973&categoryNo=1&parentCategoryNo=1&viewDate=¤tPage=1&postListTopCurrentPage=&isAfterWrite=true&userTopListOpen=true&userTopListCount=20&userTopListManageOpen=false&userTopListCurrentPage=1
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
#define FBDEVFILE "/dev/fb0"
typedef unsigned char ubyte;
unsigned short makepixel(ubyte r, ubyte g, ubyte b)
{
return (unsigned short)(((r>>3)<<11)|((g>>2)<<5)|(b>>3));
}
int main()
{
int fbfd = 0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
long int screensize = 0;
char *fbp = 0;
int x = 0, y = 0;
long int location = 0;
/* Open the file for reading and writing */
fbfd = open(FBDEVFILE, O_RDWR);
if(!fbfd) {
printf("Error : cannot open framebuffer device. \n");
exit(1);
}
printf("The framebuffer device was opened successfully.\n");
/* Get fixed screen information */
if(ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)){
printf("Error reading fixed information. \n");
exit(2);
}
/* Get variable screen information */
if(ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)){
printf("Error reading variable information. \n");
exit(3);
}
/* Figure out the size of the screen in bytes */
screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
/* Map the device to memory */
fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);
if((int)fbp == -1){
printf("Error : failed to map framebuffer device to memory. \n");
exit(4);
}
printf("The framebuffer device was mapped to memory successfully. \n");
x = 100; y = 100; /* Where we are going to put the pixel */
/* Figure out where in memory to put the pixel */
location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +
(y+vinfo.yoffset) * (finfo.line_length);
*(fbp + location) = 100; /* Some blue */
*(fbp + location + 1) = 15; /* A little green */
*(fbp + location + 2) = 200; /* A lot of red */
*(fbp + location + 3) = 0; /* No transparency */
munmap(fbp, screensize);
close(fbfd);
return 0;
}
'L I N U X' 카테고리의 다른 글
리눅스 그래픽 프레임 버퍼 (0) | 2012.03.15 |
---|---|
프레임 퍼버 이용하기 (0) | 2012.03.15 |
Arm embedded linux porting (0) | 2012.03.09 |
Makefile ?? (0) | 2012.02.28 |
환경 변수 설정 (0) | 2012.02.27 |