aboutsummaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorAndrew Hannam <andrewh@inmarket.com.au>2012-12-07 00:52:01 +1000
committerAndrew Hannam <andrewh@inmarket.com.au>2012-12-07 00:52:01 +1000
commit5873d87ca2185e825f1187eca3bc7f0de7437e69 (patch)
treeda1a2f56b60d9495cafef79734082660f39abaf2 /demos
parentec89b8e82d890066f60c48349da062add76db6cd (diff)
downloaduGFX-5873d87ca2185e825f1187eca3bc7f0de7437e69.tar.gz
uGFX-5873d87ca2185e825f1187eca3bc7f0de7437e69.tar.bz2
uGFX-5873d87ca2185e825f1187eca3bc7f0de7437e69.zip
Add GDISP font routines. Fix demo bugs
Add GDISP font routines to Open and Close a font by name. Allows wildcard searching for fonts. Old global font variables are now only optionally included (soon to be deprecated). More demo fixing
Diffstat (limited to 'demos')
-rw-r--r--demos/applications/mandelbrot/gfxconf.h8
-rw-r--r--demos/applications/notepad/gfxconf.h10
-rw-r--r--demos/applications/notepad/main.c35
-rw-r--r--demos/modules/console/gfxconf.h8
-rw-r--r--demos/modules/console/main.c9
-rw-r--r--demos/modules/ginput_touch_driver_test/gfxconf.h8
-rw-r--r--demos/modules/ginput_touch_driver_test/main.c12
-rw-r--r--demos/modules/graph/gfxconf.h8
-rw-r--r--demos/modules/gtimer/gfxconf.h8
-rw-r--r--demos/modules/window/gfxconf.h10
10 files changed, 92 insertions, 24 deletions
diff --git a/demos/applications/mandelbrot/gfxconf.h b/demos/applications/mandelbrot/gfxconf.h
index 726847cd..da8baefb 100644
--- a/demos/applications/mandelbrot/gfxconf.h
+++ b/demos/applications/mandelbrot/gfxconf.h
@@ -30,6 +30,14 @@
#define GDISP_NEED_ASYNC FALSE
#define GDISP_NEED_MSGAPI FALSE
+/* Builtin Fonts */
+#define GDISP_OLD_FONT_DEFINITIONS FALSE
+#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
+
/* Features for the GWIN sub-system. */
#define GWIN_NEED_BUTTON FALSE
#define GWIN_NEED_CONSOLE FALSE
diff --git a/demos/applications/notepad/gfxconf.h b/demos/applications/notepad/gfxconf.h
index cbdb7b95..c4cf0325 100644
--- a/demos/applications/notepad/gfxconf.h
+++ b/demos/applications/notepad/gfxconf.h
@@ -26,10 +26,18 @@
#define GDISP_NEED_SCROLL FALSE
#define GDISP_NEED_PIXELREAD FALSE
#define GDISP_NEED_CONTROL FALSE
-#define GDISP_NEED_MULTITHREAD FALSE
+#define GDISP_NEED_MULTITHREAD TRUE
#define GDISP_NEED_ASYNC FALSE
#define GDISP_NEED_MSGAPI FALSE
+/* Builtin Fonts */
+#define GDISP_OLD_FONT_DEFINITIONS FALSE
+#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 GWIN sub-system. */
#define GWIN_NEED_BUTTON FALSE
#define GWIN_NEED_CONSOLE FALSE
diff --git a/demos/applications/notepad/main.c b/demos/applications/notepad/main.c
index e1b0e333..71978488 100644
--- a/demos/applications/notepad/main.c
+++ b/demos/applications/notepad/main.c
@@ -26,8 +26,8 @@
#define PEN_SIZE 20
#define OFFSET 3
-#define COLOR_BOX(a) (x >= a && x <= a + COLOR_SIZE)
-#define PEN_BOX(a) (y >= a && y <= a + COLOR_SIZE)
+#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)
@@ -37,9 +37,13 @@
void drawScreen(void) {
char *msg = "ChibiOS/GFX";
+ font_t font1, font2;
+
+ font1 = gdispOpenFont("UI2 Double");
+ font2 = gdispOpenFont("LargeNumbers");
gdispClear(White);
- gdispDrawString(gdispGetWidth()-gdispGetStringWidth(msg, &fontUI2Double)-3, 3, msg, &fontUI2Double, Black);
+ gdispDrawString(gdispGetWidth()-gdispGetStringWidth(msg, font1)-3, 3, msg, font1, Black);
/* colors */
gdispFillArea(0 * COLOR_SIZE + 3, 3, COLOR_SIZE, COLOR_SIZE, Black); /* Black */
@@ -50,11 +54,14 @@ void drawScreen(void) {
gdispDrawBox (5 * COLOR_SIZE + 3, 3, COLOR_SIZE, COLOR_SIZE, Black); /* White */
/* pens */
- gdispDrawString(OFFSET * 2, DRAW_PEN(1), "1", &fontLargeNumbers, Black);
- gdispDrawString(OFFSET * 2, DRAW_PEN(2), "2", &fontLargeNumbers, Black);
- gdispDrawString(OFFSET * 2, DRAW_PEN(3), "3", &fontLargeNumbers, Black);
- gdispDrawString(OFFSET * 2, DRAW_PEN(4), "4", &fontLargeNumbers, Black);
- gdispDrawString(OFFSET * 2, DRAW_PEN(5), "5", &fontLargeNumbers, Black);
+ 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;
@@ -73,11 +80,11 @@ int main(void) {
while (TRUE) {
ginputGetMouseStatus(0, &ev);
- if (!(ev->current_buttons & GINPUT_MOUSE_BTN_LEFT))
+ if (!(ev.current_buttons & GINPUT_MOUSE_BTN_LEFT))
continue;
/* inside color box ? */
- if(ev->y >= OFFSET && ev->y <= COLOR_SIZE) {
+ 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;
@@ -86,7 +93,7 @@ int main(void) {
else if(GET_COLOR(5)) color = White;
/* inside pen box ? */
- } else if(ev->x >= OFFSET && ev->x <= PEN_SIZE) {
+ } 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;
@@ -94,11 +101,11 @@ int main(void) {
else if(GET_PEN(5)) pen = 4;
/* inside drawing area ? */
- } else if(DRAW_AREA(ev->x, ev->y)) {
+ } else if(DRAW_AREA(ev.x, ev.y)) {
if(pen == 0)
- gdispDrawPixel(ev->x, ev->y, color);
+ gdispDrawPixel(ev.x, ev.y, color);
else
- gdispFillCircle(ev->x, ev->y, pen, color);
+ gdispFillCircle(ev.x, ev.y, pen, color);
}
}
}
diff --git a/demos/modules/console/gfxconf.h b/demos/modules/console/gfxconf.h
index d3e99de4..bbea4a23 100644
--- a/demos/modules/console/gfxconf.h
+++ b/demos/modules/console/gfxconf.h
@@ -30,6 +30,14 @@
#define GDISP_NEED_ASYNC FALSE
#define GDISP_NEED_MSGAPI FALSE
+/* Builtin Fonts */
+#define GDISP_OLD_FONT_DEFINITIONS FALSE
+#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_BUTTON FALSE
#define GWIN_NEED_CONSOLE TRUE
diff --git a/demos/modules/console/main.c b/demos/modules/console/main.c
index 830c9d00..1227e89a 100644
--- a/demos/modules/console/main.c
+++ b/demos/modules/console/main.c
@@ -37,6 +37,7 @@ BaseSequentialStream *S1, *S2, *S3;
int main(void) {
uint8_t i;
+ font_t font1, font2;
halInit();
chSysInit();
@@ -44,11 +45,13 @@ int main(void) {
/* 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, &fontUI2Double);
- GW2 = gwinCreateConsole(NULL, 0, gdispGetHeight()/2, gdispGetWidth()/2, gdispGetHeight(), &fontSmall);
- GW3 = gwinCreateConsole(NULL, gdispGetWidth()/2, gdispGetHeight()/2, gdispGetWidth(), gdispGetHeight(), &fontSmall);
+ 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);
diff --git a/demos/modules/ginput_touch_driver_test/gfxconf.h b/demos/modules/ginput_touch_driver_test/gfxconf.h
index a6d40f06..7be662b5 100644
--- a/demos/modules/ginput_touch_driver_test/gfxconf.h
+++ b/demos/modules/ginput_touch_driver_test/gfxconf.h
@@ -30,6 +30,14 @@
#define GDISP_NEED_ASYNC FALSE
#define GDISP_NEED_MSGAPI FALSE
+/* Builtin Fonts */
+#define GDISP_OLD_FONT_DEFINITIONS FALSE
+#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
diff --git a/demos/modules/ginput_touch_driver_test/main.c b/demos/modules/ginput_touch_driver_test/main.c
index d8fe1739..a77e0b3f 100644
--- a/demos/modules/ginput_touch_driver_test/main.c
+++ b/demos/modules/ginput_touch_driver_test/main.c
@@ -40,6 +40,7 @@ int main(void) {
GHandle ghc, ghNext, ghPrev;
BaseSequentialStream *gp;
GEventType deviceType;
+ font_t font;
halInit(); // Initialise the Hardware
chSysInit(); // Initialize the OS
@@ -51,10 +52,11 @@ int main(void) {
ghNext = ghPrev = 0;
// Create our title
- gdispFillStringBox(0, 0, swidth, 20, "Touch Calibration", &fontUI2, Red, White, justifyLeft);
+ 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, &fontUI2);
+ ghc = gwinCreateConsole(&gc, 0, 20, swidth, sheight-20, font);
gwinClear(ghc);
gp = gwinGetConsoleStream(ghc);
@@ -195,13 +197,13 @@ StepCalibrate:
/* From now on we can use Next and Previous Buttons */
if (!ghNext) {
- ghNext = gwinCreateButton(&gNext, swidth-50, 0, 50, 20, &fontUI2, GBTN_NORMAL);
+ 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, &fontUI2, GBTN_NORMAL);
+ ghPrev = gwinCreateButton(&gPrev, swidth-100, 0, 50, 20, font, GBTN_NORMAL);
gwinSetButtonText(ghPrev, "Back", FALSE);
gsPrev = gwinGetButtonSource(ghPrev);
geventAttachSource(&gl, gsPrev, 0);
@@ -226,7 +228,7 @@ StepCalibrate:
}
// Calibration used the whole screen - re-establish our title
- gdispFillStringBox(0, 0, swidth, 20, "Touch Calibration", &fontUI2, Green, White, justifyLeft);
+ gdispFillStringBox(0, 0, swidth, 20, "Touch Calibration", font, Green, White, justifyLeft);
gwinButtonDraw(ghNext);
gwinButtonDraw(ghPrev);
diff --git a/demos/modules/graph/gfxconf.h b/demos/modules/graph/gfxconf.h
index 23a675b9..002f1492 100644
--- a/demos/modules/graph/gfxconf.h
+++ b/demos/modules/graph/gfxconf.h
@@ -30,6 +30,14 @@
#define GDISP_NEED_ASYNC FALSE
#define GDISP_NEED_MSGAPI FALSE
+/* Builtin Fonts */
+#define GDISP_OLD_FONT_DEFINITIONS FALSE
+#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
+
/* Features for the GWIN sub-system. */
#define GWIN_NEED_BUTTON FALSE
#define GWIN_NEED_CONSOLE FALSE
diff --git a/demos/modules/gtimer/gfxconf.h b/demos/modules/gtimer/gfxconf.h
index c0f24a7a..e06d50d7 100644
--- a/demos/modules/gtimer/gfxconf.h
+++ b/demos/modules/gtimer/gfxconf.h
@@ -30,6 +30,14 @@
#define GDISP_NEED_ASYNC FALSE
#define GDISP_NEED_MSGAPI FALSE
+/* Builtin Fonts */
+#define GDISP_OLD_FONT_DEFINITIONS FALSE
+#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
+
/* Features for the GWIN sub-system. */
#define GWIN_NEED_BUTTON FALSE
#define GWIN_NEED_CONSOLE FALSE
diff --git a/demos/modules/window/gfxconf.h b/demos/modules/window/gfxconf.h
index 80c4b327..3c6eb0a3 100644
--- a/demos/modules/window/gfxconf.h
+++ b/demos/modules/window/gfxconf.h
@@ -19,7 +19,7 @@
/* Features for the GDISP sub-system. */
#define GDISP_NEED_VALIDATION TRUE
#define GDISP_NEED_CLIP TRUE
-#define GDISP_NEED_TEXT TRUE
+#define GDISP_NEED_TEXT FALSE
#define GDISP_NEED_CIRCLE TRUE
#define GDISP_NEED_ELLIPSE FALSE
#define GDISP_NEED_ARC FALSE
@@ -30,6 +30,14 @@
#define GDISP_NEED_ASYNC FALSE
#define GDISP_NEED_MSGAPI FALSE
+/* Builtin Fonts */
+#define GDISP_OLD_FONT_DEFINITIONS FALSE
+#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
+
/* Features for the GWIN sub-system. */
#define GWIN_NEED_BUTTON FALSE
#define GWIN_NEED_CONSOLE FALSE