Electronic Components Datasheet Search
  English  ▼

X  

AN2641 Datasheet(PDF) 26 Page - STMicroelectronics

Part # AN2641
Description  Using the color LCD controller
PDF  37 Pages
Scroll/Zoom Zoom In 100%  Zoom Out
Manufacturer  STMICROELECTRONICS [STMicroelectronics]
Direct Link  http://www.st.com
Logo STMICROELECTRONICS - STMicroelectronics

AN2641 Datasheet(HTML) 26 Page - STMicroelectronics

Back Button AN2641 Datasheet HTML 22Page - STMicroelectronics AN2641 Datasheet HTML 23Page - STMicroelectronics AN2641 Datasheet HTML 24Page - STMicroelectronics AN2641 Datasheet HTML 25Page - STMicroelectronics AN2641 Datasheet HTML 26Page - STMicroelectronics AN2641 Datasheet HTML 27Page - STMicroelectronics AN2641 Datasheet HTML 28Page - STMicroelectronics AN2641 Datasheet HTML 29Page - STMicroelectronics AN2641 Datasheet HTML 30Page - STMicroelectronics Next Button
Zoom Inzoom in Zoom Outzoom out
 26 / 37 page
background image
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;
}



Html Pages

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


Datasheet Download

Go To PDF Page


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


Mirror Sites
English : Alldatasheet.com  |   English : Alldatasheet.net  |   Chinese : Alldatasheetcn.com  |   German : Alldatasheetde.com  |   Japanese : Alldatasheet.jp
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