Skip to content

Commit a19e85f

Browse files
First commit
0 parents  commit a19e85f

38 files changed

+4230
-0
lines changed

LICENSE

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2013 Andrew Duncan
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a
7+
copy of this software and associated documentation files (the "Software"),
8+
to deal in the Software without restriction, including without limitation
9+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
10+
and/or sell copies of the Software, and to permit persons to whom the
11+
Software is furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22+
DEALINGS IN THE SOFTWARE.
23+

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
TARGETS= life \
2+
pngview \
3+
rgb_triangle \
4+
sprite \
5+
test_pattern \
6+
worms
7+
8+
default :all
9+
10+
all:
11+
for target in $(TARGETS); do (make -C $$target); done
12+
13+
clean:
14+
for target in $(TARGETS); do (make -C $$target clean); done
15+

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
Dispmanx
2+
========
3+
4+
There are a number of APIs available for the Raspberry Pi that can make use
5+
of the computers GPU. These include OpenMAX, Open GL ES(1 and 2) and OpenVG.
6+
The has short examples for theses and other APIs. They can be found in
7+
/opt/vc/src/hello_pi/. Among these examples is a program called
8+
hello_dispmanx. It is a very small example of the Dispmanx windowing
9+
system. Apart from this:-
10+
11+
https://github.com/raspberrypi/firmware/tree/master/opt/vc/src/hello_pi/hello_dispmanx
12+
13+
example, there is very little documentation available for this API.
14+
Hopefully these programs can be used as a starting point.
15+
16+
test_pattern
17+
------------
18+
19+
This test pattern should be familiar to anyone who has used the Raspberry
20+
Pi. It is the same four colour squar displayed when the Raspberry Pi boots.
21+
22+
rgb_triangle
23+
------------
24+
25+
Displays a triangle in a layer with red, green and blue gradients starting
26+
at each corner respectively. Blends to grey in the center.
27+
28+
life
29+
----
30+
31+
Conway's game of life.
32+
33+
worms
34+
-----
35+
36+
The program raspiworms uses a single 16 or 32 bit RGBA layer to display a
37+
number of coloured worms on the screen of the Raspberry Pi.
38+
39+
pngview
40+
-------
41+
42+
Load a png image file and display it as a Dispmanx layer.
43+
44+
sprite
45+
------
46+
47+
Demonstrates a seamless background image that can be scolled in any
48+
direction. As well as animated sprites.
49+
50+
common
51+
------
52+
53+
Code that may be common to some of the demonstation programs is in this
54+
folder.
55+
56+
building
57+
--------
58+
59+
If you type make in the top level directory, the make file will build all
60+
the different programs in this repository. Each program has it's own make
61+
file, so you can build them individually if you wish.
62+
63+
64+
65+

common/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
common
2+
======
3+

common/element_change.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//-------------------------------------------------------------------------
2+
// flags for vc_dispmanx_element_change_attributes
3+
//
4+
// can be found in interface/vmcs_host/vc_vchi_dispmanx.h
5+
// but you can't include that file as
6+
// interface/peer/vc_vchi_dispmanx_common.h is missing.
7+
//
8+
//-------------------------------------------------------------------------
9+
10+
#ifndef ELEMENT_CHANGE_H
11+
#define ELEMENT_CHANGE_H
12+
13+
#ifndef ELEMENT_CHANGE_LAYER
14+
#define ELEMENT_CHANGE_LAYER (1<<0)
15+
#endif
16+
17+
#ifndef ELEMENT_CHANGE_OPACITY
18+
#define ELEMENT_CHANGE_OPACITY (1<<1)
19+
#endif
20+
21+
#ifndef ELEMENT_CHANGE_DEST_RECT
22+
#define ELEMENT_CHANGE_DEST_RECT (1<<2)
23+
#endif
24+
25+
#ifndef ELEMENT_CHANGE_SRC_RECT
26+
#define ELEMENT_CHANGE_SRC_RECT (1<<3)
27+
#endif
28+
29+
#ifndef ELEMENT_CHANGE_MASK_RESOURCE
30+
#define ELEMENT_CHANGE_MASK_RESOURCE (1<<4)
31+
#endif
32+
33+
#ifndef ELEMENT_CHANGE_TRANSFORM
34+
#define ELEMENT_CHANGE_TRANSFORM (1<<5)
35+
#endif
36+
37+
#endif

