Ejemplo n.º 1
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.º 2
0
//*****************************************************************************
//
// Draw the pop up buttons on the screen.
//
//*****************************************************************************
static void
DrawButtons(int32_t i32Offset, bool bClear)
{
    static const tRectangle sRectTop = {
        140,
        BG_MIN_Y,
        171,
        BG_MIN_Y + 10,
    };
    static const tRectangle sRectRight = {
        BG_MAX_X - 11,
        BG_MIN_Y - 20 + ((BG_MAX_Y - BG_MIN_Y) / 2),
        BG_MAX_X,
        BG_MIN_Y - 20 + ((BG_MAX_Y - BG_MIN_Y) / 2) + 40,
    };
    static const tRectangle sRectLeft = {
        BG_MIN_X,
        BG_MIN_Y - 20 + ((BG_MAX_Y - BG_MIN_Y) / 2),
        BG_MIN_X + 10,
        BG_MIN_Y - 20 + ((BG_MAX_Y - BG_MIN_Y) / 2) + 40,
    };

    //
    // Only draw if they are enabled.
    //
    if(g_sButtons.bEnabled == false) {
        return;
    }

    //
    // Draw the three pop up buttons.
    //
    if(g_i32ScreenIdx == SCREEN_SUMMARY || g_i32ScreenIdx == SCREEN_DETAILS) {
        GrContextForegroundSet(&g_sContext, ClrBlack);
        GrContextBackgroundSet(&g_sContext, ClrGray);

        GrRectFill(&g_sContext, &sRectRight);
        GrRectFill(&g_sContext, &sRectLeft);

        if(bClear == false) {
            GrLineDrawH(&g_sContext, 140, 171, BG_MIN_Y + 10 + i32Offset);

            GrImageDraw(&g_sContext, g_pui8DownTabImage, 140,
                        BG_MIN_Y + i32Offset);

            GrTransparentImageDraw(&g_sContext, g_pui8RightImage,
                                   BG_MAX_X - 10 + i32Offset,
                                   BG_MIN_Y - 20 + ((BG_MAX_Y - BG_MIN_Y) / 2),
                                   1);
            GrTransparentImageDraw(&g_sContext, g_pui8LeftImage,
                                   BG_MIN_X - i32Offset,
                                   BG_MIN_Y - 20 + ((BG_MAX_Y - BG_MIN_Y) / 2),
                                   1);
        } else {
            GrRectFill(&g_sContext, &sRectTop);
        }
    } else if(g_i32ScreenIdx == SCREEN_TI) {
        GrContextForegroundSet(&g_sContext, ClrGray);
        GrContextBackgroundSet(&g_sContext, ClrWhite);
        if(bClear == false) {
            GrLineDrawH(&g_sContext, 140, 171, BG_MAX_Y - 11 - i32Offset);
            GrImageDraw(&g_sContext, g_pui8UpTabImage, 140,
                        BG_MAX_Y - 10 - i32Offset);
        }
    }
}