Project

General

Profile

LCD configuration » fbfill_3-27-2015.cpp

fbfill source code with width and height arguments - Alexander Block, 03/27/2015 05:07 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
#include <string.h>
15
#include <stdlib.h>
16

    
17

    
18
int main(int argc, char** argv)
19
{
20

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

    
27
    for(int aa = 1; aa < argc -1; ++aa)
28
    {
29
    	if(0 == strncmp(argv[aa],"-w",2) && argc > (aa+1))
30
  		{
31
  			w=atoi(argv[aa+1]);
32
  			++aa;
33
  		}
34
  		if(0 == strncmp(argv[aa],"-h",2) && argc > (aa+1))
35
  		{
36
  			h=atoi(argv[aa+1]);
37
  			++aa;
38
  		}
39
    }
40
    	
41
    printf("Framebuffer w = %d h = %d\n", w,h);
42
    	
43
    FILE* fp = NULL;
44
    // un-blank the display
45
    fp = fopen("/sys/devices/platform/da8xx_lcdc.0/graphics/fb0/blank", "w");
46
    if(fp)
47
    {
48
        fwrite("1\n",2,1,fp);
49
        fclose(fp);
50
    }
51

    
52
    printf("opening %s\n",devname);
53
    fp = fopen(devname,"w");
54
    if (!fp)
55
    {
56
        perror(devname);
57
        return(2);
58
    }
59
    unsigned short* pdata = new unsigned short[w];
60
    for (int xx = 0; xx < (w); ++xx)
61
    {
62
        pdata[xx] = 0xFFFF;
63
    }
64
    fwrite(pdata,2,w,fp);
65
    for (int yy = 1; yy < (h-1); ++yy)
66
    {
67
        pdata[0] = 0xFFFF;
68
        for (int xx = 1; xx < (w-1); ++xx)
69
        {
70
            pdata[xx] = 1 << bitlane;
71
        }
72
        pdata[w-1] = 0xFFFF;
73
        fwrite(pdata,2,w,fp);
74
        if (yy && (yy%s == 0))
75
            ++bitlane;
76
    }
77
    for (int xx = 0; xx < (w); ++xx)
78
    {
79
        pdata[xx] = 0xFFFF;
80
    }
81
    fwrite(pdata,2,w,fp);
82
    delete [] pdata;
83
    return 0;
84
}
(9-9/11) Go to top
Add picture from clipboard (Maximum size: 1 GB)