common/hsv2rgb.c

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
//-------------------------------------------------------------------------
2+
//
3+
// The MIT License (MIT)
4+
//
5+
// Copyright (c) 2013 Andrew Duncan
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a
8+
// copy of this software and associated documentation files (the
9+
// "Software"), to deal in the Software without restriction, including
10+
// without limitation the rights to use, copy, modify, merge, publish,
11+
// distribute, sublicense, and/or sell copies of the Software, and to
12+
// permit persons to whom the Software is furnished to do so, subject to
13+
// the following conditions:
14+
//
15+
// The above copyright notice and this permission notice shall be included
16+
// in all copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21+
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22+
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23+
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24+
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25+
//
26+
//-------------------------------------------------------------------------
27+
28+
#include <stdio.h>
29+
#include <stdlib.h>
30+
#include <string.h>
31+
32+
#include "hsv2rgb.h"
33+
#include "image.h"
34+
35+
//-------------------------------------------------------------------------
36+
37+
void
38+
hsv2rgb(
39+
int16_t hue,
40+
int16_t saturation,
41+
int16_t value,
42+
RGBA8_T *rgb)
43+
{
44+
//---------------------------------------------------------------------
45+
// convert hue, saturation and value (HSV) to red, green and blue.
46+
//
47+
// hue = 0 to 3600 (i.e. 1/10 of a degree).
48+
// saturation = 0 to 1000
49+
// value = 0 to 1000
50+
//---------------------------------------------------------------------
51+
52+
rgb->red = 0;
53+
rgb->green = 0;
54+
rgb->blue = 0;
55+
56+
if (saturation == 0)
57+
{
58+
rgb->red = (uint8_t)((255 * value) / 1000);
59+
rgb->green = rgb->red;
60+
rgb->blue = rgb->red;
61+
}
62+
else
63+
{
64+
int16_t h = hue/600;
65+
int16_t f = ((hue%600)*1000)/600;
66+
int16_t p = (value*(1000-saturation))/1000;
67+
int16_t q = (value*(1000-((saturation*f)/1000)))/1000;
68+
int16_t t = (value*(1000-((saturation*(1000-f))/1000)))/1000;
69+
70+
switch (h)
71+
{
72+
case 0:
73+
74+
rgb->red = (uint8_t)((255 * value) / 1000);
75+
rgb->green = (uint8_t)((255 * t) / 1000);
76+
rgb->blue = (uint8_t)((255 * p) / 1000);
77+
break;
78+
79+
case 1:
80+
81+
rgb->red = (uint8_t)((255 * q) / 1000);
82+
rgb->green = (uint8_t)((255 * value) / 1000);
83+
rgb->blue = (uint8_t)((255 * p) / 1000);
84+
break;
85+
86+
case 2:
87+
88+
rgb->red = (uint8_t)((255 * p) / 1000);
89+
rgb->green = (uint8_t)((255 * value) / 1000);
90+
rgb->blue = (uint8_t)((255 * t) / 1000);
91+
break;
92+
93+
case 3:
94+
95+
rgb->red = (uint8_t)((255 * p) / 1000);
96+
rgb->green = (uint8_t)((255 * q) / 1000);
97+
rgb->blue = (uint8_t)((255 * value) / 1000);
98+
break;
99+
100+
case 4:
101+
102+
rgb->red = (uint8_t)((255 * t) / 1000);
103+
rgb->green = (uint8_t)((255 * p) / 1000);
104+
rgb->blue = (uint8_t)((255 * value) / 1000);
105+
break;
106+
107+
case 5:
108+
109+
rgb->red = (uint8_t)((255 * value) / 1000);
110+
rgb->green = (uint8_t)((255 * p) / 1000);
111+
rgb->blue = (uint8_t)((255 * q) / 1000);
112+
break;
113+
114+
}
115+
}
116+
}
117+

common/hsv2rgb.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//-------------------------------------------------------------------------
2+
//
3+
// The MIT License (MIT)
4+
//
5+
// Copyright (c) 2013 Andrew Duncan
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a
8+
// copy of this software and associated documentation files (the
9+
// "Software"), to deal in the Software without restriction, including
10+
// without limitation the rights to use, copy, modify, merge, publish,
11+
// distribute, sublicense, and/or sell copies of the Software, and to
12+
// permit persons to whom the Software is furnished to do so, subject to
13+
// the following conditions:
14+
//
15+
// The above copyright notice and this permission notice shall be included
16+
// in all copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21+
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22+
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23+
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24+
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25+
//
26+
//-------------------------------------------------------------------------
27+
28+
#ifndef HSV2RGB_H
29+
#define HSV2RGB_H
30+
31+
//-------------------------------------------------------------------------
32+
33+
#include "image.h"
34+
35+
//-------------------------------------------------------------------------
36+
37+
void hsv2rgb(int16_t hue, int16_t saturation, int16_t value, RGBA8_T *rgb);
38+
39+
//-------------------------------------------------------------------------
40+
41+
#endif

0 commit comments

Comments
 (0)