| Electronic Components Datasheet Search |
|
AN2641 Datasheet(PDF) 26 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
AN2641 Datasheet(HTML) 26 Page - STMicroelectronics |
|
26 / 37 page ![]() Linux frame buffer AN2641 26/37 Doc ID 14027 Rev 1 Figure 15. A sample user application #include <unistd.h> #include <stdio.h> #include <fcntl.h> #include <linux/fb.h> #include <sys/mman.h> 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("/dev/fb0", O_RDWR); if (!fbfd) { printf("Error: cannot open framebuffer device.\n"); exit(1); } // 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); } // Put variable screen information to Switch ON CLCD Panel vinfo.activate |= FB_ACTIVATE_FORCE | FB_ACTIVATE_NOW; if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &vinfo)) { printf("Error writing 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); } //Loop will draw 3 color bands: blue, green and red for ( location = 0, y = 0; y < vinfo.yres; y++ ) for ( x = 0; x < vinfo.xres; x++ ) { if ( y < (vinfo.yres/3) ) { *(fbp + location) = 0xFF;//show Blue *(fbp + location+1) = 0;//no Green *(fbp + location+2) = 0;//no Red *(fbp + location+3) = 0;//No Transparency } else if ( y < (2*vinfo.yres/3) ) { *(fbp + location) = 0xFF;// no Blue *(fbp + location + 1) = 0;// show Green *(fbp + location + 2) = 0;// no Red *(fbp + location + 3) = 0;// No transparency } else { *(fbp + location) = 0;// no Blue *(fbp + location + 1) = 0; // no Green *(fbp + location + 2) = 0xFF;// show Red *(fbp + location + 3) = 0;// No transparency } location +=4; } munmap(fbp, screensize); close(fbfd); return 0; } |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |