From 5873d87ca2185e825f1187eca3bc7f0de7437e69 Mon Sep 17 00:00:00 2001 From: Andrew Hannam Date: Fri, 7 Dec 2012 00:52:01 +1000 Subject: 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 --- demos/modules/console/gfxconf.h | 8 ++++++++ demos/modules/console/main.c | 9 ++++++--- demos/modules/ginput_touch_driver_test/gfxconf.h | 8 ++++++++ demos/modules/ginput_touch_driver_test/main.c | 12 +++++++----- demos/modules/graph/gfxconf.h | 8 ++++++++ demos/modules/gtimer/gfxconf.h | 8 ++++++++ demos/modules/window/gfxconf.h | 10 +++++++++- 7 files changed, 54 insertions(+), 9 deletions(-) (limited to 'demos/modules') 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 -- cgit v1.2.3