示例#1
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);
  }
}
示例#2
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);
}
示例#3
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);
        }
    }
}
示例#4
0
文件: main.c 项目: 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);

}
示例#5
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);
}
int
main(void)
{
    tContext sContext;
    tRectangle sRect;

    //
    // The FPU should be enabled because some compilers will use floating-
    // point registers, even for non-floating-point code.  If the FPU is not
    // enabled this will cause a fault.  This also ensures that floating-
    // point operations could be added to this application and would work
    // correctly and use the hardware floating-point unit.  Finally, lazy
    // stacking is enabled for interrupt handlers.  This allows floating-
    // point instructions to be used within interrupt handlers, but at the
    // expense of extra stack usage.
    //
    FPUEnable();
    FPULazyStackingEnable();

    //
    // Set the clock to 40Mhz derived from the PLL and the external oscillator
    //
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
                       SYSCTL_OSC_MAIN);

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

    //
    // Initialize the graphics context.
    //
    GrContextInit(&sContext, &g_sAdafruit320x240x16_ILI9325);

    //
    // Configure and enable uDMA
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
    SysCtlDelay(10);
    uDMAControlBaseSet(&sDMAControlTable[0]);
    uDMAEnable();

    //
    // Initialize the touch screen driver and have it route its messages to the
    // widget tree.
    //
    TouchScreenInit();

    //
    // Paint touch calibration targets and collect calibration data
    //
    GrContextForegroundSet(&sContext, ClrWhite);
    GrContextBackgroundSet(&sContext, ClrBlack);
    GrContextFontSet(&sContext, &g_sFontCm20);
    GrStringDraw(&sContext, "Touch center of circles to calibrate", -1, 0, 0, 1);
    GrCircleDraw(&sContext, 32, 24, 10);
    GrFlush(&sContext);
    TouchScreenCalibrationPoint(32, 24, 0);

    GrCircleDraw(&sContext, 280, 200, 10);
    GrFlush(&sContext);
    TouchScreenCalibrationPoint(280, 200, 1);

    GrCircleDraw(&sContext, 200, 40, 10);
    GrFlush(&sContext);
    TouchScreenCalibrationPoint(200, 40, 2);

    //
    // Calculate and set calibration matrix
    //
    long* plCalibrationMatrix = TouchScreenCalibrate();
    
    //
    // Write out calibration data if successful
    //
    if(plCalibrationMatrix)
    {
    	char pcStringBuf[20];
    	usprintf(pcStringBuf, "A %d", plCalibrationMatrix[0]);
    	GrStringDraw(&sContext, pcStringBuf, -1, 0, 20, 1);
    	usprintf(pcStringBuf, "B %d", plCalibrationMatrix[1]);
    	GrStringDraw(&sContext, pcStringBuf, -1, 0, 40, 1);
    	usprintf(pcStringBuf, "C %d", plCalibrationMatrix[2]);
    	GrStringDraw(&sContext, pcStringBuf, -1, 0, 60, 1);
    	usprintf(pcStringBuf, "D %d", plCalibrationMatrix[3]);
    	GrStringDraw(&sContext, pcStringBuf, -1, 0, 80, 1);
    	usprintf(pcStringBuf, "E %d", plCalibrationMatrix[4]);
    	GrStringDraw(&sContext, pcStringBuf, -1, 0, 100, 1);
    	usprintf(pcStringBuf, "F %d", plCalibrationMatrix[5]);
    	GrStringDraw(&sContext, pcStringBuf, -1, 0, 120, 1);
    	usprintf(pcStringBuf, "Div %d", plCalibrationMatrix[6]);
    	GrStringDraw(&sContext, pcStringBuf, -1, 0, 140, 1);
    	TouchScreenCalibrationPoint(0,0,0);	// wait for dummy touch
    }

    //
    // Enable touch screen event handler for grlib widgets
    //
    TouchScreenCallbackSet(WidgetPointerMessage);

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

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

    //
    // Put the application name in the middle of the banner.
    //
    GrContextFontSet(&sContext, &g_sFontCm20);
    GrStringDrawCentered(&sContext, "grlib demo", -1,
                         GrContextDpyWidthGet(&sContext) / 2, 8, 0);

    //
    // Add the title block and the previous and next buttons to the widget
    // tree.
    //
    WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sPrevious);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sTitle);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sNext);

    //
    // Add the first panel to the widget tree.
    //
    g_ulPanel = 0;
    WidgetAdd(WIDGET_ROOT, (tWidget *)g_psPanels);
    CanvasTextSet(&g_sTitle, g_pcPanelNames[0]);

    //
    // Issue the initial paint request to the widgets.
    //
    WidgetPaint(WIDGET_ROOT);

    //
    // Loop forever handling widget messages.
    //
    while(1)
    {
        //
        // Process any messages in the widget message queue.
        //
        WidgetMessageQueueProcess();
    }
}
示例#7
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)
    {
    }
}
//*****************************************************************************
//
// 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);
}
示例#9
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);
  }
}
示例#10
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);
  	}
}
示例#11
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)
    {
    }
}
示例#12
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
	}
}
示例#13
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);
        }
    }
}
//*****************************************************************************
//
// 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);
}
示例#15
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)
    {
    }

}