Project

General

Profile

LCD configuration » fbfill.cpp

Simple frame buffer test pattern generator - Tim Iskander, 09/22/2010 01:49 PM

 
1
/**
2
 * \file fbfill.cpp
3
 * very simple VGA frame buffer pattern fill
4
 * to compile:
5
 * /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-g++ -o fbfill fbfill.cpp
6
 *
7
 * 2010 (c) Critical Link LLC. This file is licensed under
8
 * the terms of the GNU General Public License version 2. This program
9
 * is licensed "as is" without any warranty of any kind, whether express
10
 * or implied.
11
 *
12
 */
13
#include <stdio.h>
14

    
15
int main(int argc, char** argv)
16
{
17

    
18
    int w = 640;
19
    int h = 480;
20
    int s = h/(8 *sizeof(unsigned short));
21
    unsigned short bitlane = 0;
22
    const char* devname = "/dev/fb";
23

    
24
    FILE* fp = NULL;
25
    // un-blank the display
26
    fp = fopen("/sys/devices/platform/da8xx_lcdc.0/graphics/fb0/blank", "w");
27
    if(fp)
28
    {
29
        fwrite("1\n",2,1,fp);
30
        fclose(fp);
31
    }
32

    
33
    printf("opening %s\n",devname);
34
    fp = fopen(devname,"w");
35
    if (!fp)
36
    {
37
        perror(devname);
38
        return(2);
39
    }
40
    unsigned short* pdata = new unsigned short[w];
41
    for (int xx = 0; xx < (w); ++xx)
42
    {
43
        pdata[xx] = 0xFFFF;
44
    }
45
    fwrite(pdata,2,w,fp);
46
    for (int yy = 1; yy < (h-1); ++yy)
47
    {
48
        pdata[0] = 0xFFFF;
49
        for (int xx = 1; xx < (w-1); ++xx)
50
        {
51
            pdata[xx] = 1 << bitlane;
52
        }
53
        pdata[w-1] = 0xFFFF;
54
        fwrite(pdata,2,w,fp);
55
        if (yy && (yy%s == 0))
56
            ++bitlane;
57
    }
58
    for (int xx = 0; xx < (w); ++xx)
59
    {
60
        pdata[xx] = 0xFFFF;
61
    }
62
    fwrite(pdata,2,w,fp);
63
    delete [] pdata;
64
    return 0;
65
}
(3-3/11) Go to top
Add picture from clipboard (Maximum size: 1 GB)