Ejemplo n.º 1
0
int main(void)
{
   SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);

   Kentec320x240x16_SSD2119Init();
   GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119);
   ClrScreen();

   GrImageDraw(&sContext, g_pui8Image, 0, 0);
   GrFlush(&sContext);

   SysCtlDelay(SysCtlClockGet());
   // Later lab steps go between here

   ClrScreen();

   sRect.i16XMin = 1;
   sRect.i16YMin = 1;
   sRect.i16XMax = 318;
   sRect.i16YMax = 238;
   GrContextForegroundSet(&sContext, ClrRed);
   GrContextFontSet(&sContext, &g_sFontCmss30b);
   GrStringDraw(&sContext, "Texas", -1, 110, 2, 0);
   GrStringDraw(&sContext, "Instruments", -1, 80, 32, 0);
   GrStringDraw(&sContext, "Graphics", -1, 100, 62, 0);
   GrStringDraw(&sContext, "Lab", -1, 135, 92, 0);
   GrContextForegroundSet(&sContext, ClrWhite);
   GrRectDraw(&sContext, &sRect);
   GrFlush(&sContext);

   SysCtlDelay(SysCtlClockGet());

   GrContextForegroundSet(&sContext, ClrYellow);
   GrCircleFill(&sContext, 80, 182, 50);

   sRect.i16XMin = 160;
   sRect.i16YMin = 132;
   sRect.i16XMax = 312;
   sRect.i16YMax = 232;
   GrContextForegroundSet(&sContext, ClrGreen);
   GrRectDraw(&sContext, &sRect);

   SysCtlDelay(SysCtlClockGet());

   // and here
   ClrScreen();
   while(1)
   {
   }
}
Ejemplo n.º 2
0
//*****************************************************************************
//
//! Draws a filled round rectangle.
//!
//! \param pContext is a pointer to the drawing context to use.
//! \param pRect is a pointer to the structure containing the extents of the
//! rectangle.
//!
//! This function draws a filled rectangle.  The rectangle will extend from
//! \e lXMin to \e lXMax and \e lYMin to \e lYMax, inclusive.  The clipping of
//! the rectangle to the clipping rectangle is performed within this routine;
//! the display driver's rectangle fill routine is used to perform the actual
//! rectangle fill.
//!
//! \return None.
//
//*****************************************************************************
void GrRectFillRound(const tContext *pContext, const tRectangle *pRect, long lRadius)
{
  GrCircleFill(pContext, pRect->sXMin + lRadius, pRect->sYMin + lRadius, lRadius);
  GrCircleFill(pContext, pRect->sXMin + lRadius, pRect->sYMax - lRadius, lRadius);
  GrCircleFill(pContext, pRect->sXMax - lRadius, pRect->sYMin + lRadius, lRadius);
  GrCircleFill(pContext, pRect->sXMax - lRadius, pRect->sYMax - lRadius, lRadius);

  tRectangle rect;
  rect.sYMin = pRect->sYMin;
  rect.sYMax = pRect->sYMax;
  rect.sXMin = pRect->sXMin + lRadius;
  rect.sXMax = pRect->sXMax - lRadius;
  GrRectFill(pContext, &rect);
  rect.sYMin = pRect->sYMin + lRadius;
  rect.sYMax = pRect->sYMax - lRadius;
  rect.sXMin = pRect->sXMin;
  rect.sXMax = pRect->sXMin + lRadius;
  GrRectFill(pContext, &rect);
  rect.sYMin = pRect->sYMin + lRadius;
  rect.sYMax = pRect->sYMax - lRadius;
  rect.sXMin = pRect->sXMax - lRadius;
  rect.sXMax = pRect->sXMax;
  GrRectFill(pContext, &rect);
}
Ejemplo n.º 3
0
static void onDrawTitleBar(tContext *pContext)
{
  // draw the title bar of circles
  const tRectangle rect = {0, 0, LCD_WIDTH, 12};

  GrContextForegroundSet(pContext, ClrBlack);
  GrContextClipRegionSet(pContext, &rect);

  GrRectFill(pContext, &rect);

  GrContextForegroundSet(pContext, ClrWhite);

  long startx = LCD_WIDTH/2 - num_uids * 4;

  for(int i = 0; i < num_uids; i++)
  {
    if (i == selectidx)
      GrCircleFill(pContext, startx + i * 10, 4, 3);
    else
      GrCircleDraw(pContext, startx + i * 10, 4, 3);
  }
}
Ejemplo n.º 4
0
void main(void)
{
	tRectangle myRectangle1 = { 5, 10, 60, 50};
	tRectangle myRectangle2 = { 30, 20, 100, 60};
	tRectangle myRectangle3 = { 0, 0, 101, 63};

    // Stop WDT
    WDT_A_hold(WDT_A_BASE);

    // Basic GPIO initialization
    Board_init();
    Clock_init();

    // Set up LCD
    Dogs102x64_UC1701Init();
    GrContextInit(&g_sContext, &g_sDogs102x64_UC1701);
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrContextBackgroundSet(&g_sContext, ClrWhite);
    GrContextFontSet(&g_sContext, &g_sFontFixed6x8);
    GrClearDisplay(&g_sContext);

    // Intro Screen
    GrStringDrawCentered(&g_sContext,
    		"How to use MSP430",
    		AUTO_STRING_LENGTH,
    		51,
    		16,
    		TRANSPARENT_TEXT);
    GrStringDrawCentered(&g_sContext,
    		"Graphics Library",
    		AUTO_STRING_LENGTH,
    		51,
    		32,
    		TRANSPARENT_TEXT);
    GrStringDrawCentered(&g_sContext,
    		"Primitives",
    		AUTO_STRING_LENGTH,
    		51,
    		48,
    		TRANSPARENT_TEXT);
    Delay();
    GrClearDisplay(&g_sContext);


    // Draw pixels and lines on the display
    GrStringDraw(&g_sContext,
    		"Draw Pixels",
    		AUTO_STRING_LENGTH,
    		20,
    		0,
    		TRANSPARENT_TEXT);
    GrStringDraw(&g_sContext,
    		"& Lines",
    		AUTO_STRING_LENGTH,
    		30,
    		10,
    		TRANSPARENT_TEXT);
    GrPixelDraw(&g_sContext, 10, 10);
    GrPixelDraw(&g_sContext, 10, 12);
    GrPixelDraw(&g_sContext, 12, 12);
    GrPixelDraw(&g_sContext, 12, 10);
    GrLineDraw(&g_sContext, 15, 15, 60, 60);
    GrLineDraw(&g_sContext, 10, 50, 90, 10);
    GrLineDraw(&g_sContext,
    		0,
    		GrContextDpyHeightGet(&g_sContext) - 1,
    		GrContextDpyWidthGet(&g_sContext) - 1,
    		GrContextDpyHeightGet(&g_sContext) - 1);
    Delay();
    GrClearDisplay(&g_sContext);

    // Draw circles on the display
    GrStringDrawCentered(&g_sContext,
    		"Draw Circles",
    		AUTO_STRING_LENGTH,
    		51,
    		5,
    		TRANSPARENT_TEXT);
    GrCircleDraw(&g_sContext, 30, 50, 10);
    GrCircleFill(&g_sContext, 65, 37, 23);
    Delay();



    GrClearDisplay(&g_sContext);

    // Draw rectangles on the display
    GrStringDrawCentered(&g_sContext,
    		"Draw Rectangles",
    		AUTO_STRING_LENGTH,
    		51,
    		5,
    		TRANSPARENT_TEXT);
    GrRectDraw(&g_sContext, &myRectangle1);
    GrRectFill(&g_sContext, &myRectangle2);
    // Text won't be visible on screen due to transparency
    GrStringDrawCentered(&g_sContext,
    		"Normal Text",
    		AUTO_STRING_LENGTH,
    		65,
    		30,
    		TRANSPARENT_TEXT);
    // Text draws foreground and background for opacity
    GrStringDrawCentered(&g_sContext,
    		"Opaque Text",
    		AUTO_STRING_LENGTH,
    		65,
    		40,
    		OPAQUE_TEXT);
    GrContextForegroundSet(&g_sContext, ClrWhite);
    GrContextBackgroundSet(&g_sContext, ClrBlack);
    // Text draws with inverted color to become visible
    GrStringDrawCentered(&g_sContext,
    		"Invert Text",
    		AUTO_STRING_LENGTH,
    		65,
    		50,
    		TRANSPARENT_TEXT);
    Delay();
    GrClearDisplay(&g_sContext);

    // Invert the foreground and background colors
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrContextBackgroundSet(&g_sContext, ClrWhite);
	GrRectFill(&g_sContext, &myRectangle3);
    GrContextForegroundSet(&g_sContext, ClrWhite);
    GrContextBackgroundSet(&g_sContext, ClrBlack);
	GrStringDrawCentered(&g_sContext,
			"Invert Colors",
			AUTO_STRING_LENGTH,
			51,
			5,
			TRANSPARENT_TEXT);
	GrRectDraw(&g_sContext, &myRectangle1);
	GrRectFill(&g_sContext, &myRectangle2);
	// Text won't be visible on screen due to transparency
    GrStringDrawCentered(&g_sContext,
    		"Normal Text",
    		AUTO_STRING_LENGTH,
    		65,
    		30,
    		TRANSPARENT_TEXT);
    // Text draws foreground and background for opacity
    GrStringDrawCentered(&g_sContext,
    		"Opaque Text",
    		AUTO_STRING_LENGTH,
    		65,
    		40,
    		OPAQUE_TEXT);
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrContextBackgroundSet(&g_sContext, ClrWhite);
    // Text draws with inverted color to become visible
    GrStringDrawCentered(&g_sContext,
    		"Invert Text",
    		AUTO_STRING_LENGTH,
    		65,
    		50,
    		TRANSPARENT_TEXT);
	Delay();
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrContextBackgroundSet(&g_sContext, ClrWhite);
	GrClearDisplay(&g_sContext);

    // Draw Images on the display
    GrImageDraw(&g_sContext, &LPRocket_96x37_1BPP_UNCOMP, 3, 13);
    Delay();
    GrClearDisplay(&g_sContext);
    GrImageDraw(&g_sContext, &TI_Logo_69x64_1BPP_UNCOMP, 16, 0);

    while(1)
    {
    }

}
Ejemplo n.º 5
0
//*****************************************************************************
//
// Handles paint requests for the primitives canvas widget.
//
//*****************************************************************************
void
OnPrimitivePaint(tWidget *pWidget, tContext *pContext)
{
    unsigned int ulIdx;
    tRectangle sRect;

    //
    // Draw a vertical sweep of lines from red to green.
    //
    for(ulIdx = 0; ulIdx <= 8; ulIdx++)
    {
        GrContextForegroundSet(pContext,
                               (((((10 - ulIdx) * 255) / 10) << ClrRedShift) |
                                (((ulIdx * 255) / 10) << ClrGreenShift)));
        GrLineDraw(pContext, 115+X_OFFSET, 120+Y_OFFSET, 5+X_OFFSET, 120+Y_OFFSET - (11 * ulIdx));
    }

    //
    // Draw a horizontal sweep of lines from green to blue.
    //
    for(ulIdx = 1; ulIdx <= 10; ulIdx++)
    {
        GrContextForegroundSet(pContext,
                               (((((10 - ulIdx) * 255) / 10) <<
                                 ClrGreenShift) |
                                (((ulIdx * 255) / 10) << ClrBlueShift)));
        GrLineDraw(pContext, 115+X_OFFSET, 120+Y_OFFSET, 5 + (ulIdx * 11)+X_OFFSET, 29+Y_OFFSET);
    }

    //
    // Draw a filled circle with an overlapping circle.
    //
    GrContextForegroundSet(pContext, ClrBrown);
    GrCircleFill(pContext, 185+X_OFFSET, 69+Y_OFFSET, 40);
    GrContextForegroundSet(pContext, ClrSkyBlue);
    GrCircleDraw(pContext, 205+X_OFFSET, 99+Y_OFFSET, 30);

    //
    // Draw a filled rectangle with an overlapping rectangle.
    //
    GrContextForegroundSet(pContext, ClrSlateGray);
    sRect.sXMin = 20+X_OFFSET;
    sRect.sYMin = 100+Y_OFFSET;
    sRect.sXMax = 75+X_OFFSET;
    sRect.sYMax = 160+Y_OFFSET;
    GrRectFill(pContext, &sRect);
    GrContextForegroundSet(pContext, ClrSlateBlue);
    sRect.sXMin += 40;
    sRect.sYMin += 40;
    sRect.sXMax += 30;
    sRect.sYMax += 28;
    GrRectDraw(pContext, &sRect);

    //
    // Draw a piece of text in fonts of increasing size.
    //
    GrContextForegroundSet(pContext, ClrSilver);
    GrContextFontSet(pContext, &g_sFontCm14);
    GrStringDraw(pContext, "Strings", -1, 125+X_OFFSET, 110+Y_OFFSET, 0);
    GrContextFontSet(pContext, &g_sFontCm18);
    GrStringDraw(pContext, "Strings", -1, 145+X_OFFSET, 124+Y_OFFSET, 0);
    GrContextFontSet(pContext, &g_sFontCm22);
    GrStringDraw(pContext, "Strings", -1, 165+X_OFFSET, 142+Y_OFFSET, 0);
    GrContextFontSet(pContext, &g_sFontCm24);
    GrStringDraw(pContext, "Strings", -1, 185+X_OFFSET, 162+Y_OFFSET, 0);

    //
    // Draw an image.
    //
    GrImageDraw(pContext, g_TILogo, 240+X_OFFSET, 60+Y_OFFSET);
}
Ejemplo n.º 6
0
//*****************************************************************************
//
//! Draws a radio button widget.
//!
//! \param psWidget is a pointer to the radio button widget to be drawn.
//! \param bClick is a boolean that is \b true if the paint request is a result
//! of a pointer click and \b false if not.
//!
//! This function draws a radio button widget on the display.  This is called
//! in response to a \b #WIDGET_MSG_PAINT message.
//!
//! \return None.
//
//*****************************************************************************
static void
RadioButtonPaint(tWidget *psWidget, uint32_t bClick)
{
    tRadioButtonWidget *pRadio;
    tContext sCtx;
    int32_t i32X, i32Y;

    //
    // Check the arguments.
    //
    ASSERT(psWidget);

    //
    // Convert the generic widget pointer into a radio button widget pointer.
    //
    pRadio = (tRadioButtonWidget *)psWidget;

    //
    // Initialize a drawing context.
    //
    GrContextInit(&sCtx, psWidget->psDisplay);

    //
    // Initialize the clipping region based on the extents of this radio
    // button.
    //
    GrContextClipRegionSet(&sCtx, &(psWidget->sPosition));

    //
    // See if the radio button fill style is selected.
    //
    if((pRadio->ui16Style & RB_STYLE_FILL) && !bClick)
    {
        //
        // Fill the radio button with the fill color.
        //
        GrContextForegroundSet(&sCtx, pRadio->ui32FillColor);
        GrRectFill(&sCtx, &(psWidget->sPosition));
    }

    //
    // See if the radio button outline style is selected.
    //
    if((pRadio->ui16Style & RB_STYLE_OUTLINE) && !bClick)
    {
        //
        // Outline the radio button with the outline color.
        //
        GrContextForegroundSet(&sCtx, pRadio->ui32OutlineColor);
        GrRectDraw(&sCtx, &(psWidget->sPosition));
    }

    //
    // Draw the radio button.
    //
    i32X = psWidget->sPosition.i16XMin + (pRadio->ui16CircleSize / 2) + 2;
    i32Y = (psWidget->sPosition.i16YMin +
            ((psWidget->sPosition.i16YMax - psWidget->sPosition.i16YMin) / 2));
    if(!bClick)
    {
        GrContextForegroundSet(&sCtx, pRadio->ui32OutlineColor);
        GrCircleDraw(&sCtx, i32X, i32Y, pRadio->ui16CircleSize / 2);
    }

    //
    // Select the foreground color based on whether or not the radio button is
    // selected.
    //
    if(pRadio->ui16Style & RB_STYLE_SELECTED)
    {
        GrContextForegroundSet(&sCtx, pRadio->ui32OutlineColor);
    }
    else
    {
        GrContextForegroundSet(&sCtx, pRadio->ui32FillColor);
    }

    //
    // Fill in the radio button.
    //
    GrCircleFill(&sCtx, i32X, i32Y, (pRadio->ui16CircleSize / 2) - 2);

    //
    // See if the radio button text or image style is selected.
    //
    if((pRadio->ui16Style & (RB_STYLE_TEXT | RB_STYLE_IMG)) && !bClick)
    {
        //
        // Shrink the clipping region by the size of the radio button so that
        // it is not overwritten by further "decorative" portions of the
        // widget.
        //
        sCtx.sClipRegion.i16XMin += pRadio->ui16CircleSize + 4;

        //
        // If the radio button outline style is selected then shrink the
        // clipping region by one pixel on each side so that the outline is not
        // overwritten by the text or image.
        //
        if(pRadio->ui16Style & RB_STYLE_OUTLINE)
        {
            sCtx.sClipRegion.i16YMin++;
            sCtx.sClipRegion.i16XMax--;
            sCtx.sClipRegion.i16YMax--;
        }

        //
        // See if the radio button image style is selected.
        //
        if(pRadio->ui16Style & RB_STYLE_IMG)
        {
            //
            // Determine where along the Y extent of the widget to draw the
            // image.  It is drawn at the top if it takes all (or more than
            // all) of the Y extent of the widget, and it is drawn centered if
            // it takes less than the Y extent.
            //
            if(GrImageHeightGet(pRadio->pui8Image) >
                    (sCtx.sClipRegion.i16YMax - sCtx.sClipRegion.i16YMin))
            {
                i32Y = sCtx.sClipRegion.i16YMin;
            }
            else
            {
                i32Y = (sCtx.sClipRegion.i16YMin +
                        ((sCtx.sClipRegion.i16YMax - sCtx.sClipRegion.i16YMin -
                          GrImageHeightGet(pRadio->pui8Image) + 1) / 2));
            }

            //
            // Set the foreground and background colors to use for 1 BPP
            // images.
            //
            GrContextForegroundSet(&sCtx, pRadio->ui32TextColor);
            GrContextBackgroundSet(&sCtx, pRadio->ui32FillColor);

            //
            // Draw the image next to the radio button.
            //
            GrImageDraw(&sCtx, pRadio->pui8Image, sCtx.sClipRegion.i16XMin,
                        i32Y);
        }

        //
        // See if the radio button text style is selected.
        //
        if(pRadio->ui16Style & RB_STYLE_TEXT)
        {
            //
            // Determine where along the Y extent of the widget to draw the
            // string.  It is drawn at the top if it takes all (or more than
            // all) of the Y extent of the widget, and it is drawn centered if
            // it takes less than the Y extent.
            //
            if(GrFontHeightGet(pRadio->psFont) >
                    (sCtx.sClipRegion.i16YMax - sCtx.sClipRegion.i16YMin))
            {
                i32Y = sCtx.sClipRegion.i16YMin;
            }
            else
            {
                i32Y = (sCtx.sClipRegion.i16YMin +
                        ((sCtx.sClipRegion.i16YMax - sCtx.sClipRegion.i16YMin -
                          GrFontHeightGet(pRadio->psFont) + 1) / 2));
            }

            //
            // Draw the text next to the radio button.
            //
            GrContextFontSet(&sCtx, pRadio->psFont);
            GrContextForegroundSet(&sCtx, pRadio->ui32TextColor);
            GrContextBackgroundSet(&sCtx, pRadio->ui32FillColor);
            GrStringDraw(&sCtx, pRadio->pcText, -1, sCtx.sClipRegion.i16XMin,
                         i32Y, pRadio->ui16Style & RB_STYLE_TEXT_OPAQUE);
        }
    }
}
Ejemplo n.º 7
0
Archivo: main.c Proyecto: tnapiork/all
void main(void)
{
    // Stop WDT
    WDTCTL = WDTPW + WDTHOLD;

    // Initialize the boards
    boardInit();
    clockInit();
    timerInit();
    flashInit();

    __bis_SR_register(GIE);

    // Set up the LCD
    LCDInit();
    GrContextInit(&g_sContext, &g_sharp96x96LCD);
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrContextBackgroundSet(&g_sContext, ClrWhite);
    GrContextFontSet(&g_sContext, &g_sFontFixed6x8);
    GrClearDisplay(&g_sContext);
    GrFlush(&g_sContext);

    // Intro Screen
    GrStringDrawCentered(&g_sContext, 
                         "How to use", 
                         AUTO_STRING_LENGTH, 
                         48, 
                         15, 
                         TRANSPARENT_TEXT);
    GrStringDrawCentered(&g_sContext, 
                         "the MSP430", 
                         AUTO_STRING_LENGTH, 
                         48, 
                         35, 
                         TRANSPARENT_TEXT);
    GrStringDraw(&g_sContext, 
                 "Graphics Library", 
                 AUTO_STRING_LENGTH, 
                 1, 
                 51, 
                 TRANSPARENT_TEXT);
    GrStringDrawCentered(&g_sContext, 
                         "Primitives", 
                         AUTO_STRING_LENGTH, 
                         48, 
                         75, 
                         TRANSPARENT_TEXT);
    GrFlush(&g_sContext);
    Delay_long();
    GrClearDisplay(&g_sContext);

    // Draw pixels and lines on the display
    GrStringDrawCentered(&g_sContext, 
                         "Draw Pixels", 
                         AUTO_STRING_LENGTH, 
                         48, 
                         5, 
                         TRANSPARENT_TEXT);
    GrStringDrawCentered(&g_sContext, 
                         "& Lines", 
                         AUTO_STRING_LENGTH, 
                         48, 
                         15, 
                         TRANSPARENT_TEXT);
    GrPixelDraw(&g_sContext, 30, 30);
    GrPixelDraw(&g_sContext, 30, 32);
    GrPixelDraw(&g_sContext, 32, 32);
    GrPixelDraw(&g_sContext, 32, 30);
    GrLineDraw(&g_sContext, 35, 35, 90, 90);
    GrLineDraw(&g_sContext, 5, 80, 80, 20);
    GrLineDraw(&g_sContext, 
               0, 
               GrContextDpyHeightGet(&g_sContext) - 1, 
               GrContextDpyWidthGet(&g_sContext) - 1, 
               GrContextDpyHeightGet(&g_sContext) - 1);
    GrFlush(&g_sContext);
    Delay_long();
    GrClearDisplay(&g_sContext);

    // Draw circles on the display
    GrStringDraw(&g_sContext, 
                 "Draw Circles", 
                 AUTO_STRING_LENGTH, 
                 10, 
                 5, 
                 TRANSPARENT_TEXT);
    GrCircleDraw(&g_sContext, 30, 70, 20);
    GrCircleFill(&g_sContext, 60, 50, 30);
    GrFlush(&g_sContext);
    Delay_long();
    GrClearDisplay(&g_sContext);

    // Draw rectangles on the display
    GrStringDrawCentered(&g_sContext, 
                         "Draw Rectangles", 
                         AUTO_STRING_LENGTH, 
                         48, 
                         5, 
                         TRANSPARENT_TEXT);
    GrRectDraw(&g_sContext, &myRectangle1);
    GrRectFill(&g_sContext, &myRectangle2);
    GrFlush(&g_sContext);
    Delay_long();
    GrClearDisplay(&g_sContext);

    // Combining Primitive screen
    GrStringDrawCentered(&g_sContext, 
                         "Combining", 
                         AUTO_STRING_LENGTH, 
                         48, 
                         15, 
                         TRANSPARENT_TEXT);
    GrStringDrawCentered(&g_sContext, 
                         "Primitives to", 
                         AUTO_STRING_LENGTH, 
                         48, 
                         35, 
                         TRANSPARENT_TEXT);
    GrStringDrawCentered(&g_sContext, 
                         "create menus", 
                         AUTO_STRING_LENGTH, 
                         48, 
                         51, 
                         TRANSPARENT_TEXT);
    GrStringDrawCentered(&g_sContext, 
                         "and animations", 
                         AUTO_STRING_LENGTH, 
                         48, 
                         75, 
                         TRANSPARENT_TEXT);
    GrFlush(&g_sContext);
    Delay_long();
    GrClearDisplay(&g_sContext);

    // Draw a Menu screen
    GrStringDrawCentered(&g_sContext, 
                         "Create a Menu", 
                         AUTO_STRING_LENGTH, 
                         48, 
                         5, 
                         TRANSPARENT_TEXT);
    GrRectDraw(&g_sContext, &myRectangleOption1);
    GrStringDraw(&g_sContext,"Option #1", 10,15,15,TRANSPARENT_TEXT);
    GrRectFill(&g_sContext, &myRectangleOption2);
    GrStringDraw(&g_sContext,"Option #2", 10,15,25,TRANSPARENT_TEXT);
    GrRectDraw(&g_sContext, &myRectangleOption3);
    GrStringDraw(&g_sContext,"Option #3", 10,15,35,TRANSPARENT_TEXT);
    GrRectDraw(&g_sContext, &myRectangleOption4);
    GrStringDraw(&g_sContext,"Option #4", 10,15,45,TRANSPARENT_TEXT);
    GrRectDraw(&g_sContext, &myRectangleOption5);
    GrStringDraw(&g_sContext,"Option #5", 10,15,55,TRANSPARENT_TEXT);
    GrFlush(&g_sContext);
    Delay_long();
    GrClearDisplay(&g_sContext);

    // Show progress bar screen
    // The following animation consist on displaying a progress bar and 
    // updating the progress bar in increments of 25%.
    GrStringDrawCentered(&g_sContext, 
                         "Show progress", 
                         AUTO_STRING_LENGTH, 
                         48, 
                         5, 
                         TRANSPARENT_TEXT);
    GrRectDraw(&g_sContext, &myRectangleFrame);
    GrStringDrawCentered(&g_sContext,
                         "Processing...", 
                         AUTO_STRING_LENGTH, 
                         48, 
                         75, 
                         TRANSPARENT_TEXT);
    GrFlush(&g_sContext);
    Delay_short();

    // Update display with 25 %. Initial value of "myRectangleProgress" are set 
    // to update bar with a 25 % increment.
    GrRectFill(&g_sContext, &myRectangleProgress);
    GrFlush(&g_sContext);
    Delay_short();

    // Set myRectangleProgress values to update progress bar with 50 %
    myRectangleProgress.sXMin = 30;
    myRectangleProgress.sYMin = 40;
    myRectangleProgress.sXMax = 50;
    myRectangleProgress.sYMax = 60;

    GrRectFill(&g_sContext, &myRectangleProgress);
    GrFlush(&g_sContext);
    Delay_short();

    // Set myRectangleProgress values to update progress bar with 75 %
    myRectangleProgress.sXMin = 50;
    myRectangleProgress.sYMin = 40;
    myRectangleProgress.sXMax = 70;
    myRectangleProgress.sYMax = 60;

    GrRectFill(&g_sContext, &myRectangleProgress);
    GrFlush(&g_sContext);
    Delay_short();

    // Set myRectangleProgress values to update progress bar with 100 %
    myRectangleProgress.sXMin = 70;
    myRectangleProgress.sYMin = 40;
    myRectangleProgress.sXMax = 90;
    myRectangleProgress.sYMax = 60;
    GrRectFill(&g_sContext, &myRectangleProgress);

    GrStringDrawCentered(&g_sContext,
                         "DONE!", 
                         AUTO_STRING_LENGTH, 
                         48, 
                         85, 
                         TRANSPARENT_TEXT);
    GrFlush(&g_sContext);
    Delay_long();



    while(1);

}
Ejemplo n.º 8
0
//*****************************************************************************
//
// Handles paint requests for the primitives canvas widget.
//
//*****************************************************************************
void
OnPrimitivePaint(tWidget *psWidget, tContext *psContext)
{
    uint32_t ui32Idx;
    tRectangle sRect;

    //
    // Draw a vertical sweep of lines from red to green.
    //
    for(ui32Idx = 0; ui32Idx <= 8; ui32Idx++) {
        GrContextForegroundSet(psContext,
                               (((((10 - ui32Idx) * 255) / 10) << ClrRedShift) |
                                (((ui32Idx * 255) / 10) << ClrGreenShift)));
        GrLineDraw(psContext, 115, 120, 5, 120 - (11 * ui32Idx));
    }

    //
    // Draw a horizontal sweep of lines from green to blue.
    //
    for(ui32Idx = 1; ui32Idx <= 10; ui32Idx++) {
        GrContextForegroundSet(psContext,
                               (((((10 - ui32Idx) * 255) / 10) <<
                                 ClrGreenShift) |
                                (((ui32Idx * 255) / 10) << ClrBlueShift)));
        GrLineDraw(psContext, 115, 120, 5 + (ui32Idx * 11), 29);
    }

    //
    // Draw a filled circle with an overlapping circle.
    //
    GrContextForegroundSet(psContext, ClrBrown);
    GrCircleFill(psContext, 185, 69, 40);
    GrContextForegroundSet(psContext, ClrSkyBlue);
    GrCircleDraw(psContext, 205, 99, 30);

    //
    // Draw a filled rectangle with an overlapping rectangle.
    //
    GrContextForegroundSet(psContext, ClrSlateGray);
    sRect.i16XMin = 20;
    sRect.i16YMin = 100;
    sRect.i16XMax = 75;
    sRect.i16YMax = 160;
    GrRectFill(psContext, &sRect);
    GrContextForegroundSet(psContext, ClrSlateBlue);
    sRect.i16XMin += 40;
    sRect.i16YMin += 40;
    sRect.i16XMax += 30;
    sRect.i16YMax += 28;
    GrRectDraw(psContext, &sRect);

    //
    // Draw a piece of text in fonts of increasing size.
    //
    GrContextForegroundSet(psContext, ClrSilver);
    GrContextFontSet(psContext, &g_sFontCm14);
    GrStringDraw(psContext, "Strings", -1, 125, 110, 0);
    GrContextFontSet(psContext, &g_sFontCm18);
    GrStringDraw(psContext, "Strings", -1, 145, 124, 0);
    GrContextFontSet(psContext, &g_sFontCm22);
    GrStringDraw(psContext, "Strings", -1, 165, 142, 0);
    GrContextFontSet(psContext, &g_sFontCm24);
    GrStringDraw(psContext, "Strings", -1, 185, 162, 0);

    //
    // Draw an image.
    //
    GrImageDraw(psContext, g_pui8Logo, 270, 80);
}
Ejemplo n.º 9
0
//*****************************************************************************
//
// A simple demonstration of the features of the Stellaris Graphics Library.
//
//*****************************************************************************
int
main(void)
{
    unsigned long ulIdx;
    tRectangle sRect;

    //
    // Set the clocking to run from the PLL.
    //
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_8MHZ);

    //
    // Initialize the display driver.
    //
    Formike128x128x16Init();

    //
    // Turn on the backlight.
    //
    Formike128x128x16BacklightOn();

    //
    // Initialize the graphics context.
    //
    GrContextInit(&g_sContext, &g_sFormike128x128x16);

    //
    // Fill the top 15 rows of the screen with blue to create the banner.
    //
    sRect.sXMin = 0;
    sRect.sYMin = 0;
    sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1;
    sRect.sYMax = 14;
    GrContextForegroundSet(&g_sContext, ClrDarkBlue);
    GrRectFill(&g_sContext, &sRect);

    //
    // Put a white box around the banner.
    //
    GrContextForegroundSet(&g_sContext, ClrWhite);
    GrRectDraw(&g_sContext, &sRect);

    //
    // Put the application name in the middle of the banner.
    //
    GrContextFontSet(&g_sContext, &g_sFontFixed6x8);
    GrStringDrawCentered(&g_sContext, "grlib_demo", -1,
                         GrContextDpyWidthGet(&g_sContext) / 2, 7, 0);

    //
    // Draw a vertical sweep of lines from red to green.
    //
    for(ulIdx = 0; ulIdx <= 10; ulIdx++)
    {
        GrContextForegroundSet(&g_sContext,
                               (((((10 - ulIdx) * 255) / 10) << ClrRedShift) |
                                (((ulIdx * 255) / 10) << ClrGreenShift)));
        GrLineDraw(&g_sContext, 62, 70, 2, 70 - (5 * ulIdx));
    }

    //
    // Draw a horizontal sweep of lines from green to blue.
    //
    for(ulIdx = 1; ulIdx <= 10; ulIdx++)
    {
        GrContextForegroundSet(&g_sContext,
                               (((((10 - ulIdx) * 255) / 10) <<
                                 ClrGreenShift) |
                                (((ulIdx * 255) / 10) << ClrBlueShift)));
        GrLineDraw(&g_sContext, 62, 70, 2 + (ulIdx * 6), 20);
    }

    //
    // Draw a filled circle with an overlapping circle.
    //
    GrContextForegroundSet(&g_sContext, ClrBrown);
    GrCircleFill(&g_sContext, 88, 37, 17);
    GrContextForegroundSet(&g_sContext, ClrSkyBlue);
    GrCircleDraw(&g_sContext, 104, 45, 17);

    //
    // Draw a filled rectangle with an overlapping rectangle.
    //
    GrContextForegroundSet(&g_sContext, ClrSlateGray);
    sRect.sXMin = 4;
    sRect.sYMin = 84;
    sRect.sXMax = 42;
    sRect.sYMax = 104;
    GrRectFill(&g_sContext, &sRect);
    GrContextForegroundSet(&g_sContext, ClrSlateBlue);
    sRect.sXMin += 12;
    sRect.sYMin += 15;
    sRect.sXMax += 12;
    sRect.sYMax += 15;
    GrRectDraw(&g_sContext, &sRect);

    //
    // Draw a piece of text in fonts of increasing size.
    //
    GrContextForegroundSet(&g_sContext, ClrSilver);
    GrStringDraw(&g_sContext, "Strings", -1, 75, 114, 0);

    //
    // Draw an image.
    //
    GrImageDraw(&g_sContext, g_pucLogo, 80, 77);

    //
    // Flush any cached drawing operations.
    //
    GrFlush(&g_sContext);

    //
    // Loop forever.
    //
    while(1)
    {
    }
}
Ejemplo n.º 10
0
//*****************************************************************************
//
// Handles paint requests for the primitives canvas widget.
//
//*****************************************************************************
void
OnPrimitivePaint(tWidget *pWidget, tContext *pContext)
{
    unsigned long ulIdx;
    tRectangle sRect;

    //
    // Draw a vertical sweep of lines from red to green.
    //
    for(ulIdx = 0; ulIdx <= 10; ulIdx++)
    {
        GrContextForegroundSet(pContext,
                               (((((10 - ulIdx) * 255) / 10) << ClrRedShift) |
                                (((ulIdx * 255) / 10) << ClrGreenShift)));
        GrLineDraw(pContext, 115, 139, 5, 139 - (11 * ulIdx));
    }

    //
    // Draw a horizontal sweep of lines from green to blue.
    //
    for(ulIdx = 1; ulIdx <= 10; ulIdx++)
    {
        GrContextForegroundSet(pContext,
                               (((((10 - ulIdx) * 255) / 10) <<
                                 ClrGreenShift) |
                                (((ulIdx * 255) / 10) << ClrBlueShift)));
        GrLineDraw(pContext, 115, 139, 5 + (ulIdx * 11), 29);
    }

    //
    // Draw a filled circle with an overlapping circle.
    //
    GrContextForegroundSet(pContext, ClrBrown);
    GrCircleFill(pContext, 165, 69, 40);
    GrContextForegroundSet(pContext, ClrSkyBlue);
    GrCircleDraw(pContext, 195, 99, 40);

    //
    // Draw a filled rectangle with an overlapping rectangle.
    //
    GrContextForegroundSet(pContext, ClrSlateGray);
    sRect.sXMin = 5;
    sRect.sYMin = 149;
    sRect.sXMax = 75;
    sRect.sYMax = 219;
    GrRectFill(pContext, &sRect);
    GrContextForegroundSet(pContext, ClrSlateBlue);
    sRect.sXMin += 40;
    sRect.sYMin += 40;
    sRect.sXMax += 40;
    sRect.sYMax += 40;
    GrRectDraw(pContext, &sRect);

    //
    // Draw a piece of text in fonts of increasing size.
    //
    GrContextForegroundSet(pContext, ClrSilver);
    GrContextFontSet(pContext, g_pFontCm14);
    GrStringDraw(pContext, "Strings", -1, 125, 149, 0);
    GrContextFontSet(pContext, g_pFontCm18);
    GrStringDraw(pContext, "Strings", -1, 125, 163, 0);
    GrContextFontSet(pContext, g_pFontCm22);
    GrStringDraw(pContext, "Strings", -1, 125, 181, 0);
    GrContextFontSet(pContext, g_pFontCm26);
    GrStringDraw(pContext, "Strings", -1, 125, 203, 0);
    GrContextFontSet(pContext, g_pFontCm30);
    GrStringDraw(pContext, "Strings", -1, 125, 229, 0);

    //
    // Draw an image.
    //
    GrImageDraw(pContext, g_pucLogo, 190, 149);
}
Ejemplo n.º 11
0
//*****************************************************************************
//
// Handles paint requests for the primitives canvas widget.
//
//*****************************************************************************
void
OnPrimitivePaint(tWidget *pWidget, tContext *pContext)
{
    unsigned long ulIdx;
    tRectangle sRect;

    //
    // Draw a vertical sweep of lines from red to green.
    //
    for(ulIdx = 0; ulIdx <= 8; ulIdx++)
    {
        GrContextForegroundSet(pContext,
                               (((((10 - ulIdx) * 255) / 10) << ClrRedShift) |
                                (((ulIdx * 255) / 10) << ClrGreenShift)));
        GrLineDraw(pContext, 115, 120, 5, 120 - (11 * ulIdx));
    }

    //
    // Draw a horizontal sweep of lines from green to blue.
    //
    for(ulIdx = 1; ulIdx <= 10; ulIdx++)
    {
        GrContextForegroundSet(pContext,
                               (((((10 - ulIdx) * 255) / 10) <<
                                 ClrGreenShift) |
                                (((ulIdx * 255) / 10) << ClrBlueShift)));
        GrLineDraw(pContext, 115, 120, 5 + (ulIdx * 11), 29);
    }

    //
    // Draw a filled circle with an overlapping circle.
    //
    GrContextForegroundSet(pContext, ClrBrown);
    GrCircleFill(pContext, 185, 69, 40);
    GrContextForegroundSet(pContext, ClrSkyBlue);
    GrCircleDraw(pContext, 205, 99, 30);

    //
    // Draw a filled rectangle with an overlapping rectangle.
    //
    GrContextForegroundSet(pContext, ClrSlateGray);
    sRect.sXMin = 20;
    sRect.sYMin = 100;
    sRect.sXMax = 75;
    sRect.sYMax = 160;
    GrRectFill(pContext, &sRect);
    GrContextForegroundSet(pContext, ClrSlateBlue);
    sRect.sXMin += 40;
    sRect.sYMin += 40;
    sRect.sXMax += 30;
    sRect.sYMax += 28;
    GrRectDraw(pContext, &sRect);

    //
    // Draw a piece of text in fonts of increasing size.
    //
    GrContextForegroundSet(pContext, ClrSilver);
    GrContextFontSet(pContext, g_pFontFixed6x8);
    GrStringDraw(pContext, "Strings", -1, 125, 110, 0);
    GrContextFontSet(pContext, g_pFontCmss18b);
    GrStringDraw(pContext, "Strings", -1, 145, 124, 0);
    GrContextFontSet(pContext, g_pFontCmss22b);
    GrStringDraw(pContext, "Strings", -1, 165, 142, 0);

    //
    // Draw an image.
    //
    GrImageDraw(pContext, g_pucTISymbol_80x75, 240, 80);
}
Ejemplo n.º 12
0
static void OnDraw(tContext* pContext)
{
  // clear the region
  GrContextForegroundSet(pContext, ClrBlack);
  GrRectFill(pContext, &status_clip);

  GrContextForegroundSet(pContext, ClrWhite);
  GrLineDrawH(pContext, 0, pContext->pDisplay->usWidth, 16);

  GrContextFontSet(pContext, (tFont*)&g_sFontExIcon16);
  char icon;
  int x = CHARGE_X;

  switch(status & 0x03)
  {
    case BATTERY_EMPTY:
      icon = ICON_BATTERY_EMPTY;
      break;
    case BATTERY_LESS:
      icon = ICON_BATTERY_LESS;
      break;
    case BATTERY_MORE:
      icon = ICON_BATTERY_MORE;
      break;
    case BATTERY_FULL:
      icon = ICON_BATTERY_FULL;
      break;
    default:
      icon = 0;
  }

  if (status & BATTERY_CHARGING)
  {
    GrStringDraw(pContext, &icon, 1, 120, 0, 0);
    icon = ICON_CHARGING;
    GrStringDraw(pContext, &icon, 1, 137, 0, 0);
  }
  else
  {
    GrStringDraw(pContext, &icon, 1, 127, 0, 0);
  }

  x = 2;
  if (status & ALARM_STATUS)
  {
    icon = ICON_ALARM;
    GrStringDraw(pContext, &icon, 1, x, 0, 0);
    x += 15;
  }

  if (status & BLUETOOTH_STATUS)
  {
    icon = ICON_BT;
    GrStringDraw(pContext, &icon, 1, x, 0, 0);
  }

  if (status & MID_STATUS)
  {
    char icon = ICON_RUN;
    // draw activity
    GrContextFontSet(pContext, (tFont*)&g_sFontExIcon16);
    GrStringDraw(pContext, &icon, 1, 48, 0, 0);

    uint16_t part = window_readconfig()->goal_steps / 5;
    uint16_t steps = ped_get_steps();
    for(int i = 0; i < 5; i++)
    {
      if (i * part + part / 2 <= steps)
      {
        GrCircleFill(pContext, 68 + i*6, 7, 2);
      }
      else
      {
        GrCircleDraw(pContext, 68 + i*6, 7, 2);
      }
    }
  }
  else
  {
    uint8_t hour, minute;
    char buf[20];
    uint8_t ispm;
    rtc_readtime(&hour, &minute, NULL);

    adjustAMPM(hour, &hour, &ispm);

    sprintf(buf, "%02d:%02d %s", hour, minute, ispm?"PM":"AM");
#if defined(PRODUCT_W002) || defined(PRODUCT_W004)  
	GrContextFontSet(pContext, (tFont*)&g_sFontRonda12);
#else	    	
    GrContextFontSet(pContext, &g_sFontGothic14);
#endif    
    GrStringDrawCentered(pContext, buf, -1, pContext->pDisplay->usWidth/2, 8, 0);
  }
}
Ejemplo n.º 13
0
//*****************************************************************************
//
// A simple demonstration of the features of the TivaWare Graphics Library.
//
//*****************************************************************************
int
main(void)
{
  	clockInit();

    // Set up the LCD
  	Sharp96x96_initDisplay();

    GrContextInit(&g_sContext, &g_sharp96x96LCD);
  	GrContextFontSet(&g_sContext, &g_sFontFixed6x8);

  	int step = -1;
  	Sharp96x96_VCOM_count = 10;
  	while(1)
  	{
  		if(Sharp96x96_VCOM_count < 4)
  		{
  			continue;
  		}
  		Sharp96x96_VCOM_count = 0;
  		if(++step >= 5)
  		{
  			step = 0;
  		}

  		BlankScreen();
  	  	GrFlush(&g_sContext);
		switch(step) {
		case 0:
			// Intro Screen
			GrStringDrawCentered(&g_sContext,
								 "How to use",
								 AUTO_STRING_LENGTH,
								 48,
								 15,
								 TRANSPARENT_TEXT);
			GrStringDrawCentered(&g_sContext,
								 "the TivaWare",
								 AUTO_STRING_LENGTH,
								 48,
								 35,
								 TRANSPARENT_TEXT);
			GrStringDraw(&g_sContext,
						 "Graphics Library",
						 AUTO_STRING_LENGTH,
						 1,
						 51,
						 TRANSPARENT_TEXT);
			GrStringDrawCentered(&g_sContext,
								 "Primitives",
								 AUTO_STRING_LENGTH,
								 48,
								 75,
								 TRANSPARENT_TEXT);
			break;
		case 1:
			// Draw pixels and lines on the display
			GrStringDrawCentered(&g_sContext,
								 "Draw Pixels",
								 AUTO_STRING_LENGTH,
								 48,
								 5,
								 TRANSPARENT_TEXT);
			GrStringDrawCentered(&g_sContext,
								 "& Lines",
								 AUTO_STRING_LENGTH,
								 48,
								 15,
								 TRANSPARENT_TEXT);
			GrPixelDraw(&g_sContext, 30, 30);
			GrPixelDraw(&g_sContext, 30, 32);
			GrPixelDraw(&g_sContext, 32, 32);
			GrPixelDraw(&g_sContext, 32, 30);
			GrLineDraw(&g_sContext, 35, 35, 90, 90);
			GrLineDraw(&g_sContext, 5, 80, 80, 20);
			GrLineDraw(&g_sContext,
					   0,
					   GrContextDpyHeightGet(&g_sContext) - 1,
					   GrContextDpyWidthGet(&g_sContext) - 1,
					   GrContextDpyHeightGet(&g_sContext) - 1);
			break;
		case 2:
			// Draw circles on the display
			GrStringDraw(&g_sContext,
						 "Draw Circles",
						 AUTO_STRING_LENGTH,
						 10,
						 5,
						 TRANSPARENT_TEXT);
			GrCircleDraw(&g_sContext,
						 30,
						 70,
						 20);
			GrCircleFill(&g_sContext,
						 60,
						 50,
						 30);
			break;
		case 3:
			// Draw rectangles on the display
			GrStringDrawCentered(&g_sContext,
								 "Draw Rectangles",
								 AUTO_STRING_LENGTH,
								 48,
								 5,
								 TRANSPARENT_TEXT);
			GrRectDraw(&g_sContext, &myRectangle1);
			GrRectFill(&g_sContext, &myRectangle2);
			// Text below won't be visible on screen due to transparency
			// (foreground colors match)
			GrStringDrawCentered(&g_sContext,
								 "Normal Text",
								 AUTO_STRING_LENGTH,
								 50,
								 50,
								 TRANSPARENT_TEXT);
			// Text below draws foreground and background for opacity
			GrStringDrawCentered(&g_sContext,
								 "Opaque Text",
								 AUTO_STRING_LENGTH,
								 50,
								 65,
								 OPAQUE_TEXT);
			GrContextForegroundSet(&g_sContext, ClrWhite);
			GrContextBackgroundSet(&g_sContext, ClrBlack);
			GrStringDrawCentered(&g_sContext,
								 "Invert Text",
								 AUTO_STRING_LENGTH,
								 50,
								 80,
								 TRANSPARENT_TEXT);
			break;
		case 4:
			// Invert the foreground and background colors
			GrContextForegroundSet(&g_sContext, ClrBlack);
			GrContextBackgroundSet(&g_sContext, ClrWhite);
			GrRectFill(&g_sContext, &myRectangle3);
			GrContextForegroundSet(&g_sContext, ClrWhite);
			GrContextBackgroundSet(&g_sContext, ClrBlack);
			GrStringDrawCentered(&g_sContext,
								 "Invert Colors",
								 AUTO_STRING_LENGTH,
								 48,
								 5,
								 TRANSPARENT_TEXT);
			GrRectDraw(&g_sContext, &myRectangle1);
			GrRectFill(&g_sContext, &myRectangle2);
			// Text below won't be visible on screen due to
			// transparency (foreground colors match)
			GrStringDrawCentered(&g_sContext,
								 "Normal Text",
								 AUTO_STRING_LENGTH,
								 50,
								 50,
								 TRANSPARENT_TEXT);
			// Text below draws foreground and background for opacity
			GrStringDrawCentered(&g_sContext,
								 "Opaque Text",
								 AUTO_STRING_LENGTH,
								 50,
								 65,
								 OPAQUE_TEXT);
			// Text below draws with inverted foreground color to become visible
			GrContextForegroundSet(&g_sContext, ClrBlack);
			GrContextBackgroundSet(&g_sContext, ClrWhite);
			GrStringDrawCentered(&g_sContext,
								 "Invert Text",
								 AUTO_STRING_LENGTH,
								 50,
								 80,
								 TRANSPARENT_TEXT);
			break;
		default:
			break;
		}
		GrFlush(&g_sContext);
  	}
}
Ejemplo n.º 14
0
//*****************************************************************************
//
// A simple demonstration of the features of the TivaWare Graphics Library.
//
//*****************************************************************************
int
main(void)
{
    uint32_t ui32Idx;
    tRectangle sRect;

    //
    // Enable lazy stacking for interrupt handlers.  This allows floating-point
    // instructions to be used within interrupt handlers, but at the expense of
    // extra stack usage.
    //
    ROM_FPULazyStackingEnable();

    //
    // Set the clocking to run from the PLL.
    //
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
                       SYSCTL_OSC_MAIN);

    //
    // Initialize the display driver.
    //
    CFAL96x64x16Init();

    //
    // Initialize the graphics context.
    //
    GrContextInit(&g_sContext, &g_sCFAL96x64x16);

    //
    // Fill the top 12 rows of the screen with blue to create the banner.
    //
    sRect.i16XMin = 0;
    sRect.i16YMin = 0;
    sRect.i16XMax = GrContextDpyWidthGet(&g_sContext) - 1;
    sRect.i16YMax = 11;
    GrContextForegroundSet(&g_sContext, ClrDarkBlue);
    GrRectFill(&g_sContext, &sRect);

    //
    // Put a white box around the banner.
    //
    GrContextForegroundSet(&g_sContext, ClrWhite);
    GrRectDraw(&g_sContext, &sRect);

    //
    // Put the application name in the middle of the banner.
    //
    GrContextFontSet(&g_sContext, g_psFontFixed6x8);
    GrStringDrawCentered(&g_sContext, "grlib_demo", -1,
                         GrContextDpyWidthGet(&g_sContext) / 2, 5, 0);

    //
    // Draw a vertical sweep of lines from red to green.
    //
    for(ui32Idx = 0; ui32Idx <= 8; ui32Idx++)
    {
        GrContextForegroundSet(&g_sContext,
                               (((((10 - ui32Idx) * 255) / 8) << ClrRedShift) |
                                (((ui32Idx * 255) / 8) << ClrGreenShift)));
        GrLineDraw(&g_sContext, 60, 60, 0, 60 - (5 * ui32Idx));
    }

    //
    // Draw a horizontal sweep of lines from green to blue.
    //
    for(ui32Idx = 1; ui32Idx <= 11; ui32Idx++)
    {
        GrContextForegroundSet(&g_sContext,
                               (((((11 - ui32Idx) * 255) / 11) <<
                                 ClrGreenShift) |
                                (((ui32Idx * 255) / 11) << ClrBlueShift)));
        GrLineDraw(&g_sContext, 60, 60, (ui32Idx * 5), 20);
    }

    //
    // Draw a filled circle with an overlapping circle.
    //
    GrContextForegroundSet(&g_sContext, ClrBlue);
    GrCircleFill(&g_sContext, 80, 30, 15);
    GrContextForegroundSet(&g_sContext, ClrWhite);
    GrCircleDraw(&g_sContext, 80, 30, 15);

    //
    // Draw a filled rectangle with an overlapping rectangle.
    //
    GrContextForegroundSet(&g_sContext, ClrGray);
    sRect.i16XMin = 8;
    sRect.i16YMin = 45;
    sRect.i16XMax = 46;
    sRect.i16YMax = 51;
    GrRectFill(&g_sContext, &sRect);
    GrContextForegroundSet(&g_sContext, ClrWhite);
    sRect.i16XMin += 4;
    sRect.i16YMin += 4;
    sRect.i16XMax += 4;
    sRect.i16YMax += 4;
    GrRectDraw(&g_sContext, &sRect);

    //
    // Draw a piece of text in fonts of increasing size.
    //
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrStringDraw(&g_sContext, "Strings", -1, 6, 16, 0);
    GrContextForegroundSet(&g_sContext, ClrSilver);
    GrStringDraw(&g_sContext, "Strings", -1, 7, 17, 0);

    //
    // Draw an image.
    //
    GrTransparentImageDraw(&g_sContext, g_pui8Logo, 64, 34, ClrBlack);
