static void vLcdDemo( void *pvParameters )
{
unsigned portCHAR cnt;
for ( ; ; )
{
/*General LCD task blocktime*/
vGlcdSetBlockTime(300);
/*Create a common frame for text*/
xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
/*Suspend until completion of task*/
vTaskSuspend( xLcdDemoHandle );
text.string.data = "\fGraphic LCD driver\n\tfor FreeRTOS\n";//Text to display
/*Call to the method "print text in window"*/
cGlcdPrintf( &text );
text.font.size.x = 5; text.font.size.y = 6; //Size of font
text.font.data = font5_6;
text.string.pos.y += 4;
text.string.data = "All Right reserved\nMarcelo Lorenzati - 2009";
/*Call to the method "print text in window"*/
cGlcdPrintf( &text );
/*Showing FillScreen*/
vTaskDelay( 3000 );
xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
vTaskSuspend( xLcdDemoHandle );
text.string.data = "\fFunction:FillScreen\n";
cGlcdPrintf( &text );
text.font.size.x = 5; text.font.size.y = 6;
text.font.data = font5_6;
text.string.data = "This function fills the\nwhole screen with a tile\noptimized in byte blocks.\nThe initial offset can be configured.";
cGlcdPrintf( &text );
vTaskDelay( 5000);
text.string.data = "\fIf the source is smaller\nthan the the screen, the\nimage is repeated in x\nand y.\nIf it is bigger it´s cho-\npped.";
cGlcdPrintf( &text );
vTaskDelay( 5000);
fillScr.data = pthunder;
fillScr.size.x = 128;
fillScr.size.y = 8;
for (cnt = 0; cnt < 128; cnt += 2)
{
fillScr.offset.x = cnt;
cGlcdFillScr( &fillScr );
vTaskDelay( 50 );
}
fillScr.offset.x = 0;
for (cnt = 0; cnt <= 8; cnt++)
{
fillScr.offset.y = cnt;
cGlcdFillScr( &fillScr );
vTaskDelay( 100 );
}
vTaskDelay( 1000 );
fillScr.data = pball;
fillScr.size.x = 16;
fillScr.size.y = 2;
for (cnt = 0; cnt <= 64; cnt += 2)
{
fillScr.offset.x = cnt;
fillScr.offset.y = cnt >> 4;
cGlcdFillScr( &fillScr );
vTaskDelay( 100 );
}
vTaskDelay( 2000 );
/*Showing Pixel*/
xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
vTaskSuspend( xLcdDemoHandle );
text.string.data = "\fFunction:Pixel\n";
cGlcdPrintf( &text );
text.font.size.x = 5; text.font.size.y = 6;
text.font.data = font5_6;
text.string.data = "This function plots a pix\nel or get its from the\nposition to store in a var";
cGlcdPrintf( &text );
vTaskDelay( 5000);
text.string.data = "\fThe colors are ON, OFF\nand NOT.";
cGlcdPrintf( &text );
vTaskDelay( 3000);
cGlcdFillScr( &fillScr );
pixel.param.limited = 0; pixel.param.optimized = 1;
pixel.param.getSet = SET; //We want to set the pixel
pixel.param.color = PX_COMB_ON; //We want to set the pixel
for (cnt = 0; cnt < 128; cnt ++)
{
pixel.pos.x = cnt; pixel.pos.y = getsin(cnt);
cGlcdPixel( &pixel );
}
for (cnt = 0; cnt < 64; cnt ++)
{
pixel.pos.x = cnt + 63; pixel.pos.y = 63 - psin[ cnt ];
cGlcdPixel( &pixel );
}
vTaskDelay( 1000 );
vGlcdCls(text);
text.string.data = "Pixel Set\n";
cGlcdPrintf( &text );
vTaskDelay( 3000 );
cGlcdFillScr( &fillScr );
rectangle.posIni.x = 20; rectangle.posFin.x = 106;
rectangle.posIni.y = 0; rectangle.posFin.y = 63;
rectangle.param.color = PX_COMB_ON;
rectangle.param.getSet = SET;
rectangle.param.limited = 1; rectangle.param.optimized = 1;
cGlcdRectangle( &rectangle);
cGlcdLine( &line1);
cnt=0;
pixel.pos.x = 21; pixel.pos.y = 2;
while (cnt <= 30)
{
pixel.param.getSet = GET; //We want to get the pixel
cGlcdPixel( &pixel );
if (pixel.param.color == PX_COMB_ON)
{
switch (cnt & 0x3)
{
case 0:pixel.pos.x-=4; break;
case 1:pixel.pos.y-=4; break;
case 2:pixel.pos.x+=4; break;
case 3:pixel.pos.y+=4; break;
}
cnt++;
}
else
{
pixel.param.getSet = SET; //We want to set the pixel
pixel.param.color = PX_COMB_ON;
cGlcdPixel( &pixel );
vTaskDelay(5);
}
switch (cnt & 0x3)
{
case 0:pixel.pos.x++; break;
case 1:pixel.pos.y++; break;
case 2:pixel.pos.x--; break;
case 3:pixel.pos.y--; break;
}
}
vTaskDelay( 1000 );
vGlcdCls(text);
text.string.data = "Pixel Get\n";
cGlcdPrintf( &text );
vTaskDelay( 2000 );
/*Show Line*/
xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
vTaskSuspend( xLcdDemoHandle );
text.string.data = "\fFunction:Line\n";
cGlcdPrintf( &text );
text.font.size.x = 5; text.font.size.y = 6;
text.font.data = font5_6;
text.string.data = "This function plots a\nline or get the data\nfrom it to store in a bit-array";
cGlcdPrintf( &text );
vTaskDelay( 5000);
cGlcdFillScr( &fillScr );
line1.param.color = PX_COMB_ON;
line1.param.getSet = SET;
line1.param.limited = 1;
line1.param.optimized = 1;
for (cnt = 0; cnt <= 127; cnt += 4)
{
line1.posIni.x = getsin(cnt);
line1.posIni.y = getsin(cnt+32);
line1.posFin.x = getsin(cnt+50);
line1.posFin.y = getsin(cnt+82);
cGlcdLine( &line1 );
}
text.string.pos.x = 0;text.string.pos.y = 18;
text.string.data = "This´s a Test\n";
cGlcdPrintf( &text );
vTaskDelay( 2000 );
line1.buffer.size = 64;
line1.buffer.data = bArray;
for ( cnt = 0u; cnt < 64; cnt ++)
{
line1.posIni.x = 0; line1.posIni.y = cnt;
line1.posFin.x = 63; line1.posFin.y = cnt;
line1.buffer.index = 0;
line1.param.getSet = GET;
cGlcdLine( &line1 );
line1.posIni.x = cnt + 64; line1.posIni.y = 0;
line1.posFin.x = cnt + 64; line1.posFin.y = 63;
line1.buffer.index = 0;
line1.param.getSet = SET;
line1.param.color = PX_COMB_NDATA;
cGlcdLine( &line1 );
}
vTaskDelay( 1000 );
vGlcdCls(text);
text.string.data = "Line Set\t\tLine Get\n";
cGlcdPrintf( &text );
vTaskDelay( 2000 );
/*Show Rectangle*/
xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
vTaskSuspend( xLcdDemoHandle );
text.string.data = "\fFunction:Rectangle\n";
cGlcdPrintf( &text );
text.font.size.x = 5; text.font.size.y = 6;
text.font.data = font5_6;
text.string.data = "This function plots a\nRectangle or gets it´s\ndata to store in an array";
cGlcdPrintf( &text );
vTaskDelay(3000);
cGlcdFillScr( &fillScr );
rectangle.param.limited = 1; rectangle.param.optimized = 1;
rectangle.param.getSet = SET;
for ( cnt = 0u; cnt < 127; cnt ++)
{
rectangle.posIni.x = getsin(2 * cnt);
rectangle.posFin.x = 64 + getsin(3 * cnt);
rectangle.posIni.y = getsin(5 * cnt-128);
rectangle.posFin.y = getsin(4 * cnt-64);
rectangle.param.color = PX_COMB_ON;
cGlcdRectangle( &rectangle);
vTaskDelay( 100 );
rectangle.param.color = PX_COMB_OFF;
cGlcdRectangle( &rectangle);
}
/*Show Circle*/
xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
vTaskSuspend( xLcdDemoHandle );
text.string.data = "\fFunction:Circle\n";
cGlcdPrintf( &text );
text.font.size.x = 5; text.font.size.y = 6;
text.font.data = font5_6;
text.string.data = "This function plots a\nCircle giving it the\nradius and position";
cGlcdPrintf( &text );
vTaskDelay(3000);
cGlcdFillScr( &fillScr );
circle.param.limited = 1; circle.param.optimized = 1;
circle.param.getSet = SET;
for ( cnt = 0u; cnt < 127; cnt ++)
{
circle.pos.x = 2 * getsin(2 * cnt);
circle.pos.y = getsin(3 * cnt);
circle.radio = getsin(4 * cnt);
circle.param.color = PX_COMB_ON;
cGlcdCircle( &circle );
vTaskDelay( 100 );
circle.param.color = PX_COMB_OFF;
cGlcdCircle( &circle );
}
/*Show FloodFill*/
xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
vTaskSuspend( xLcdDemoHandle );
text.string.data = "\fFunction:FloodFill\n";
cGlcdPrintf( &text );
text.font.size.x = 5; text.font.size.y = 6;
text.font.data = font5_6;
text.string.data = "This function fills the\nobject respecting its\nborders";
cGlcdPrintf( &text );
vTaskDelay(3000);
cGlcdFillScr( &fillScr );
fillScr.size.x = 128;
fillScr.size.y = 8;
fillScr.data = plaberinth;
fillScr.param.color = PX_COMB_PASTE;
cGlcdFillScr( &fillScr );
vTaskDelay( 1000 );
floodFill.size = TEST_FLOODFILL_MAX;
floodFill.data = testfloodFill;
floodFill.pos.x = 63;
floodFill.pos.y = 5;
floodFill.param.color = PX_COMB_ON;
floodFill.param.limited = 1;
floodFill.param.optimized = 1;
/*This task takes long so I increase its maximum block time*/
vGlcdSetBlockTime(2000);
cGlcdFloodFill( &floodFill );
vGlcdSetBlockTime(300);
vTaskDelay(3000);
/*Show Bitmap*/
xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
vTaskSuspend( xLcdDemoHandle );
text.string.data = "\fFunction:Bitmap\n";
cGlcdPrintf( &text );
text.font.size.x = 5; text.font.size.y = 6;
text.font.data = font5_6;
text.string.data = "This function places or\nreads a bitmap in a\nspecific position";
cGlcdPrintf( &text );
vTaskDelay(3000);
fillScr.data = pthunder;
fillScr.size.x = 128;
fillScr.size.y = 8;
fillScr.offset.x = 0;
cGlcdFillScr( &fillScr );
bitmap.param.limited = 1;
bitmap.param.optimized = 1;
gbitmap.param.limited = 1;
gbitmap.param.optimized = 1;
gbitmap.size.x = 16;
gbitmap.size.y = 16;
bitmap.size = gbitmap.size;
bitmap.source.size = gbitmap.size;
gbitmap.pos.y = 0;
bitmap.source.offset.x = 0;
bitmap.source.offset.y = 0;
for ( cnt = 0u; cnt < 253u; cnt++ )
{
gbitmap.pos.x = (unsigned int ) 2 * getsin(2 * cnt) * (128-gbitmap.size.x) / 128;
gbitmap.pos.y = (unsigned int ) (getsin(5 * cnt) * (64-gbitmap.size.y)) / 64;
gbitmap.data = gbuffer;
cGlcdBitmapGet( &gbitmap );
bitmap.pos = gbitmap.pos;
bitmap.param.color = PX_COMB_XOR;
bitmap.source.data = pball;
cGlcdBitmapSet( &bitmap );
vTaskDelay( 50 );
bitmap.param.color = PX_COMB_PASTE;
bitmap.source.data = gbuffer;
cGlcdBitmapSet( &bitmap );
}
/*Show Text Window*/
xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
vTaskSuspend( xLcdDemoHandle );
text.string.data = "\fFunction:wind.text\n";
cGlcdPrintf( &text );
text.font.size.x = 5; text.font.size.y = 6;
text.font.data = font5_6;
text.string.data = "This function place text\ninside a XY window with\nany kind of font";
cGlcdPrintf( &text );
vTaskDelay(3000);
cGlcdFillScr( &fillScr );
rectangle.posIni.x = 0;
rectangle.posIni.y = 0;
rectangle.posFin.x = 62;
rectangle.posFin.y = 63;
rectangle.param.color = PX_COMB_ON;
rectangle.param.getSet = SET;
rectangle.param.limited = 0;
rectangle.param.optimized = 1;
cGlcdRectangle( &rectangle );
rectangle.posIni.x = 65;
rectangle.posIni.y = 0;
rectangle.posFin.x = 127;
rectangle.posFin.y = 63;
cGlcdRectangle( &rectangle );
text.window.pos.x = 1;
text.window.pos.y = 1;
text.window.size.x = 61;
text.window.size.y = 61;
text.string.pos.x = 0;
text.string.pos.y = 0;
text.string.param.color = PX_COMB_PASTE;
text.string.param.optimized = 1;
text.string.param.limited = 1;
text.string.tabspace = xGlcdGetDefTAB(4);
text.string.data = "\fThis text is on a particular window, the number 1";
text.font.size.x = 7;
text.font.size.y = 8;
text.font.data = font7_8;
cGlcdPrintf( &text );
text.window.pos.x = 66;
text.string.pos.x = 0;
text.string.pos.y = 0;
text.string.data = "\fThis other text is on another window, the number 2";
cGlcdPrintf( &text );
vTaskDelay(2000);
rectangle.posIni.x = 31;
rectangle.posIni.y = 15;
rectangle.posFin.x = 95;
rectangle.posFin.y = 47;
cGlcdRectangle( &rectangle );
text.window.pos.x = rectangle.posIni.x + 1;
text.window.pos.y = rectangle.posIni.y + 1;
text.window.size.x = xGlcdSizeof(rectangle, x);
text.window.size.y = xGlcdSizeof(rectangle, y);
text.window.size.x -= 1;
text.window.size.y -= 1;
text.string.pos.x = 0;
text.string.pos.y = 0;
text.font.size.x = 5; text.font.size.y = 6;
text.font.data = font5_6;
text.string.data = "\fAnd this one is window 3,\nisn´t it\ngreat?";
cGlcdPrintf( &text );
vTaskDelay(3000);
xTaskCreate( vLcdDemoFrame, "DemoFrame", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
vTaskSuspend( xLcdDemoHandle );
text.string.data = "\fGraphic LCD driver\n\tfor FreeRTOS\n"; //Text to display
cGlcdPrintf( &text );
text.font.size.x = 5; text.font.size.y = 6; //Size of font
text.font.data = font5_6;
text.string.pos.y += 4;
text.string.data = "All Right reserved\nMarcelo Lorenzati - 2009";
cGlcdPrintf( &text );
vTaskDelete( xLcdDemoHandle );
}
}