diff options
Diffstat (limited to 'demos')
26 files changed, 1666 insertions, 0 deletions
| diff --git a/demos/applications/mandelbrot/gfxconf.h b/demos/applications/mandelbrot/gfxconf.h new file mode 100644 index 00000000..7eaacc50 --- /dev/null +++ b/demos/applications/mandelbrot/gfxconf.h @@ -0,0 +1,33 @@ +/**
 + * This file has a different license to the rest of the GFX system.
 + * You can copy, modify and distribute this file as you see fit.
 + * You do not need to publish your source modifications to this file.
 + * The only thing you are not permitted to do is to relicense it
 + * under a different license.
 + */
 +
 +#ifndef _GFXCONF_H
 +#define _GFXCONF_H
 +
 +/* GFX sub-systems to turn on */
 +#define GFX_USE_GDISP			TRUE
 +#define GFX_USE_GWIN			FALSE
 +#define GFX_USE_GEVENT			FALSE
 +#define GFX_USE_GTIMER			FALSE
 +#define GFX_USE_GINPUT			FALSE
 +
 +/* Features for the GDISP sub-system. */
 +#define GDISP_NEED_VALIDATION	TRUE
 +#define GDISP_NEED_CLIP			FALSE
 +#define GDISP_NEED_TEXT			FALSE
 +#define GDISP_NEED_CIRCLE		FALSE
 +#define GDISP_NEED_ELLIPSE		FALSE
 +#define GDISP_NEED_ARC			FALSE
 +#define GDISP_NEED_SCROLL		FALSE
 +#define GDISP_NEED_PIXELREAD	FALSE
 +#define GDISP_NEED_CONTROL		FALSE
 +#define GDISP_NEED_MULTITHREAD	FALSE
 +#define GDISP_NEED_ASYNC		FALSE
 +#define GDISP_NEED_MSGAPI		FALSE
 +
 +#endif /* _GFXCONF_H */
 diff --git a/demos/applications/mandelbrot/main.c b/demos/applications/mandelbrot/main.c new file mode 100644 index 00000000..2fe1141d --- /dev/null +++ b/demos/applications/mandelbrot/main.c @@ -0,0 +1,79 @@ +/*
 +    ChibiOS/GFX - Copyright (C) 2012
 +                 Joel Bodenmann aka Tectu <joel@unormal.org>
 +
 +    This file is part of ChibiOS/GFX.
 +
 +    ChibiOS/GFX is free software; you can redistribute it and/or modify
 +    it under the terms of the GNU General Public License as published by
 +    the Free Software Foundation; either version 3 of the License, or
 +    (at your option) any later version.
 +
 +    ChibiOS/GFX is distributed in the hope that it will be useful,
 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +    GNU General Public License for more details.
 +
 +    You should have received a copy of the GNU General Public License
 +    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +*/
 +
 +#include "ch.h"
 +#include "hal.h"
 +#include "gfx.h"
 +
 +void mandelbrot(float x1, float y1, float x2, float y2) {
 +	unsigned int i,j, width, height;
 +	uint16_t iter;
 +	color_t color;
 +	float fwidth, fheight;
 +	
 +	float sy = y2 - y1;
 +	float sx = x2 - x1;
 +	const int MAX = 512;
 +	
 +	width = (unsigned int)gdispGetWidth();
 +	height = (unsigned int)gdispGetHeight();
 +	fwidth = width;
 +	fheight = height;
 +	
 +	for(i = 0; i < width; i++) {
 +		for(j = 0; j < height; j++) {
 +			float cy = j * sy / fheight + y1;
 +			float cx = i * sx / fwidth + x1;
 +			float x=0.0f, y=0.0f, xx=0.0f, yy=0.0f;
 +			for(iter=0; iter <= MAX && xx+yy<4.0f; iter++) {
 +				xx = x*x;
 +				yy = y*y;
 +				y = 2.0f*x*y + cy;
 +				x = xx - yy + cx;
 +			}
 +			//color = ((iter << 8) | (iter&0xFF));
 +			color = RGB2COLOR(iter<<7, iter<<4, iter);
 +			gdispDrawPixel(i, j, color);
 +		}
 +	}
 +}
 +
 +int main(void) {
 +	float cx, cy;
 +	float zoom = 1.0f;
 +
 +	halInit();
 +	chSysInit();
 +
 +	gdispInit();
 +
 +	/* where to zoom in */
 +	cx = -0.086f;
 +	cy = 0.85f;
 +
 +	while(TRUE) {
 +		mandelbrot(-2.0f*zoom+cx, -1.5f*zoom+cy, 2.0f*zoom+cx, 1.5f*zoom+cy);
 +
 +		zoom *= 0.7f;
 +		if(zoom <= 0.00001f)
 +			zoom = 1.0f;	
 +	}
 +}
 +
 diff --git a/demos/applications/notepad/gfxconf.h b/demos/applications/notepad/gfxconf.h new file mode 100644 index 00000000..45413580 --- /dev/null +++ b/demos/applications/notepad/gfxconf.h @@ -0,0 +1,43 @@ +/**
 + * This file has a different license to the rest of the GFX system.
 + * You can copy, modify and distribute this file as you see fit.
 + * You do not need to publish your source modifications to this file.
 + * The only thing you are not permitted to do is to relicense it
 + * under a different license.
 + */
 +
 +#ifndef _GFXCONF_H
 +#define _GFXCONF_H
 +
 +/* GFX sub-systems to turn on */
 +#define GFX_USE_GDISP			TRUE
 +#define GFX_USE_GWIN			FALSE
 +#define GFX_USE_GEVENT			TRUE
 +#define GFX_USE_GTIMER			TRUE
 +#define GFX_USE_GINPUT			TRUE
 +
 +/* Features for the GDISP sub-system. */
 +#define GDISP_NEED_VALIDATION	TRUE
 +#define GDISP_NEED_CLIP			TRUE
 +#define GDISP_NEED_TEXT			TRUE
 +#define GDISP_NEED_CIRCLE		TRUE
 +#define GDISP_NEED_ELLIPSE		FALSE
 +#define GDISP_NEED_ARC			FALSE
 +#define GDISP_NEED_SCROLL		FALSE
 +#define GDISP_NEED_PIXELREAD	FALSE
 +#define GDISP_NEED_CONTROL		TRUE
 +#define GDISP_NEED_MULTITHREAD	TRUE
 +#define GDISP_NEED_ASYNC		FALSE
 +#define GDISP_NEED_MSGAPI		FALSE
 +
 +/* Builtin Fonts */
 +#define GDISP_INCLUDE_FONT_SMALL		FALSE
 +#define GDISP_INCLUDE_FONT_LARGER		FALSE
 +#define GDISP_INCLUDE_FONT_UI1			FALSE
 +#define GDISP_INCLUDE_FONT_UI2			TRUE
 +#define GDISP_INCLUDE_FONT_LARGENUMBERS	TRUE
 +
 +/* Features for the GINPUT sub-system. */
 +#define GINPUT_NEED_MOUSE		TRUE
 +
 +#endif /* _GFXCONF_H */
 diff --git a/demos/applications/notepad/main.c b/demos/applications/notepad/main.c new file mode 100644 index 00000000..919aaafc --- /dev/null +++ b/demos/applications/notepad/main.c @@ -0,0 +1,113 @@ +/*
 +    ChibiOS/GFX - Copyright (C) 2012
 +                 Joel Bodenmann aka Tectu <joel@unormal.org>
 +
 +    This file is part of ChibiOS/GFX.
 +
 +    ChibiOS/GFX is free software; you can redistribute it and/or modify
 +    it under the terms of the GNU General Public License as published by
 +    the Free Software Foundation; either version 3 of the License, or
 +    (at your option) any later version.
 +
 +    ChibiOS/GFX is distributed in the hope that it will be useful,
 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +    GNU General Public License for more details.
 +
 +    You should have received a copy of the GNU General Public License
 +    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +*/
 +
 +#include "ch.h"
 +#include "hal.h"
 +#include "gfx.h"
 +
 +#define COLOR_SIZE	20
 +#define PEN_SIZE	20
 +#define OFFSET		3
 +
 +#define COLOR_BOX(a)		(ev.x >= a && ev.x <= a + COLOR_SIZE)
 +#define PEN_BOX(a)			(ev.y >= a && ev.y <= a + COLOR_SIZE)
 +#define GET_COLOR(a)		(COLOR_BOX(a * COLOR_SIZE + OFFSET))
 +#define GET_PEN(a)			(PEN_BOX(a * 2 * PEN_SIZE + OFFSET))
 +#define DRAW_COLOR(a)		(a * COLOR_SIZE + OFFSET)
 +#define DRAW_PEN(a)			(a * 2 * PEN_SIZE + OFFSET)
 +#define DRAW_AREA(x, y)		(x >= PEN_SIZE + OFFSET + 3 && x <= gdispGetWidth() && \
 +							 y >= COLOR_SIZE + OFFSET + 3 && y <= gdispGetHeight())
 +
 +void drawScreen(void) {
 +	char *msg = "ChibiOS/GFX";
 +	font_t		font1, font2;
 +
 +	font1 = gdispOpenFont("UI2 Double");
 +	font2 = gdispOpenFont("LargeNumbers");
 +
 +	gdispClear(White);
 +	gdispDrawString(gdispGetWidth()-gdispGetStringWidth(msg, font1)-3, 3, msg, font1, Black);
 +	
 +	/* colors */
 +	gdispFillArea(0 * COLOR_SIZE + 3, 3, COLOR_SIZE, COLOR_SIZE, Black);	/* Black */
 +	gdispFillArea(1 * COLOR_SIZE + 3, 3, COLOR_SIZE, COLOR_SIZE, Red);		/* Red */
 +	gdispFillArea(2 * COLOR_SIZE + 3, 3, COLOR_SIZE, COLOR_SIZE, Yellow);	/* Yellow */
 +	gdispFillArea(3 * COLOR_SIZE + 3, 3, COLOR_SIZE, COLOR_SIZE, Green);	/* Green */
 +	gdispFillArea(4 * COLOR_SIZE + 3, 3, COLOR_SIZE, COLOR_SIZE, Blue);		/* Blue */
 +	gdispDrawBox (5 * COLOR_SIZE + 3, 3, COLOR_SIZE, COLOR_SIZE, Black);	/* White */
 +
 +	/* pens */	
 +	gdispDrawString(OFFSET * 2, DRAW_PEN(1), "1", font2, Black);
 +	gdispDrawString(OFFSET * 2, DRAW_PEN(2), "2", font2, Black);
 +	gdispDrawString(OFFSET * 2, DRAW_PEN(3), "3", font2, Black);
 +	gdispDrawString(OFFSET * 2, DRAW_PEN(4), "4", font2, Black);
 +	gdispDrawString(OFFSET * 2, DRAW_PEN(5), "5", font2, Black);
 +
 +	gdispCloseFont(font1);
 +	gdispCloseFont(font2);
 +}
 +
 +GEventMouse		ev;
 +
 +int main(void) {
 +	color_t color = Black;
 +	uint16_t pen = 0;
 +
 +	halInit();
 +	chSysInit();
 +
 +	gdispInit();
 +	ginputGetMouse(0);
 +	gdispSetOrientation(GDISP_ROTATE_90);
 +
 +	drawScreen();
 +
 +	while (TRUE) {
 +		ginputGetMouseStatus(0, &ev);
 +		if (!(ev.current_buttons & GINPUT_MOUSE_BTN_LEFT))
 +			continue;
 +
 +		/* inside color box ? */
 +		if(ev.y >= OFFSET && ev.y <= COLOR_SIZE) {
 +			     if(GET_COLOR(0)) 	color = Black;
 +			else if(GET_COLOR(1))	color = Red;
 +			else if(GET_COLOR(2))	color = Yellow;
 +			else if(GET_COLOR(3))	color = Green;
 +			else if(GET_COLOR(4))	color = Blue;
 +			else if(GET_COLOR(5))	color = White;
 +		
 +		/* inside pen box ? */
 +		} else if(ev.x >= OFFSET && ev.x <= PEN_SIZE) {
 +			     if(GET_PEN(1))		pen = 0;
 +			else if(GET_PEN(2))		pen = 1;
 +			else if(GET_PEN(3))		pen = 2;
 +			else if(GET_PEN(4))		pen = 3;
 +			else if(GET_PEN(5))		pen = 4;		
 +
 +		/* inside drawing area ? */
 +		} else if(DRAW_AREA(ev.x, ev.y)) {
 +			if(pen == 0)
 +				gdispDrawPixel(ev.x, ev.y, color);
 +			else
 +				gdispFillCircle(ev.x, ev.y, pen, color);
 +		}
 +	}
 +}
 +
 diff --git a/demos/benchmarks/gfxconf.h b/demos/benchmarks/gfxconf.h new file mode 100644 index 00000000..e96bf5fd --- /dev/null +++ b/demos/benchmarks/gfxconf.h @@ -0,0 +1,41 @@ +/** + * This file has a different license to the rest of the GFX system. + * You can copy, modify and distribute this file as you see fit. + * You do not need to publish your source modifications to this file. + * The only thing you are not permitted to do is to relicense it + * under a different license. + */ + +#ifndef _GFXCONF_H +#define _GFXCONF_H + +/* GFX sub-systems to turn on */ +#define GFX_USE_GDISP                   TRUE +#define GFX_USE_GWIN                    FALSE +#define GFX_USE_GEVENT                  FALSE +#define GFX_USE_GTIMER                  FALSE +#define GFX_USE_GINPUT                  FALSE + +/* Features for the GDISP sub-system. */ +#define GDISP_NEED_VALIDATION           FALSE +#define GDISP_NEED_CLIP                 FALSE +#define GDISP_NEED_TEXT                 TRUE +#define GDISP_NEED_CIRCLE               FALSE +#define GDISP_NEED_ELLIPSE              FALSE +#define GDISP_NEED_ARC                  FALSE +#define GDISP_NEED_SCROLL               FALSE +#define GDISP_NEED_PIXELREAD            FALSE +#define GDISP_NEED_CONTROL              TRUE +#define GDISP_NEED_MULTITHREAD          FALSE +#define GDISP_NEED_ASYNC                FALSE +#define GDISP_NEED_MSGAPI               FALSE + +/* Builtin Fonts */ +#define GDISP_INCLUDE_FONT_SMALL        FALSE +#define GDISP_INCLUDE_FONT_LARGER       FALSE +#define GDISP_INCLUDE_FONT_UI1          FALSE +#define GDISP_INCLUDE_FONT_UI2          TRUE +#define GDISP_INCLUDE_FONT_LARGENUMBERS FALSE + +#endif /* _GFXCONF_H */ + diff --git a/demos/benchmarks/main.c b/demos/benchmarks/main.c new file mode 100644 index 00000000..9bd3cef3 --- /dev/null +++ b/demos/benchmarks/main.c @@ -0,0 +1,146 @@ +/*
 +    ChibiOS/GFX - Copyright (C) 2012
 +                 Joel Bodenmann aka Tectu <joel@unormal.org>
 +
 +    This file is part of ChibiOS/GFX.
 +
 +    ChibiOS/GFX is free software; you can redistribute it and/or modify
 +    it under the terms of the GNU General Public License as published by
 +    the Free Software Foundation; either version 3 of the License, or
 +    (at your option) any later version.
 +
 +    ChibiOS/GFX is distributed in the hope that it will be useful,
 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +    GNU General Public License for more details.
 +
 +    You should have received a copy of the GNU General Public License
 +    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +*/
 +
 +#include "ch.h"
 +#include "hal.h"
 +#include "chprintf.h"
 +#include "stdlib.h"
 +#include "string.h"
 +#include "gfx.h"
 +
 +#define SCB_DEMCR (*(volatile unsigned *)0xE000EDFC)
 +#define CPU_RESET_CYCLECOUNTER do { SCB_DEMCR = SCB_DEMCR | 0x01000000; \
 +DWT_CYCCNT = 0; \
 +DWT_CTRL = DWT_CTRL | 1 ; } while(0)
 +
 +static int uitoa(unsigned int value, char * buf, int max) {
 +    int n = 0;
 +    int i = 0;
 +    unsigned int tmp = 0;
 +
 +    if (NULL == buf)
 +        return -3;
 +
 +    if (2 > max)
 +        return -4;
 +
 +    i=1;
 +    tmp = value;
 +    if (0 > tmp) {
 +        tmp *= -1;
 +        i++;
 +    }
 +    for (;;) {
 +        tmp /= 10;
 +        if (0 >= tmp)
 +            break;
 +        i++;
 +    }
 +    if (i >= max) {
 +        buf[0] = '?';
 +        buf[1] = 0x0;
 +        return 2;
 +    }
 +
 +    n = i;
 +    tmp = value;
 +    if (0 > tmp) {
 +        tmp *= -1;
 +    }
 +    buf[i--] = 0x0;
 +    for (;;) {
 +        buf[i--] = (tmp % 10) + '0';
 +        tmp /= 10;
 +        if (0 >= tmp) {
 +            break;
 +        }
 +    }
 +    if (-1 != i) {
 +        buf[i--] = '-';
 +    }
 +
 +    return n;
 +}
 +
 +void benchmark(void) {
 +    uint32_t i, pixels, ms, pps;
 +    char pps_str[25];
 +	coord_t height, width, rx, ry, rcx, rcy;
 +    color_t random_color;
 +	font_t font;
 +
 +    gdispSetOrientation(GDISP_ROTATE_90);
 +    gdispClear(Black);
 +
 +	width = gdispGetWidth();
 +	height = gdispGetHeight();
 +    font = gdispOpenFont("UI2 Double");
 +
 +	gdispDrawStringBox(0, 0, width, 30, "ChibiOS/GFX - Benchmark", font, White, justifyCenter);
 +
 +	font = gdispOpenFont("UI2");
 +	gdispDrawStringBox(0, height/2, width, 30, "5000 random rectangles", font, White, justifyCenter);
 +	
 +	chThdSleepMilliseconds(3000);
 +	
 +	/* seed for the rand() */
 +	srand(DWT_CYCCNT);
 +	pixels = 0;
 +
 +	CPU_RESET_CYCLECOUNTER;
 +
 +	for (i = 0; i < 5000; i++) {
 +		random_color = (rand() % 65535);
 +		rx = (rand() % (width-10));
 +		ry = (rand() % (height-10));
 +		rcx = (rand() % ((width-rx)-10))+10;
 +		rcy = (rand() % ((height-ry)-10))+10;
 +
 +		gdispFillArea(rx, ry, rcx, rcy, random_color);
 +		pixels += (rcx+1)*(rcy+1);
 +	}
 +
 +	ms = DWT_CYCCNT / 168000;
 +	pps = (float)pixels/((float)ms/1000.0f);
 +
 +	memset (pps_str, 0, sizeof(pps_str));
 +	uitoa(pps, pps_str, sizeof(pps_str));
 +	strcat(pps_str, " Pixels/s");
 +
 +	font = gdispOpenFont("UI2 Double");
 +	gdispClear(Black);
 +	gdispDrawStringBox(0, 0, width, 30, "ChibiOS/GFX - Benchmark", font, White, justifyCenter);
 +	gdispDrawStringBox(0, height/2, width, 30, pps_str, font, White, justifyCenter);
 +	//gdispDrawString(20, height/2, pps_str, font, White);
 +}
 +
 +int main(void) {
 +    halInit();
 +    chSysInit();
 +	gdispInit();
 +	
 +	benchmark();
 +    
 +	while(TRUE) {
 +        chThdSleepMilliseconds(500);
 +	}
 +
 +	return 0;
 +}
 diff --git a/demos/modules/console/gfxconf.h b/demos/modules/console/gfxconf.h new file mode 100644 index 00000000..254bf181 --- /dev/null +++ b/demos/modules/console/gfxconf.h @@ -0,0 +1,43 @@ +/**
 + * This file has a different license to the rest of the GFX system.
 + * You can copy, modify and distribute this file as you see fit.
 + * You do not need to publish your source modifications to this file.
 + * The only thing you are not permitted to do is to relicense it
 + * under a different license.
 + */
 +
 +#ifndef _GFXCONF_H
 +#define _GFXCONF_H
 +
 +/* GFX sub-systems to turn on */
 +#define GFX_USE_GDISP			TRUE
 +#define GFX_USE_GWIN			TRUE
 +#define GFX_USE_GEVENT			FALSE
 +#define GFX_USE_GTIMER			FALSE
 +#define GFX_USE_GINPUT			FALSE
 +
 +/* Features for the GDISP sub-system. */
 +#define GDISP_NEED_VALIDATION	TRUE
 +#define GDISP_NEED_CLIP			TRUE
 +#define GDISP_NEED_TEXT			TRUE
 +#define GDISP_NEED_CIRCLE		FALSE
 +#define GDISP_NEED_ELLIPSE		FALSE
 +#define GDISP_NEED_ARC			FALSE
 +#define GDISP_NEED_SCROLL		FALSE
 +#define GDISP_NEED_PIXELREAD	FALSE
 +#define GDISP_NEED_CONTROL		FALSE
 +#define GDISP_NEED_MULTITHREAD	FALSE
 +#define GDISP_NEED_ASYNC		FALSE
 +#define GDISP_NEED_MSGAPI		FALSE
 +
 +/* Builtin Fonts */
 +#define GDISP_INCLUDE_FONT_SMALL		TRUE
 +#define GDISP_INCLUDE_FONT_LARGER		FALSE
 +#define GDISP_INCLUDE_FONT_UI1			FALSE
 +#define GDISP_INCLUDE_FONT_UI2			TRUE
 +#define GDISP_INCLUDE_FONT_LARGENUMBERS	FALSE
 +
 +/* Features for the GWIN sub-system. */
 +#define GWIN_NEED_CONSOLE		TRUE
 +
 +#endif /* _GFXCONF_H */
 diff --git a/demos/modules/console/main.c b/demos/modules/console/main.c new file mode 100644 index 00000000..4efe9d0a --- /dev/null +++ b/demos/modules/console/main.c @@ -0,0 +1,87 @@ +/*
 +    ChibiOS/GFX - Copyright (C) 2012
 +                 Joel Bodenmann aka Tectu <joel@unormal.org>
 +
 +    This file is part of ChibiOS/GFX.
 +
 +    ChibiOS/GFX is free software; you can redistribute it and/or modify
 +    it under the terms of the GNU General Public License as published by
 +    the Free Software Foundation; either version 3 of the License, or
 +    (at your option) any later version.
 +
 +    ChibiOS/GFX is distributed in the hope that it will be useful,
 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +    GNU General Public License for more details.
 +
 +    You should have received a copy of the GNU General Public License
 +    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +*/
 +
 +#include "ch.h"
 +#include "hal.h"
 +#include "chprintf.h"
 +#include "gfx.h"
 +
 +/* The handles for our three consoles */
 +GHandle GW1, GW2, GW3;
 +
 +/* The streams for our three consoles */
 +BaseSequentialStream *S1, *S2, *S3;
 +
 +int main(void) {
 +	uint8_t i;
 +	font_t	font1, font2;
 +
 +	halInit();
 +	chSysInit();
 +
 +	/* initialize and clear the display */
 +	gdispInit();
 +	gdispClear(Black);
 +	font1 = gdispOpenFont("UI2 Double");
 +	font2 = gdispOpenFont("Small");
 +
 +	/* create the three console windows and set a font for each */
 +	GW1 = gwinCreateConsole(NULL, 0, 0, gdispGetWidth(), gdispGetHeight()/2, font1);
 +	GW2 = gwinCreateConsole(NULL, 0, gdispGetHeight()/2, gdispGetWidth()/2, gdispGetHeight(), font2);
 +	GW3 = gwinCreateConsole(NULL, gdispGetWidth()/2, gdispGetHeight()/2, gdispGetWidth(), gdispGetHeight(), font2);
 +
 +	/* Set the fore- and background colors for each console */
 +	gwinSetColor(GW1, Green);
 +	gwinSetBgColor(GW1, Black);
 +	gwinSetColor(GW2, White);
 +	gwinSetBgColor(GW2, Blue);
 +	gwinSetColor(GW3, Black);
 +	gwinSetBgColor(GW3, Red);
 +
 +	/* clear all console windows - to set background */
 +	gwinClear(GW1);
 +	gwinClear(GW2);
 +	gwinClear(GW3);
 +
 +	/* receive the stream pointers of each console */
 +	S1 = gwinGetConsoleStream(GW1);
 +	S2 = gwinGetConsoleStream(GW2);
 +	S3 = gwinGetConsoleStream(GW3);
 +
 +	/* Output some data on the first console */
 +	for(i = 0; i < 10; i++) {
 +		chprintf(S1, "Hello ChibiOS/GFX!\r\n");
 +	}
 +
 +	/* Output some data on the second console */
 +	for(i = 0; i < 16; i++) {
 +		chprintf(S2, "Message Nr.: %d\r\n", i+1);
 +	}
 +
 +	/* Output some data on the third console */
 +	for(i = 0; i < 18; i++) {
 +		chprintf(S3, "Message Nr.: %d\r\n", i+1);
 +	}
 +
 +	while(TRUE) {
 +		chThdSleepMilliseconds(500);
 +	}
 +}
 +
 diff --git a/demos/modules/gdisp/gdisp_basics/gfxconf.h b/demos/modules/gdisp/gdisp_basics/gfxconf.h new file mode 100644 index 00000000..498046b4 --- /dev/null +++ b/demos/modules/gdisp/gdisp_basics/gfxconf.h @@ -0,0 +1,33 @@ +/**
 + * This file has a different license to the rest of the GFX system.
 + * You can copy, modify and distribute this file as you see fit.
 + * You do not need to publish your source modifications to this file.
 + * The only thing you are not permitted to do is to relicense it
 + * under a different license.
 + */
 +
 +#ifndef _GFXCONF_H
 +#define _GFXCONF_H
 +
 +/* GFX sub-systems to turn on */
 +#define GFX_USE_GDISP			TRUE
 +#define GFX_USE_GWIN			FALSE
 +#define GFX_USE_GEVENT			FALSE
 +#define GFX_USE_GTIMER			FALSE
 +#define GFX_USE_GINPUT			FALSE
 +
 +/* Features for the GDISP sub-system. */
 +#define GDISP_NEED_VALIDATION	TRUE
 +#define GDISP_NEED_CLIP			TRUE
 +#define GDISP_NEED_TEXT			FALSE
 +#define GDISP_NEED_CIRCLE		FALSE
 +#define GDISP_NEED_ELLIPSE		FALSE
 +#define GDISP_NEED_ARC			FALSE
 +#define GDISP_NEED_SCROLL		FALSE
 +#define GDISP_NEED_PIXELREAD	FALSE
 +#define GDISP_NEED_CONTROL		FALSE
 +#define GDISP_NEED_MULTITHREAD	FALSE
 +#define GDISP_NEED_ASYNC		FALSE
 +#define GDISP_NEED_MSGAPI		FALSE
 +
 +#endif /* _GFXCONF_H */
 diff --git a/demos/modules/gdisp/gdisp_basics/main.c b/demos/modules/gdisp/gdisp_basics/main.c new file mode 100644 index 00000000..fa0bef45 --- /dev/null +++ b/demos/modules/gdisp/gdisp_basics/main.c @@ -0,0 +1,52 @@ +/*
 +    ChibiOS/GFX - Copyright (C) 2012
 +                 Joel Bodenmann aka Tectu <joel@unormal.org>
 +
 +    This file is part of ChibiOS/GFX.
 +
 +    ChibiOS/GFX is free software; you can redistribute it and/or modify
 +    it under the terms of the GNU General Public License as published by
 +    the Free Software Foundation; either version 3 of the License, or
 +    (at your option) any later version.
 +
 +    ChibiOS/GFX is distributed in the hope that it will be useful,
 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +    GNU General Public License for more details.
 +
 +    You should have received a copy of the GNU General Public License
 +    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +*/
 +
 +#include "ch.h"
 +#include "hal.h"
 +#include "gfx.h"
 +
 +int main(void) {
 +	coord_t		width, height;
 +	coord_t		i, j;
 +
 +    halInit();
 +    chSysInit();
 +
 +    /* Initialize and clear the display */
 +    gdispInit();
 +    gdispClear(Black);
 +
 +    // Get the screen size
 +    width = gdispGetWidth();
 +    height = gdispGetHeight();
 +
 +    // Code Here
 +	gdispDrawBox(10, 10, width/2, height/2, Yellow);
 +    gdispFillArea(width/2, height/2, width/2-10, height/2-10, Blue);
 +    gdispDrawLine(5, 30, width-50, height-40, Red);
 +    
 +	for(i = 5, j = 0; i < width && j < height; i += 7, j += i/20)
 +    	gdispDrawPixel (i, j, White);
 +
 +    while(TRUE) {
 +        chThdSleepMilliseconds(500);
 +    }   
 +}
 +
 diff --git a/demos/modules/gdisp/gdisp_circles/gfxconf.h b/demos/modules/gdisp/gdisp_circles/gfxconf.h new file mode 100644 index 00000000..00d88e48 --- /dev/null +++ b/demos/modules/gdisp/gdisp_circles/gfxconf.h @@ -0,0 +1,33 @@ +/**
 + * This file has a different license to the rest of the GFX system.
 + * You can copy, modify and distribute this file as you see fit.
 + * You do not need to publish your source modifications to this file.
 + * The only thing you are not permitted to do is to relicense it
 + * under a different license.
 + */
 +
 +#ifndef _GFXCONF_H
 +#define _GFXCONF_H
 +
 +/* GFX sub-systems to turn on */
 +#define GFX_USE_GDISP			TRUE
 +#define GFX_USE_GWIN			FALSE
 +#define GFX_USE_GEVENT			FALSE
 +#define GFX_USE_GTIMER			FALSE
 +#define GFX_USE_GINPUT			FALSE
 +
 +/* Features for the GDISP sub-system. */
 +#define GDISP_NEED_VALIDATION	TRUE
 +#define GDISP_NEED_CLIP			TRUE
 +#define GDISP_NEED_TEXT			FALSE
 +#define GDISP_NEED_CIRCLE		TRUE
 +#define GDISP_NEED_ELLIPSE		TRUE
 +#define GDISP_NEED_ARC			TRUE
 +#define GDISP_NEED_SCROLL		FALSE
 +#define GDISP_NEED_PIXELREAD	FALSE
 +#define GDISP_NEED_CONTROL		FALSE
 +#define GDISP_NEED_MULTITHREAD	FALSE
 +#define GDISP_NEED_ASYNC		FALSE
 +#define GDISP_NEED_MSGAPI		FALSE
 +
 +#endif /* _GFXCONF_H */
 diff --git a/demos/modules/gdisp/gdisp_circles/main.c b/demos/modules/gdisp/gdisp_circles/main.c new file mode 100644 index 00000000..45764d4f --- /dev/null +++ b/demos/modules/gdisp/gdisp_circles/main.c @@ -0,0 +1,51 @@ +/*
 +    ChibiOS/GFX - Copyright (C) 2012
 +                 Joel Bodenmann aka Tectu <joel@unormal.org>
 +
 +    This file is part of ChibiOS/GFX.
 +
 +    ChibiOS/GFX is free software; you can redistribute it and/or modify
 +    it under the terms of the GNU General Public License as published by
 +    the Free Software Foundation; either version 3 of the License, or
 +    (at your option) any later version.
 +
 +    ChibiOS/GFX is distributed in the hope that it will be useful,
 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +    GNU General Public License for more details.
 +
 +    You should have received a copy of the GNU General Public License
 +    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +*/
 +
 +#include "ch.h"
 +#include "hal.h"
 +#include "gfx.h"
 +
 +int main(void) {
 +	coord_t		width, height;
 +
 +    halInit();
 +    chSysInit();
 +
 +    /* Initialize and clear the display */
 +    gdispInit();
 +    gdispClear(Black);
 +
 +    // Get the screen size
 +    width = gdispGetWidth();
 +    height = gdispGetHeight();
 +
 +    // Code Here
 +	gdispDrawCircle(width/2, height/2, 20, Yellow);
 +    gdispFillCircle (width/4, height/4, 50, Blue);
 +    gdispFillEllipse (width-100, height-100, 30, 60, Red);
 +    gdispDrawEllipse (width-100, height-100, 50, 20, Yellow);
 +    gdispDrawArc(width-width/8, height/8, 30, 10, 70, Gray);
 +    gdispFillArc(width/8, height/8, 30, 10, 70, Gray);
 +
 +    while(TRUE) {
 +        chThdSleepMilliseconds(500);
 +    }   
 +}
 +
 diff --git a/demos/modules/gdisp/gdisp_text/gfxconf.h b/demos/modules/gdisp/gdisp_text/gfxconf.h new file mode 100644 index 00000000..a928806b --- /dev/null +++ b/demos/modules/gdisp/gdisp_text/gfxconf.h @@ -0,0 +1,33 @@ +/**
 + * This file has a different license to the rest of the GFX system.
 + * You can copy, modify and distribute this file as you see fit.
 + * You do not need to publish your source modifications to this file.
 + * The only thing you are not permitted to do is to relicense it
 + * under a different license.
 + */
 +
 +#ifndef _GFXCONF_H
 +#define _GFXCONF_H
 +
 +/* GFX sub-systems to turn on */
 +#define GFX_USE_GDISP			TRUE
 +#define GFX_USE_GWIN			FALSE
 +#define GFX_USE_GEVENT			FALSE
 +#define GFX_USE_GTIMER			FALSE
 +#define GFX_USE_GINPUT			FALSE
 +
 +/* Features for the GDISP sub-system. */
 +#define GDISP_NEED_VALIDATION	TRUE
 +#define GDISP_NEED_CLIP			TRUE
 +#define GDISP_NEED_TEXT			TRUE
 +#define GDISP_NEED_CIRCLE		FALSE
 +#define GDISP_NEED_ELLIPSE		FALSE
 +#define GDISP_NEED_ARC			FALSE
 +#define GDISP_NEED_SCROLL		FALSE
 +#define GDISP_NEED_PIXELREAD	FALSE
 +#define GDISP_NEED_CONTROL		FALSE
 +#define GDISP_NEED_MULTITHREAD	FALSE
 +#define GDISP_NEED_ASYNC		FALSE
 +#define GDISP_NEED_MSGAPI		FALSE
 +
 +#endif /* _GFXCONF_H */
 diff --git a/demos/modules/gdisp/gdisp_text/main.c b/demos/modules/gdisp/gdisp_text/main.c new file mode 100644 index 00000000..4dc45f71 --- /dev/null +++ b/demos/modules/gdisp/gdisp_text/main.c @@ -0,0 +1,72 @@ +/*
 +    ChibiOS/GFX - Copyright (C) 2012
 +                 Joel Bodenmann aka Tectu <joel@unormal.org>
 +
 +    This file is part of ChibiOS/GFX.
 +
 +    ChibiOS/GFX is free software; you can redistribute it and/or modify
 +    it under the terms of the GNU General Public License as published by
 +    the Free Software Foundation; either version 3 of the License, or
 +    (at your option) any later version.
 +
 +    ChibiOS/GFX is distributed in the hope that it will be useful,
 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +    GNU General Public License for more details.
 +
 +    You should have received a copy of the GNU General Public License
 +    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +*/
 +
 +#include "ch.h"
 +#include "hal.h"
 +#include "gfx.h"
 +
 +int main(void) {
 +	coord_t		width, height;
 +	font_t		font1, font2, font3, font4;
 +	const char	*msg;
 +
 +    halInit();
 +    chSysInit();
 +
 +    /* Initialize and clear the display */
 +    gdispInit();
 +    gdispClear(Black);
 +
 +    // Get the screen size
 +    width = gdispGetWidth();
 +    height = gdispGetHeight();
 +
 +    // Get the fonts we want to use
 +	font1 = gdispOpenFont("UI2");
 +	font2 = gdispOpenFont("UI2 Double");
 +	font3 = gdispOpenFont("UI2 Narrow");
 +	font4 = gdispOpenFont("LargeNumbers");
 +
 +	// Display large numbers on the right (measuring the string)
 +	msg = "123456";
 +	gdispDrawString(width-gdispGetStringWidth(msg, font4)-3, 3, msg, font4, Green);
 +	
 +	// Display the font name under it.
 +	msg = gdispGetFontName(font4);
 +	gdispDrawString(width-gdispGetStringWidth(msg, font1)-3, 20, msg, font1, Green);
 +
 +	// Demonstrate our other fonts
 +	gdispDrawString(10, 10, "Writing with Font 'UI2'", font1, Yellow);
 +	gdispFillString(10, 35, "Writing with Font 'UI2 Double'", font2, Red, White);
 +	gdispDrawStringBox(0, 50, width, 40, "Writing with Font 'UI2 Narrow'", font3, Red, justifyCenter);
 +	gdispFillStringBox(0, 90, width, 40, "Filled Centered", font3, Pink, Gray, justifyCenter);
 +
 +	// Clean up the fonts
 +	gdispCloseFont(font1);
 +	gdispCloseFont(font2);
 +	gdispCloseFont(font3);
 +	gdispCloseFont(font4);
 +
 +	// Wait forever
 +    while(TRUE) {
 +        chThdSleepMilliseconds(500);
 +    }   
 +}
 +
 diff --git a/demos/modules/ginput_touch_driver_test/gfxconf.h b/demos/modules/ginput_touch_driver_test/gfxconf.h new file mode 100644 index 00000000..05f685dd --- /dev/null +++ b/demos/modules/ginput_touch_driver_test/gfxconf.h @@ -0,0 +1,47 @@ +/**
 + * This file has a different license to the rest of the GFX system.
 + * You can copy, modify and distribute this file as you see fit.
 + * You do not need to publish your source modifications to this file.
 + * The only thing you are not permitted to do is to relicense it
 + * under a different license.
 + */
 +
 +#ifndef _GFXCONF_H
 +#define _GFXCONF_H
 +
 +/* GFX sub-systems to turn on */
 +#define GFX_USE_GDISP			TRUE
 +#define GFX_USE_GWIN			TRUE
 +#define GFX_USE_GEVENT			TRUE
 +#define GFX_USE_GTIMER			TRUE
 +#define GFX_USE_GINPUT			TRUE
 +
 +/* Features for the GDISP sub-system. */
 +#define GDISP_NEED_VALIDATION	TRUE
 +#define GDISP_NEED_CLIP			TRUE
 +#define GDISP_NEED_TEXT			TRUE
 +#define GDISP_NEED_CIRCLE		FALSE
 +#define GDISP_NEED_ELLIPSE		FALSE
 +#define GDISP_NEED_ARC			FALSE
 +#define GDISP_NEED_SCROLL		FALSE
 +#define GDISP_NEED_PIXELREAD	FALSE
 +#define GDISP_NEED_CONTROL		FALSE
 +#define GDISP_NEED_MULTITHREAD	TRUE
 +#define GDISP_NEED_ASYNC		FALSE
 +#define GDISP_NEED_MSGAPI		FALSE
 +
 +/* Builtin Fonts */
 +#define GDISP_INCLUDE_FONT_SMALL		FALSE
 +#define GDISP_INCLUDE_FONT_LARGER		FALSE
 +#define GDISP_INCLUDE_FONT_UI1			FALSE
 +#define GDISP_INCLUDE_FONT_UI2			TRUE
 +#define GDISP_INCLUDE_FONT_LARGENUMBERS	FALSE
 +
 +/* Features for the GWIN sub-system. */
 +#define GWIN_NEED_BUTTON		TRUE
 +#define GWIN_NEED_CONSOLE		TRUE
 +
 +/* Features for the GINPUT sub-system. */
 +#define GINPUT_NEED_MOUSE		TRUE
 +
 +#endif /* _GFXCONF_H */
 diff --git a/demos/modules/ginput_touch_driver_test/main.c b/demos/modules/ginput_touch_driver_test/main.c new file mode 100644 index 00000000..a77e0b3f --- /dev/null +++ b/demos/modules/ginput_touch_driver_test/main.c @@ -0,0 +1,349 @@ +/*
 +    ChibiOS/GFX - Copyright (C) 2012
 +                 Joel Bodenmann aka Tectu <joel@unormal.org>
 +
 +    This file is part of ChibiOS/GFX.
 +
 +    ChibiOS/GFX is free software; you can redistribute it and/or modify
 +    it under the terms of the GNU General Public License as published by
 +    the Free Software Foundation; either version 3 of the License, or
 +    (at your option) any later version.
 +
 +    ChibiOS/GFX is distributed in the hope that it will be useful,
 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +    GNU General Public License for more details.
 +
 +    You should have received a copy of the GNU General Public License
 +    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +*/
 +
 +#include "ch.h"
 +#include "hal.h"
 +#include "chprintf.h"
 +#include "gfx.h"
 +
 +static GConsoleObject			gc;
 +static GButtonObject			gNext;
 +static GButtonObject			gPrev;
 +static GListener				gl;
 +
 +/*------------------------------------------------------------------------*
 + * GINPUT Touch Driver Calibrator.                                        *
 + *------------------------------------------------------------------------*/
 +int main(void) {
 +	GSourceHandle			gs, gsNext, gsPrev;
 +	GEvent					*pe;
 +	GEventMouse				*pem;
 +	GEventGWinButton		*peb;
 +	coord_t					swidth, sheight;
 +	GHandle					ghc, ghNext, ghPrev;
 +	BaseSequentialStream	*gp;
 +	GEventType				deviceType;
 +	font_t					font;
 +
 +	halInit();			// Initialise the Hardware
 +	chSysInit();		// Initialize the OS
 +	gdispInit();		// Initialize the display
 +
 +	// Get the display dimensions
 +	swidth = gdispGetWidth();
 +	sheight = gdispGetHeight();
 +	ghNext = ghPrev = 0;
 +
 +	// Create our title
 +	font = gdispOpenFont("UI2");
 +	gdispFillStringBox(0, 0, swidth, 20, "Touch Calibration", font, Red, White, justifyLeft);
 +
 +	// Create our main display window
 +	ghc = gwinCreateConsole(&gc, 0, 20, swidth, sheight-20, font);
 +	gwinClear(ghc);
 +	gp = gwinGetConsoleStream(ghc);
 +
 +	// Initialize the mouse in our special no calibration mode.
 +	geventListenerInit(&gl);
 +	gs = ginputGetMouse(9999);
 +	geventAttachSource(&gl, gs, GLISTEN_MOUSEDOWNMOVES|GLISTEN_MOUSEMETA);
 +
 +	/*
 +	 * Test: Device Type
 +	 */
 +
 +StepDeviceType:
 +	gwinClear(ghc);
 +	gwinSetColor(ghc, Yellow);
 +	chprintf(gp, "\n1. DEVICE TYPE\n\n");
 +
 +	pem = (GEventMouse *)&gl.event;
 +	ginputGetMouseStatus(0, pem);
 +	deviceType = pem->type;
 +
 +	gwinSetColor(ghc, White);
 +	chprintf(gp, "This is detected as a %s device\n\n",
 +		deviceType == GEVENT_MOUSE ? "MOUSE" : (pem->type == GEVENT_TOUCH ? "TOUCH" : "UNKNOWN"));
 +
 +	if (ghNext)
 +		chprintf(gp, "Press Next or Back to continue.\n");
 +	else if (deviceType == GEVENT_MOUSE)
 +		chprintf(gp, "Click the mouse button to move on to the next test.\n");
 +	else
 +		chprintf(gp, "Press and release your finger to move on to the next test.\n");
 +
 +	while(1) {
 +		pe = geventEventWait(&gl, TIME_INFINITE);
 +		if (pe->type == GEVENT_GWIN_BUTTON) {
 +			peb = (GEventGWinButton *)pe;
 +			if (peb->button == ghPrev)
 +				goto StepClickJitter;
 +			if (peb->button == ghNext)
 +				break;
 +		}
 +		if (pe->type == GEVENT_MOUSE || pe->type == GEVENT_TOUCH) {
 +			pem = (GEventMouse *)pe;
 +			if (!ghNext && (pem->meta & GMETA_MOUSE_UP))
 +				break;
 +		}
 +	}
 +
 +	/*
 +	 * Test: Mouse raw reading jitter
 +	 */
 +
 +StepRawJitter:
 +	gwinClear(ghc);
 +	gwinSetColor(ghc, Yellow);
 +	chprintf(gp, "\n2. GINPUT_MOUSE_READ_CYCLES\n\n");
 +
 +	gwinSetColor(ghc, White);
 +	if (deviceType == GEVENT_MOUSE)
 +		chprintf(gp, "Press and hold the mouse button.\n\n");
 +	else
 +		chprintf(gp, "Press and hold on the surface.\n\n");
 +	chprintf(gp, "Numbers will display in this window.\n"
 +			"Ensure that values don't jump around very much when your finger is stationary.\n\n"
 +			"Increasing GINPUT_MOUSE_READ_CYCLES helps reduce jitter but increases CPU usage.\n\n");
 +
 +	if (ghNext)
 +		chprintf(gp, "Press Next or Back to continue.\n");
 +	else if (deviceType == GEVENT_MOUSE)
 +		chprintf(gp, "Release the mouse button to move on to the next test.\n");
 +	else
 +		chprintf(gp, "Release your finger to move on to the next test.\n");
 +
 +	// For this test turn on ALL mouse movement events
 +	geventAttachSource(&gl, gs, GLISTEN_MOUSEDOWNMOVES|GLISTEN_MOUSEMETA|GLISTEN_MOUSENOFILTER);
 +
 +	while(1) {
 +		pe = geventEventWait(&gl, TIME_INFINITE);
 +		if (pe->type == GEVENT_GWIN_BUTTON) {
 +			peb = (GEventGWinButton *)pe;
 +			if (peb->button == ghPrev)
 +				goto StepDeviceType;
 +			if (peb->button == ghNext)
 +				break;
 +		}
 +		if (pe->type == GEVENT_MOUSE || pe->type == GEVENT_TOUCH) {
 +			pem = (GEventMouse *)pe;
 +			if ((pem->current_buttons & GINPUT_MOUSE_BTN_LEFT))
 +				chprintf(gp, "%u:%u\n", pem->x, pem->y);
 +			if (!ghNext && (pem->meta & GMETA_MOUSE_UP))
 +				break;
 +		}
 +	}
 +
 +	// Reset to just changed movements.
 +	geventAttachSource(&gl, gs, GLISTEN_MOUSEDOWNMOVES|GLISTEN_MOUSEMETA);
 +
 +	/*
 +	 * Test: Calibration
 +	 */
 +
 +StepCalibrate:
 +	gwinClear(ghc);
 +	gwinSetColor(ghc, Yellow);
 +	chprintf(gp, "\n3. GINPUT_MOUSE_CALIBRATION_ERROR\n\n");
 +	gwinSetColor(ghc, Gray);
 +	chprintf(gp, "Ensure GINPUT_MOUSE_NEED_CALIBRATION = TRUE and GINPUT_MOUSE_CALIBRATION_ERROR is >= 0\n\n");
 +	gwinSetColor(ghc, White);
 +	chprintf(gp, "You will be presented with a number of points to touch.\nPress them in turn.\n\n"
 +			"If the calibration repeatedly fails, increase GINPUT_MOUSE_CALIBRATION_ERROR and try again.\n\n");
 +
 +	if (ghNext)
 +		chprintf(gp, "Press Next to start the calibration.\n");
 +	else if (deviceType == GEVENT_MOUSE)
 +		chprintf(gp, "Click the mouse button to start the calibration.\n");
 +	else
 +		chprintf(gp, "Press and release your finger to start the calibration.\n");
 +
 +	while(1) {
 +		pe = geventEventWait(&gl, TIME_INFINITE);
 +		if (pe->type == GEVENT_GWIN_BUTTON) {
 +			peb = (GEventGWinButton *)pe;
 +			if (peb->button == ghPrev)
 +				goto StepRawJitter;
 +			if (peb->button == ghNext)
 +				break;
 +		}
 +		if (pe->type == GEVENT_MOUSE || pe->type == GEVENT_TOUCH) {
 +			pem = (GEventMouse *)pe;
 +			if (!ghNext && (pem->meta & GMETA_MOUSE_UP))
 +				break;
 +		}
 +	}
 +
 +	// Calibrate
 +	ginputCalibrateMouse(0);
 +
 +	/* From now on we can use Next and Previous Buttons */
 +	if (!ghNext) {
 +
 +		ghNext = gwinCreateButton(&gNext, swidth-50, 0, 50, 20, font, GBTN_NORMAL);
 +		gwinSetButtonText(ghNext, "Next", FALSE);
 +		gsNext = gwinGetButtonSource(ghNext);
 +		geventAttachSource(&gl, gsNext, 0);
 +		gwinAttachButtonMouseSource(ghNext, gs);
 +
 +		ghPrev = gwinCreateButton(&gPrev, swidth-100, 0, 50, 20, font, GBTN_NORMAL);
 +		gwinSetButtonText(ghPrev, "Back", FALSE);
 +		gsPrev = gwinGetButtonSource(ghPrev);
 +		geventAttachSource(&gl, gsPrev, 0);
 +		gwinAttachButtonMouseSource(ghPrev, gs);
 +
 +#if 0
 +		{
 +			GSourceHandle			gsButton1, gsButton2;
 +
 +			// Attach a couple of hardware toggle buttons to our Next and Back buttons as well.
 +			//	We can always use the mouse to trigger the buttons if you don't want to use hardware toggles.
 +			//	This code depends on your hardware. Turn it on only if you have
 +			//	defined a board definition for your toggle driver. Then change
 +			//	the next two lines to be correct for your hardware. The values
 +			//	below are correct for the Win32 toggle driver.
 +			gsButton1 = ginputGetToggle(GINPUT_TOGGLE_MOMENTARY1);
 +			gsButton2 = ginputGetToggle(GINPUT_TOGGLE_MOMENTARY2);
 +			gwinAttachButtonToggleSource(ghNext, gsButton2);
 +			gwinAttachButtonToggleSource(ghPrev, gsButton1);
 +		}
 +#endif
 +	}
 +
 +	// Calibration used the whole screen - re-establish our title
 +	gdispFillStringBox(0, 0, swidth, 20, "Touch Calibration", font, Green, White, justifyLeft);
 +	gwinButtonDraw(ghNext);
 +	gwinButtonDraw(ghPrev);
 +
 +	/*
 +	 * Test: Mouse movement jitter
 +	 */
 +
 +StepJitter:
 +	gwinClear(ghc);
 +	gwinSetColor(ghc, Yellow);
 +	chprintf(gp, "\n4. GINPUT_MOUSE_MOVE_JITTER\n\n");
 +
 +	gwinSetColor(ghc, White);
 +	if (deviceType == GEVENT_MOUSE)
 +		chprintf(gp, "Press and hold the mouse button and move around as if to draw.\n\n");
 +	else
 +		chprintf(gp, "Press firmly on the surface and move around as if to draw.\n\n");
 +
 +	chprintf(gp, "Dots will display in this window. Ensure that when you stop moving your finger that "
 +			"new dots stop displaying.\nNew dots should only display when your finger is moving.\n\n"
 +			"Adjust GINPUT_MOUSE_MOVE_JITTER to the smallest value that this reliably works for.\n\n");
 +	chprintf(gp, "Press Next or Back to continue.\n\n");
 +
 +	while(1) {
 +		pe = geventEventWait(&gl, TIME_INFINITE);
 +		if (pe->type == GEVENT_GWIN_BUTTON) {
 +			peb = (GEventGWinButton *)pe;
 +			if (peb->button == ghPrev)
 +				goto StepCalibrate;
 +			if (peb->button == ghNext)
 +				break;
 +		}
 +		if (pe->type == GEVENT_MOUSE || pe->type == GEVENT_TOUCH) {
 +			pem = (GEventMouse *)pe;
 +			if ((pem->current_buttons & GINPUT_MOUSE_BTN_LEFT))
 +				chprintf(gp, ".");
 +		}
 +	}
 +
 +	/*
 +	 * Test: Polling frequency
 +	 */
 +
 +StepPolling:
 +	gwinClear(ghc);
 +	gwinSetColor(ghc, Yellow);
 +	chprintf(gp, "\n5. GINPUT_MOUSE_POLL_PERIOD\n\n");
 +
 +	gwinSetColor(ghc, White);
 +	chprintf(gp, "Press firmly on the surface (or press and hold the mouse button) and move around as if to draw.\n\n");
 +	chprintf(gp, "A green line will follow your finger.\n"
 +			"Adjust GINPUT_MOUSE_POLL_PERIOD to the highest value that provides a line without "
 +			"gaps that are too big.\nDecreasing the value increases CPU usage.\n"
 +			"About 25 (millisecs) normally produces good results."
 +			"This test can be ignored for interrupt driven drivers.\n\n");
 +	chprintf(gp, "Press Next or Back to continue.\n\n");
 +
 +	while(1) {
 +		pe = geventEventWait(&gl, TIME_INFINITE);
 +		if (pe->type == GEVENT_GWIN_BUTTON) {
 +			peb = (GEventGWinButton *)pe;
 +			if (peb->button == ghPrev)
 +				goto StepJitter;
 +			if (peb->button == ghNext)
 +				break;
 +		}
 +		if (pe->type == GEVENT_MOUSE || pe->type == GEVENT_TOUCH) {
 +			pem = (GEventMouse *)pe;
 +			if ((pem->current_buttons & GINPUT_MOUSE_BTN_LEFT))
 +				gdispDrawPixel(pem->x, pem->y, Green);
 +		}
 +	}
 +	
 +	/*
 +	 * Test: Click Jitter
 +	 */
 +
 +StepClickJitter:
 +	gwinClear(ghc);
 +	gwinSetColor(ghc, Yellow);
 +	chprintf(gp, "\n6. GINPUT_MOUSE_MAX_CLICK_JITTER\n\n");
 +
 +	gwinSetColor(ghc, White);
 +	chprintf(gp, "Press and release the touch surface to \"click\".\nTry both short and long presses.\n");
 +	chprintf(gp, "For a mouse click with the left and right buttons.\n\n");
 +	chprintf(gp, "Dots will display in this window. A yellow dash is a left (or short) click. "
 +			"A red x is a right (or long) click.\n\n"
 +			"Adjust GINPUT_MOUSE_CLICK_JITTER to the smallest value that this reliably works for.\n"
 +			"Adjust GINPUT_MOUSE_CLICK_TIME to adjust distinguishing short vs long presses.\n"
 +			"TIME_INFINITE means there are no long presses (although a right mouse button will still work).\n\n"
 +			"Note: moving your finger (mouse) during a click cancels it.\n\n");
 +	chprintf(gp, "This is the last test but you can press Next or Back to continue.\n\n");
 +
 +	while(1) {
 +		pe = geventEventWait(&gl, TIME_INFINITE);
 +		if (pe->type == GEVENT_GWIN_BUTTON) {
 +			peb = (GEventGWinButton *)pe;
 +			if (peb->button == ghPrev)
 +				goto StepPolling;
 +			if (peb->button == ghNext)
 +				break;
 +		}
 +		if (pe->type == GEVENT_MOUSE || pe->type == GEVENT_TOUCH) {
 +			pem = (GEventMouse *)pe;
 +			if ((pem->meta & GMETA_MOUSE_CLICK)) {
 +				gwinSetColor(ghc, Yellow);
 +				chprintf(gp, "-");
 +			}
 +			if ((pem->meta & GMETA_MOUSE_CXTCLICK)) {
 +				gwinSetColor(ghc, Red);
 +				chprintf(gp, "x");
 +			}
 +		}
 +	}
 +
 +	// Can't let this really exit
 +	goto StepDeviceType;
 +}
 diff --git a/demos/modules/graph/gfxconf.h b/demos/modules/graph/gfxconf.h new file mode 100644 index 00000000..4f4258ed --- /dev/null +++ b/demos/modules/graph/gfxconf.h @@ -0,0 +1,36 @@ +/**
 + * This file has a different license to the rest of the GFX system.
 + * You can copy, modify and distribute this file as you see fit.
 + * You do not need to publish your source modifications to this file.
 + * The only thing you are not permitted to do is to relicense it
 + * under a different license.
 + */
 +
 +#ifndef _GFXCONF_H
 +#define _GFXCONF_H
 +
 +/* GFX sub-systems to turn on */
 +#define GFX_USE_GDISP			TRUE
 +#define GFX_USE_GWIN			TRUE
 +#define GFX_USE_GEVENT			FALSE
 +#define GFX_USE_GTIMER			FALSE
 +#define GFX_USE_GINPUT			FALSE
 +
 +/* Features for the GDISP sub-system. */
 +#define GDISP_NEED_VALIDATION	TRUE
 +#define GDISP_NEED_CLIP			TRUE
 +#define GDISP_NEED_TEXT			FALSE
 +#define GDISP_NEED_CIRCLE		TRUE
 +#define GDISP_NEED_ELLIPSE		FALSE
 +#define GDISP_NEED_ARC			FALSE
 +#define GDISP_NEED_SCROLL		FALSE
 +#define GDISP_NEED_PIXELREAD	FALSE
 +#define GDISP_NEED_CONTROL		FALSE
 +#define GDISP_NEED_MULTITHREAD	FALSE
 +#define GDISP_NEED_ASYNC		FALSE
 +#define GDISP_NEED_MSGAPI		FALSE
 +
 +/* Features for the GWIN sub-system. */
 +#define GWIN_NEED_GRAPH			TRUE
 +
 +#endif /* _GFXCONF_H */
 diff --git a/demos/modules/graph/main.c b/demos/modules/graph/main.c new file mode 100644 index 00000000..544d4c2b --- /dev/null +++ b/demos/modules/graph/main.c @@ -0,0 +1,71 @@ +#include "ch.h"
 +#include "hal.h"
 +#include "gfx.h"
 +#include "math.h"
 +
 +const GGraphPoint data[5] = {
 +	{ -40, -40 },
 +	{ 70, 40 },
 +	{ 140, 60 },
 +	{ 210, 60 },
 +	{ 280, 200 }
 +};
 +
 +GGraphObject	g;
 +
 +GGraphStyle GraphStyle1 = {
 +	{ GGRAPH_POINT_DOT, 0, Blue },			// point
 +	{ GGRAPH_LINE_NONE, 2, Gray },			// line
 +	{ GGRAPH_LINE_SOLID, 0, White },		// x axis
 +	{ GGRAPH_LINE_SOLID, 0, White },		// y axis
 +	{ GGRAPH_LINE_DASH, 5, Gray, 50 },		// x grid
 +	{ GGRAPH_LINE_DOT, 7, Yellow, 50 },		// y grid
 +	GWIN_GRAPH_STYLE_POSITIVE_AXIS_ARROWS	// flags
 +};
 +
 +GGraphStyle GraphStyle2 = {
 +	{ GGRAPH_POINT_SQUARE, 5, Red },		// point
 +	{ GGRAPH_LINE_DOT, 2, Pink },			// line
 +	{ GGRAPH_LINE_SOLID, 0, White },		// x axis
 +	{ GGRAPH_LINE_SOLID, 0, White },		// y axis
 +	{ GGRAPH_LINE_DASH, 5, Gray, 50 },		// x grid
 +	{ GGRAPH_LINE_DOT, 7, Yellow, 50 },		// y grid
 +	GWIN_GRAPH_STYLE_POSITIVE_AXIS_ARROWS	// flags
 +};
 +
 +int main(void) {
 +	GHandle		gh;
 +	uint16_t 	i;
 +	
 +	halInit();
 +	chSysInit();
 +
 +	gdispInit();
 +	gdispClear(Black);
 +	
 +	gh = gwinCreateGraph(&g, 0, 0, gdispGetWidth(), gdispGetHeight());
 +
 +	gwinGraphSetOrigin(gh, gwinGetWidth(gh)/2, gwinGetHeight(gh)/2);
 +	gwinGraphSetStyle(gh, &GraphStyle1);
 +	gwinGraphDrawAxis(gh);
 +	
 +	for(i = 0; i < gwinGetWidth(gh); i++)
 +		gwinGraphDrawPoint(gh, i-gwinGetWidth(gh)/2, 80*sin(2*0.2*M_PI*i/180));
 +
 +	gwinGraphStartSet(gh);
 +	GraphStyle1.point.color = Green;
 +	gwinGraphSetStyle(gh, &GraphStyle1);
 +	
 +	for(i = 0; i < gwinGetWidth(gh)*5; i++)
 +		gwinGraphDrawPoint(gh, i/5-gwinGetWidth(gh)/2, 95*sin(2*0.2*M_PI*i/180));
 +
 +	gwinGraphStartSet(gh);
 +	gwinGraphSetStyle(gh, &GraphStyle2);
 +
 +	gwinGraphDrawPoints(gh, data, sizeof(data)/sizeof(data[0]));
 +
 +	while(TRUE) {
 +		chThdSleepMilliseconds(100);	
 +	}
 +}
 +
 diff --git a/demos/modules/graph/result-640x480.gif b/demos/modules/graph/result-640x480.gifBinary files differ new file mode 100644 index 00000000..6fc8b30c --- /dev/null +++ b/demos/modules/graph/result-640x480.gif diff --git a/demos/modules/gtimer/gfxconf.h b/demos/modules/gtimer/gfxconf.h new file mode 100644 index 00000000..e814bd18 --- /dev/null +++ b/demos/modules/gtimer/gfxconf.h @@ -0,0 +1,19 @@ +/**
 + * This file has a different license to the rest of the GFX system.
 + * You can copy, modify and distribute this file as you see fit.
 + * You do not need to publish your source modifications to this file.
 + * The only thing you are not permitted to do is to relicense it
 + * under a different license.
 + */
 +
 +#ifndef _GFXCONF_H
 +#define _GFXCONF_H
 +
 +/* GFX sub-systems to turn on */
 +#define GFX_USE_GDISP			FALSE
 +#define GFX_USE_GWIN			FALSE
 +#define GFX_USE_GEVENT			FALSE
 +#define GFX_USE_GTIMER			TRUE
 +#define GFX_USE_GINPUT			FALSE
 +
 +#endif /* _GFXCONF_H */
 diff --git a/demos/modules/gtimer/main.c b/demos/modules/gtimer/main.c new file mode 100644 index 00000000..ae7c2c92 --- /dev/null +++ b/demos/modules/gtimer/main.c @@ -0,0 +1,59 @@ +/*
 +    ChibiOS/GFX - Copyright (C) 2012
 +                 Joel Bodenmann aka Tectu <joel@unormal.org>
 +
 +    This file is part of ChibiOS/GFX.
 +
 +    ChibiOS/GFX is free software; you can redistribute it and/or modify
 +    it under the terms of the GNU General Public License as published by
 +    the Free Software Foundation; either version 3 of the License, or
 +    (at your option) any later version.
 +
 +    ChibiOS/GFX is distributed in the hope that it will be useful,
 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +    GNU General Public License for more details.
 +
 +    You should have received a copy of the GNU General Public License
 +    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +*/
 +
 +#include "ch.h"
 +#include "hal.h"
 +#include "gfx.h"
 +
 +GTimer GT1, GT2;
 + 
 +void callback1(void* arg) {
 +    (void)arg;
 +
 +    palTogglePad(GPIOD, GPIOD_LED3);
 +}
 + 
 +void callback2(void* arg) {
 +    (void)arg;
 +
 +    palSetPad(GPIOD, GPIOD_LED4);
 +}
 + 
 +int main(void) {
 +    halInit();
 +    chSysInit();
 + 
 +    /* initialize the timers */
 +    gtimerInit(>1);
 +    gtimerInit(>2);
 + 
 +    /* continious mode - callback1() called without any argument every 250ms */
 +    gtimerStart(>1, callback1, NULL, TRUE, 250);
 + 
 +    /* single shot mode - callback2() called without any argument once after 1s */
 +    gtimerStart(>2, callback2, NULL, FALSE, 1000);
 +
 +	while(TRUE) {
 +		chThdSleepMilliseconds(500);
 +	}
 +
 +	return 0;
 +}
 +
 diff --git a/demos/modules/tdisp/gfxconf.h b/demos/modules/tdisp/gfxconf.h new file mode 100644 index 00000000..5077e010 --- /dev/null +++ b/demos/modules/tdisp/gfxconf.h @@ -0,0 +1,55 @@ +/** + * This file has a different license to the rest of the GFX system. + * You can copy, modify and distribute this file as you see fit. + * You do not need to publish your source modifications to this file. + * The only thing you are not permitted to do is to relicense it + * under a different license. + */ + +#ifndef _GFXCONF_H +#define _GFXCONF_H + +/* GFX sub-systems to turn on */ +#define GFX_USE_TDISP					TRUE +#define GFX_USE_GDISP                   FALSE +#define GFX_USE_GWIN                    FALSE +#define GFX_USE_GEVENT                  FALSE +#define GFX_USE_GTIMER                  FALSE +#define GFX_USE_GINPUT                  FALSE + +/* Features for the GDISP subsystem */ +#define GDISP_NEED_VALIDATION           FALSE +#define GDISP_NEED_CLIP                 FALSE +#define GDISP_NEED_TEXT                 FALSE +#define GDISP_NEED_CIRCLE               FALSE +#define GDISP_NEED_ELLIPSE              FALSE +#define GDISP_NEED_ARC                  FALSE +#define GDISP_NEED_SCROLL               FALSE +#define GDISP_NEED_PIXELREAD            FALSE +#define GDISP_NEED_CONTROL              FALSE +#define GDISP_NEED_MULTITHREAD          FALSE +#define GDISP_NEED_ASYNC                FALSE +#define GDISP_NEED_MSGAPI               FALSE + +/* Features for the TDISP subsystem */ +#define TDISP_NEED_4BIT_MODE			TRUE +#define TDISP_NEED_8BIT_MODE			FALSE + +/* Builtin Fonts */ +#define GDISP_INCLUDE_FONT_SMALL        FALSE +#define GDISP_INCLUDE_FONT_LARGER       FALSE +#define GDISP_INCLUDE_FONT_UI1          FALSE +#define GDISP_INCLUDE_FONT_UI2          FALSE +#define GDISP_INCLUDE_FONT_LARGENUMBERS FALSE + +/* GWIN */ +#define GWIN_NEED_CONSOLE				FALSE +#define GWIN_NEED_GRAPH					FALSE +#define GWIN_NEED_BUTTON				FALSE +#define GWIN_NEED_DIAL					FALSE + +/* GINPUT */ +#define GINPUT_NEED_MOUSE				FALSE + +#endif /* _GFXCONF_H */ + diff --git a/demos/modules/tdisp/main.c b/demos/modules/tdisp/main.c new file mode 100644 index 00000000..69ab7349 --- /dev/null +++ b/demos/modules/tdisp/main.c @@ -0,0 +1,67 @@ +/*
 +    ChibiOS/GFX - Copyright (C) 2012
 +                 Joel Bodenmann aka Tectu <joel@unormal.org>
 +
 +    This file is part of ChibiOS/GFX.
 +
 +    ChibiOS/GFX is free software; you can redistribute it and/or modify
 +    it under the terms of the GNU General Public License as published by
 +    the Free Software Foundation; either version 3 of the License, or
 +    (at your option) any later version.
 +
 +    ChibiOS/GFX is distributed in the hope that it will be useful,
 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +    GNU General Public License for more details.
 +
 +    You should have received a copy of the GNU General Public License
 +    along with this program. If not, see <http://www.gnu.org/licenses/>.
 +*/
 +
 +#include "ch.h"
 +#include "hal.h"
 +#include "gfx.h"
 +
 +int main(void) {
 +	char charmap[8];
 +
 +	halInit();
 +	chSysInit();
 +
 +	tdispInit();
 +
 +	/* reset cursor position and clear the screen */
 +	tdispHome();
 +	tdispClear();
 +
 +	/* set cursor position and draw single characters */
 +	tdispSetCursor(4, 0);
 +	tdispDrawChar('H');
 +	tdispDrawChar('D');
 +	tdispDrawChar('4');
 +	tdispDrawChar('4');
 +	tdispDrawChar('7');
 +	tdispDrawChar('8');
 +	tdispDrawChar('0');
 +
 +	/* draw a string to a given location */
 +	tdispDrawStringLocation(0, 1, "chibios-gfx.com");
 +
 +	/* create and display a custom made character */
 +	charmap[0] = 0b00000;
 +	charmap[1] = 0b00100;
 +	charmap[2] = 0b00010;
 +	charmap[3] = 0b11111;
 +	charmap[4] = 0b00010;
 +	charmap[5] = 0b00100;
 +	charmap[6] = 0b00000;
 +	charmap[7] = 0b00000;
 +	tdispCreateChar(0, charmap);
 +	tdispHome();
 +	tdispDrawChar(0);
 +
 +	while(TRUE) {
 +		chThdSleepMilliseconds(250);	
 +	}
 +}
 +
 diff --git a/demos/modules/window/gfxconf.h b/demos/modules/window/gfxconf.h new file mode 100644 index 00000000..c8080075 --- /dev/null +++ b/demos/modules/window/gfxconf.h @@ -0,0 +1,33 @@ +/**
 + * This file has a different license to the rest of the GFX system.
 + * You can copy, modify and distribute this file as you see fit.
 + * You do not need to publish your source modifications to this file.
 + * The only thing you are not permitted to do is to relicense it
 + * under a different license.
 + */
 +
 +#ifndef _GFXCONF_H
 +#define _GFXCONF_H
 +
 +/* GFX sub-systems to turn on */
 +#define GFX_USE_GDISP			TRUE
 +#define GFX_USE_GWIN			TRUE
 +#define GFX_USE_GEVENT			FALSE
 +#define GFX_USE_GTIMER			FALSE
 +#define GFX_USE_GINPUT			FALSE
 +
 +/* Features for the GDISP sub-system. */
 +#define GDISP_NEED_VALIDATION	TRUE
 +#define GDISP_NEED_CLIP			TRUE
 +#define GDISP_NEED_TEXT			FALSE
 +#define GDISP_NEED_CIRCLE		TRUE
 +#define GDISP_NEED_ELLIPSE		FALSE
 +#define GDISP_NEED_ARC			FALSE
 +#define GDISP_NEED_SCROLL		FALSE
 +#define GDISP_NEED_PIXELREAD	FALSE
 +#define GDISP_NEED_CONTROL		FALSE
 +#define GDISP_NEED_MULTITHREAD	FALSE
 +#define GDISP_NEED_ASYNC		FALSE
 +#define GDISP_NEED_MSGAPI		FALSE
 +
 +#endif /* _GFXCONF_H */
 diff --git a/demos/modules/window/main.c b/demos/modules/window/main.c new file mode 100644 index 00000000..e9cf21e0 --- /dev/null +++ b/demos/modules/window/main.c @@ -0,0 +1,67 @@ +/*
 +    ChibiOS/GFX - Copyright (C) 2012
 +                 Joel Bodenmann aka Tectu <joel@unormal.org>
 +
 +    This file is part of ChibiOS/GFX.
 +
 +    ChibiOS/GFX is free software; you can redistribute it and/or modify
 +    it under the terms of the GNU General Public License as published by
 +    the Free Software Foundation; either version 3 of the License, or
 +    (at your option) any later version.
 +
 +    ChibiOS/GFX is distributed in the hope that it will be useful,
 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +    GNU General Public License for more details.
 +
 +    You should have received a copy of the GNU General Public License
 +    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +*/
 +
 +#include "ch.h"
 +#include "hal.h"
 +#include "gfx.h"
 +
 +/* The handles for our two Windows */
 +GHandle GW1, GW2;
 +
 +int main(void) {
 +    halInit();
 +    chSysInit();
 +   	coord_t		i, j;
 +
 +    /* Initialize and clear the display */
 +    gdispInit();
 +    gdispClear(Lime);
 +
 +    /* Create two windows */
 +    GW1 = gwinCreateWindow(NULL, 20, 10, 200, 150);
 +    GW2 = gwinCreateWindow(NULL, 50, 190, 150, 100);
 +
 +    /* Set fore- and background colors for both windows */
 +    gwinSetColor(GW1, Black);
 +    gwinSetBgColor(GW1, White);
 +    gwinSetColor(GW2, White);
 +    gwinSetBgColor(GW2, Blue);
 +
 +    /* Clear both windows - to set background color */
 +    gwinClear(GW1);
 +    gwinClear(GW2);
 +
 +    gwinDrawLine (GW1, 5, 30, 150, 110);
 +    for(i=5, j=0; i < 200 && j < 150; i+=3, j+=i/20)
 +        	gwinDrawPixel (GW1, i, j);
 +
 +    /*  
 +     * Draw two filled circles at the same coordinate
 +     * of each window to demonstrate the relative coordinates
 +     * of windows
 +     */
 +    gwinFillCircle(GW1, 20, 20, 15);
 +    gwinFillCircle(GW2, 20, 20, 15);
 +
 +    while(TRUE) {
 +        chThdSleepMilliseconds(500);
 +    }   
 +}
 +
 diff --git a/demos/readme.txt b/demos/readme.txt new file mode 100644 index 00000000..fbea2090 --- /dev/null +++ b/demos/readme.txt @@ -0,0 +1,4 @@ +This folder contains a few demos which explain how to use the library. + +Only the main files are contained. No compile-able projects + | 