#if 0
    GrImageDraw(&g_sContext, g_pui8Logo, 64, 34);
#endif

    //
    // Flush any cached drawing operations.
    //
    GrFlush(&g_sContext);

    //
    // Loop forever.
    //
    while(1)
    {
    }
}
Ejemplo n.º 15
0
void main(void){

    WDT_A_hold(WDT_A_BASE); // Stop WDT

    boardInit(); // Basic GPIO initialization

    clockInit(8000000); // Config clocks. MCLK=SMCLK=FLL=8MHz; ACLK=REFO=32kHz

    Sharp96x96_LCDInit(); // Set up the LCD


    GrContextInit(&g_sContext, &g_sharp96x96LCD);
  	GrContextForegroundSet(&g_sContext, ClrBlack);
  	GrContextBackgroundSet(&g_sContext, ClrWhite);
  	GrContextFontSet(&g_sContext, &g_sFontFixed6x8);
  	GrClearDisplay(&g_sContext);
  	GrFlush(&g_sContext);

	while(1){
		// Intro Screen
		GrClearDisplay(&g_sContext);
		GrStringDrawCentered(&g_sContext,
							 "How to use",
							 AUTO_STRING_LENGTH,
							 48,
							 15,
							 TRANSPARENT_TEXT);
		GrStringDrawCentered(&g_sContext,
							 "the MSP430",
							 AUTO_STRING_LENGTH,
							 48,
							 35,
							 TRANSPARENT_TEXT);
		GrStringDraw(&g_sContext,
					 "Graphics Library",
					 AUTO_STRING_LENGTH,
					 1,
					 51,
					 TRANSPARENT_TEXT);
		GrStringDrawCentered(&g_sContext,
							 "Primitives",
							 AUTO_STRING_LENGTH,
							 48,
							 75,
							 TRANSPARENT_TEXT);

		GrFlush(&g_sContext);
		Delay();
		GrClearDisplay(&g_sContext);

		// Draw pixels and lines on the display
		GrStringDrawCentered(&g_sContext,
							 "Draw Pixels",
							 AUTO_STRING_LENGTH,
							 48,
							 5,
							 TRANSPARENT_TEXT);
		GrStringDrawCentered(&g_sContext,
							 "& Lines",
							 AUTO_STRING_LENGTH,
							 48,
							 15,
							 TRANSPARENT_TEXT);
		GrPixelDraw(&g_sContext, 30, 30);
		GrPixelDraw(&g_sContext, 30, 32);
		GrPixelDraw(&g_sContext, 32, 32);
		GrPixelDraw(&g_sContext, 32, 30);
		GrLineDraw(&g_sContext, 35, 35, 90, 90);
		GrLineDraw(&g_sContext, 5, 80, 80, 20);
		GrLineDraw(&g_sContext,
				   0,
				   GrContextDpyHeightGet(&g_sContext) - 1,
				   GrContextDpyWidthGet(&g_sContext) - 1,
				   GrContextDpyHeightGet(&g_sContext) - 1);
		GrFlush(&g_sContext);
		Delay();
		GrClearDisplay(&g_sContext);

		// Draw circles on the display
		GrStringDraw(&g_sContext,
					 "Draw Circles",
					 AUTO_STRING_LENGTH,
					 10,
					 5,
					 TRANSPARENT_TEXT);
		GrCircleDraw(&g_sContext,
					 30,
					 70,
					 20);
		GrCircleFill(&g_sContext,
					 60,
					 50,
					 30);
		GrFlush(&g_sContext);
		Delay();
		GrClearDisplay(&g_sContext);

		// Draw rectangles on the display
		GrStringDrawCentered(&g_sContext,
							 "Draw Rectangles",
							 AUTO_STRING_LENGTH,
							 48,
							 5,
							 TRANSPARENT_TEXT);
		GrRectDraw(&g_sContext, &myRectangle1);
		GrRectFill(&g_sContext, &myRectangle2);
		// Text below won't be visible on screen due to transparency
		// (foreground colors match)
		GrStringDrawCentered(&g_sContext,
							 "Normal Text",
							 AUTO_STRING_LENGTH,
							 50,
							 50,
							 TRANSPARENT_TEXT);
		// Text below draws foreground and background for opacity
		GrStringDrawCentered(&g_sContext,
							 "Opaque Text",
							 AUTO_STRING_LENGTH,
							 50,
							 65,
							 OPAQUE_TEXT);
		GrContextForegroundSet(&g_sContext, ClrWhite);
		GrContextBackgroundSet(&g_sContext, ClrBlack);
		GrStringDrawCentered(&g_sContext,
							 "Invert Text",
							 AUTO_STRING_LENGTH,
							 50,
							 80,
							 TRANSPARENT_TEXT);
		GrFlush(&g_sContext);
		Delay();

		// Invert the foreground and background colors
		GrContextForegroundSet(&g_sContext, ClrBlack);
		GrContextBackgroundSet(&g_sContext, ClrWhite);
		GrRectFill(&g_sContext, &myRectangle3);
		GrContextForegroundSet(&g_sContext, ClrWhite);
		GrContextBackgroundSet(&g_sContext, ClrBlack);
		GrStringDrawCentered(&g_sContext,
							 "Invert Colors",
							 AUTO_STRING_LENGTH,
							 48,
							 5,
							 TRANSPARENT_TEXT);
		GrRectDraw(&g_sContext, &myRectangle1);
		GrRectFill(&g_sContext, &myRectangle2);
		// Text below won't be visible on screen due to
		// transparency (foreground colors match)
		GrStringDrawCentered(&g_sContext,
							 "Normal Text",
							 AUTO_STRING_LENGTH,
							 50,
							 50,
							 TRANSPARENT_TEXT);
		// Text below draws foreground and background for opacity
		GrStringDrawCentered(&g_sContext,
							 "Opaque Text",
							 AUTO_STRING_LENGTH,
							 50,
							 65,
							 OPAQUE_TEXT);
		// Text below draws with inverted foreground color to become visible
		GrContextForegroundSet(&g_sContext, ClrBlack);
		GrContextBackgroundSet(&g_sContext, ClrWhite);
		GrStringDrawCentered(&g_sContext,
							 "Invert Text",
							 AUTO_STRING_LENGTH,
							 50,
							 80,
							 TRANSPARENT_TEXT);
		GrFlush(&g_sContext);
		Delay();
		GrContextForegroundSet(&g_sContext, ClrBlack);
		GrContextBackgroundSet(&g_sContext, ClrWhite);
		GrClearDisplay(&g_sContext);

		// Draw Images on the display
		GrImageDraw(&g_sContext, &LPRocket_96x37_1BPP_UNCOMP, 3, 28);
		GrFlush(&g_sContext);
		Delay();
		GrClearDisplay(&g_sContext);
		GrImageDraw(&g_sContext, &TI_Logo_69x64_1BPP_UNCOMP, 15, 15);
		GrFlush(&g_sContext);
		Delay();
		// __bis_SR_register(LPM0_bits+GIE); //enter low power mode 0 with interrupts
	}
}
Ejemplo n.º 16
0
//*****************************************************************************
//
// Handles paint requests for the introduction canvas widget.
//
//*****************************************************************************
void
OnIntroPaint(tWidget *psWidget, tContext *psContext)
{
	tRectangle sRect;

	//
    // Display the introduction text in the canvas.
    //
    GrContextFontSet		( psContext, g_psFontCm16);
    GrContextForegroundSet	( psContext, ClrSilver);

    GrStringDraw(psContext, "OUTPUTS", 	-1, 125, LOC_Y_0UTPUTS-50, 0);
    GrStringDraw(psContext, "0", 		-1, LOC_X_0-4, LOC_Y_0UTPUTS-35, 0);
    GrStringDraw(psContext, "1", 		-1, LOC_X_1-4, LOC_Y_0UTPUTS-35, 0);
    GrStringDraw(psContext, "2", 		-1, LOC_X_2-4, LOC_Y_0UTPUTS-35, 0);
    GrStringDraw(psContext, "3", 		-1, LOC_X_3-4, LOC_Y_0UTPUTS-35, 0);
    GrStringDraw(psContext, "4", 		-1, LOC_X_4-4, LOC_Y_0UTPUTS-35, 0);
    GrStringDraw(psContext, "5", 		-1, LOC_X_5-4, LOC_Y_0UTPUTS-35, 0);
    GrStringDraw(psContext, "6", 		-1, LOC_X_6-4, LOC_Y_0UTPUTS-35, 0);
    GrStringDraw(psContext, "7", 		-1, LOC_X_7-4, LOC_Y_0UTPUTS-35, 0);

    WidgetAdd((tWidget *)&g_sBackground, (tWidget *)&g_sPushBtn_0);
    WidgetAdd((tWidget *)&g_sBackground, (tWidget *)&g_sPushBtn_1);
    WidgetAdd((tWidget *)&g_sBackground, (tWidget *)&g_sPushBtn_2);
    WidgetAdd((tWidget *)&g_sBackground, (tWidget *)&g_sPushBtn_3);
    WidgetAdd((tWidget *)&g_sBackground, (tWidget *)&g_sPushBtn_4);
    WidgetAdd((tWidget *)&g_sBackground, (tWidget *)&g_sPushBtn_5);
    WidgetAdd((tWidget *)&g_sBackground, (tWidget *)&g_sPushBtn_6);
    WidgetAdd((tWidget *)&g_sBackground, (tWidget *)&g_sPushBtn_7);


	GrStringDraw(psContext, "INPUTS", 	-1, 130, LOC_Y_INPUTS-50, 0);
    GrStringDraw(psContext, "0", 		-1, LOC_X_0-4, LOC_Y_INPUTS-35, 0);
    GrStringDraw(psContext, "1", 		-1, LOC_X_1-4, LOC_Y_INPUTS-35, 0);
    GrStringDraw(psContext, "2", 		-1, LOC_X_2-4, LOC_Y_INPUTS-35, 0);
    GrStringDraw(psContext, "3", 		-1, LOC_X_3-4, LOC_Y_INPUTS-35, 0);
    GrStringDraw(psContext, "4", 		-1, LOC_X_4-4, LOC_Y_INPUTS-35, 0);
    GrStringDraw(psContext, "5", 		-1, LOC_X_5-4, LOC_Y_INPUTS-35, 0);
    GrStringDraw(psContext, "6", 		-1, LOC_X_6-4, LOC_Y_INPUTS-35, 0);
    GrStringDraw(psContext, "7", 		-1, LOC_X_7-4, LOC_Y_INPUTS-35, 0);	
	
	//Draw all INPUT status circles
	//TBD Cant get a loop to work for this for some reason
	GrContextForegroundSet( psContext, ClrCyan);
    if ( input_status[0] == INPUT_STATUS_IS_ONE ){
    	GrContextForegroundSet( psContext, ClrRed);
    }	
	GrCircleFill( psContext, LOC_X_0, LOC_Y_INPUTS, 15);

	GrContextForegroundSet( psContext, ClrCyan);
    if ( input_status[1] == INPUT_STATUS_IS_ONE ){
    	GrContextForegroundSet( psContext, ClrRed);
    }	
	GrCircleFill( psContext, LOC_X_1, LOC_Y_INPUTS, 15);	

	GrContextForegroundSet( psContext, ClrCyan);
    if ( input_status[2] == INPUT_STATUS_IS_ONE ){
    	GrContextForegroundSet( psContext, ClrRed);
    }	
	GrCircleFill( psContext, LOC_X_2, LOC_Y_INPUTS, 15);

	GrContextForegroundSet( psContext, ClrCyan);
    if ( input_status[3] == INPUT_STATUS_IS_ONE ){
    	GrContextForegroundSet( psContext, ClrRed);
    }	
	GrCircleFill( psContext, LOC_X_3, LOC_Y_INPUTS, 15);	
	
	GrContextForegroundSet( psContext, ClrCyan);
    if ( input_status[4] == INPUT_STATUS_IS_ONE ){
    	GrContextForegroundSet( psContext, ClrRed);
    }	
	GrCircleFill( psContext, LOC_X_4, LOC_Y_INPUTS, 15);

	GrContextForegroundSet( psContext, ClrCyan);
    if ( input_status[5] == INPUT_STATUS_IS_ONE ){
    	GrContextForegroundSet( psContext, ClrRed);
    }	
	GrCircleFill( psContext, LOC_X_5, LOC_Y_INPUTS, 15);	

	GrContextForegroundSet( psContext, ClrCyan);
    if ( input_status[6] == INPUT_STATUS_IS_ONE ){
    	GrContextForegroundSet( psContext, ClrRed);
    }	
	GrCircleFill( psContext, LOC_X_6, LOC_Y_INPUTS, 15);

	GrContextForegroundSet( psContext, ClrCyan);
    if ( input_status[7] == INPUT_STATUS_IS_ONE ){
    	GrContextForegroundSet( psContext, ClrRed);
    }	
	GrCircleFill( psContext, LOC_X_7, LOC_Y_INPUTS, 15);


	GrContextForegroundSet	( psContext, ClrSilver);
	GrStringDraw(psContext, "ANALOG", 	-1, 130, LOC_Y_ANALOG-30, 0);

	//Draw two rectangles, one filled left to right up to the analog value then an empty one to contain the information
    GrContextForegroundSet(psContext, ClrMidnightBlue);
    sRect.i16XMin = 20;
	sRect.i16XMax = 300;
	sRect.i16YMin = LOC_Y_ANALOG-10;
	sRect.i16YMax = LOC_Y_ANALOG+8;
    GrRectFill(psContext, &sRect);

    GrContextForegroundSet(psContext, ClrCyan);
	sRect.i16XMin = 20;
    sRect.i16XMax = num_analog_pixels + sRect.i16XMin;
	sRect.i16YMin = LOC_Y_ANALOG-10;
	sRect.i16YMax = LOC_Y_ANALOG+8;	
    GrRectFill(psContext, &sRect);
	




}
Ejemplo n.º 17
0
//*****************************************************************************
//
//! Draws a line.
//!
//! \param pContext is a pointer to the drawing context to use.
//! \param lX1 is the X coordinate of the start of the line.
//! \param lY1 is the Y coordinate of the start of the line.
//! \param lX2 is the X coordinate of the end of the line.
//! \param lY2 is the Y coordinate of the end of the line.
//!
//! This function draws a line, utilizing GrLineDrawH() and GrLineDrawV() to
//! draw the line as efficiently as possible.  The line is clipped to the
//! clippping rectangle using the Cohen-Sutherland clipping algorithm, and then
//! scan converted using Bresenham's line drawing algorithm.
//!
//! \return None.
//
//*****************************************************************************
void
GrLineFill(const tContext *pContext, long lX1, long lY1, long lX2, long lY2, long width)
{
    long lError, lDeltaX, lDeltaY, lYStep, bSteep;
    long lWStart, lWEnd;

    lWEnd = width/2;
    lWStart = lWEnd - width;
    //
    // Check the arguments.
    //
    ASSERT(pContext);

    GrCircleFill(pContext, lX1, lY1, width/2);
    GrCircleFill(pContext, lX2, lY2, width/2);

    //
    // See if this is a vertical line.
    //
    if(lX1 == lX2)
    {
        //
        // It is more efficient to avoid Bresenham's algorithm when drawing a
        // vertical line, so use the vertical line routine to draw this line.
        //
        for(long i = lWStart; i <= lWEnd; i++)
            GrLineDrawV(pContext, lX1 + i, lY1, lY2);

        //
        // The line has ben drawn, so return.
        //
        return;
    }

    //
    // See if this is a horizontal line.
    //
    if(lY1 == lY2)
    {
        //
        // It is more efficient to avoid Bresenham's algorithm when drawing a
        // horizontal line, so use the horizontal line routien to draw this
        // line.
        //
        for(long i = lWStart; i <= lWEnd; i++)
            GrLineDrawH(pContext, lX1, lX2, lY1+i);

        //
        // The line has ben drawn, so return.
        //
        return;
    }

    //
    // Clip this line if necessary, and return without drawing anything if the
    // line does not cross the clipping region.
    //
    if(GrLineClip(pContext, &lX1, &lY1, &lX2, &lY2) == 0)
    {
        return;
    }

    //
    // Determine if the line is steep.  A steep line has more motion in the Y
    // direction than the X direction.
    //
    if(((lY2 > lY1) ? (lY2 - lY1) : (lY1 - lY2)) >
            ((lX2 > lX1) ? (lX2 - lX1) : (lX1 - lX2)))
    {
        bSteep = 1;
    }
    else
    {
        bSteep = 0;
    }

    //
    // If the line is steep, then swap the X and Y coordinates.
    //
    if(bSteep)
    {
        lError = lX1;
        lX1 = lY1;
        lY1 = lError;
        lError = lX2;
        lX2 = lY2;
        lY2 = lError;
    }

    //
    // If the starting X coordinate is larger than the ending X coordinate,
    // then swap the start and end coordinates.
    //
    if(lX1 > lX2)
    {
        lError = lX1;
        lX1 = lX2;
        lX2 = lError;
        lError = lY1;
        lY1 = lY2;
        lY2 = lError;
    }

    //
    // Compute the difference between the start and end coordinates in each
    // axis.
    //
    lDeltaX = lX2 - lX1;
    lDeltaY = (lY2 > lY1) ? (lY2 - lY1) : (lY1 - lY2);

    //
    // Initialize the error term to negative half the X delta.
    //
    lError = -lDeltaX / 2;

    //
    // Determine the direction to step in the Y axis when required.
    //
    if(lY1 < lY2)
    {
        lYStep = 1;
    }
    else
    {
        lYStep = -1;
    }

    //
    // Loop through all the points along the X axis of the line.
    //
    for(; lX1 <= lX2; lX1++)
    {
        //
        // See if this is a steep line.
        //
        if(bSteep)
        {
            //
            // Plot this point of the line, swapping the X and Y coordinates.
            //
            //DpyPixelDraw(pContext->pDisplay, lY1, lX1, pContext->ulForeground);
            GrLineDrawH(pContext, lY1 + lWStart, lY1 + lWEnd, lX1);
        }
        else
        {
            //
            // Plot this point of the line, using the coordinates as is.
            //
            //DpyPixelDraw(pContext->pDisplay, lX1, lY1, pContext->ulForeground);
            GrLineDrawV(pContext, lX1, lY1 + lWStart, lY1 + lWEnd);
        }

        //
        // Increment the error term by the Y delta.
        //
        lError += lDeltaY;

        //
        // See if the error term is now greater than zero.
        //
        if(lError > 0)
        {
            //
            // Take a step in the Y axis.
            //
            lY1 += lYStep;

            //
            // Decrement the error term by the X delta.
            //
            lError -= lDeltaX;
        }
    }
}
Ejemplo n.º 18
0
//*****************************************************************************
//
//! Draws a circular push button.
//!
//! \param pWidget is a pointer to the push button widget to be drawn.
//!
//! This function draws a circular push button on the display.  This is called
//! in response to a \b #WIDGET_MSG_PAINT message.
//!
//! \return None.
//
//*****************************************************************************
static void
CircularButtonPaint(tWidget *pWidget)
{
    const unsigned char *pucImage;
    tPushButtonWidget *pPush;
    tContext sCtx;
    long lX, lY, lR;

    //
    // Check the arguments.
    //
    ASSERT(pWidget);

    //
    // Convert the generic widget pointer into a push button widget pointer.
    //
    pPush = (tPushButtonWidget *)pWidget;

    //
    // Initialize a drawing context.
    //
    GrContextInit(&sCtx, pWidget->pDisplay);

    //
    // Initialize the clipping region based on the extents of this circular
    // push button.
    //
    GrContextClipRegionSet(&sCtx, &(pWidget->sPosition));

    //
    // Get the radius of the circular push button, along with the X and Y
    // coordinates for its center.
    //
    lR = (pWidget->sPosition.sXMax - pWidget->sPosition.sXMin + 1) / 2;
    lX = pWidget->sPosition.sXMin + lR;
    lY = pWidget->sPosition.sYMin + lR;

    //
    // See if the push button fill style is selected.
    //
    if(pPush->ulStyle & PB_STYLE_FILL)
    {
        //
        // Fill the push button with the fill color.
        //
        GrContextForegroundSet(&sCtx, ((pPush->ulStyle & PB_STYLE_PRESSED) ?
                                       pPush->ulPressFillColor :
                                       pPush->ulFillColor));
        GrCircleFill(&sCtx, lX, lY, lR);
    }

    //
    // See if the push button outline style is selected.
    //
    if(pPush->ulStyle & PB_STYLE_OUTLINE)
    {
        //
        // Outline the push button with the outline color.
        //
        GrContextForegroundSet(&sCtx, pPush->ulOutlineColor);
        GrCircleDraw(&sCtx, lX, lY, lR);
    }

    //
    // See if the push button text or image style is selected.
    //
    if(pPush->ulStyle & (PB_STYLE_TEXT | PB_STYLE_IMG))
    {
        //
        // If the push button outline style is selected then shrink the
        // clipping region by one pixel on each side so that the outline is not
        // overwritten by the text or image.
        //
        if(pPush->ulStyle & PB_STYLE_OUTLINE)
        {
            sCtx.sClipRegion.sXMin++;
            sCtx.sClipRegion.sYMin++;
            sCtx.sClipRegion.sXMax--;
            sCtx.sClipRegion.sYMax--;
        }

        //
        // See if the push button image style is selected.
        //
        if(pPush->ulStyle & PB_STYLE_IMG)
        {
            //
            // Set the foreground and background colors to use for 1 BPP
            // images.
            //
            GrContextForegroundSet(&sCtx, pPush->ulTextColor);
            GrContextBackgroundSet(&sCtx,
                                   ((pPush->ulStyle & PB_STYLE_PRESSED) ?
                                    pPush->ulPressFillColor :
                                    pPush->ulFillColor));

            //
            // Get the image to be drawn.
            //
            pucImage = (((pPush->ulStyle & PB_STYLE_PRESSED) &&
                         pPush->pucPressImage) ?
                        pPush->pucPressImage : pPush->pucImage);

            //
            // Draw the image centered in the push button.
            //
            GrImageDraw(&sCtx, pucImage, lX - (GrImageWidthGet(pucImage) / 2),
                        lY - (GrImageHeightGet(pucImage) / 2));
        }

        //
        // See if the push button text style is selected.
        //
        if(pPush->ulStyle & PB_STYLE_TEXT)
        {
            //
            // Draw the text centered in the middle of the push button.
            //
            GrContextFontSet(&sCtx, pPush->pFont);
            GrContextForegroundSet(&sCtx, pPush->ulTextColor);
            GrContextBackgroundSet(&sCtx,
                                   ((pPush->ulStyle & PB_STYLE_PRESSED) ?
                                    pPush->ulPressFillColor :
                                    pPush->ulFillColor));
            GrStringDrawCentered(&sCtx, pPush->pcText, -1, lX, lY,
                                 pPush->ulStyle & PB_STYLE_TEXT_OPAQUE);
        }
    }
}