From c0cf584c85d2a9ee31adccb23d307b1955e3d8fc Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Wed, 21 Nov 2012 09:54:23 +0100 Subject: [PATCH] console example doc --- demos/modules/console/main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/demos/modules/console/main.c b/demos/modules/console/main.c index f8ef6338..fd329f95 100644 --- a/demos/modules/console/main.c +++ b/demos/modules/console/main.c @@ -34,7 +34,10 @@ #include "gdisp.h" #include "gwin.h" +/* The handles for our three consoles */ GHandle GW1, GW2, GW3; + +/* The streams for our three consoles */ BaseSequentialStream *S1, *S2, *S3; int main(void) { @@ -43,15 +46,16 @@ int main(void) { halInit(); chSysInit(); + /* initialize and clear the display */ gdispInit(); - //tsInit(&TSD1); - //gdispInit(); gdispClear(Black); + /* 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); + /* Set the fore- and background colors for each console */ gwinSetColor(GW1, Green); gwinSetBgColor(GW1, Black); gwinSetColor(GW2, White); @@ -59,22 +63,27 @@ int main(void) { 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); }