console example doc

ugfx_release_2.6
Joel Bodenmann 2012-11-21 09:54:23 +01:00
parent 1dd5de6e81
commit c0cf584c85
1 changed files with 11 additions and 2 deletions

View File

@ -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);
}