Exemplo n.º 1
0
//****************************************************************************
//
// Handles updating the Scroll Lock status when in keyboard mode.
//
//****************************************************************************
void
UIUpdateScrollLock(void)
{
    if(g_sUIState.ui32Indicators & UI_STATUS_KEY_SCROLL)
    {
        PushButtonTextSet(&g_sStatus2, "SCROLL");
        PushButtonTextColorSet(&g_sStatus2, ClrRed);
    }
    else
    {
        PushButtonTextSet(&g_sStatus2, "scroll");
        PushButtonTextColorSet(&g_sStatus2, ClrBlack);
    }

    WidgetPaint((tWidget *)&g_sStatus2);
}
Exemplo n.º 2
0
//****************************************************************************
//
// Handles updating the Num Lock status when in keyboard mode.
//
//****************************************************************************
void
UIUpdateNumLock(void)
{
    if(g_sUIState.ui32Indicators & UI_STATUS_KEY_NUM)
    {
        PushButtonTextSet(&g_sStatus3, "NUM");
        PushButtonTextColorSet(&g_sStatus3, ClrRed);
    }
    else
    {
        PushButtonTextSet(&g_sStatus3, "num");
        PushButtonTextColorSet(&g_sStatus3, ClrBlack);
    }

    WidgetPaint((tWidget *)&g_sStatus3);
}
Exemplo n.º 3
0
//****************************************************************************
//
// Handles updating the Caps Lock status when in keyboard mode.
//
//****************************************************************************
void
UIUpdateCapsLock(void)
{
    if(g_sUIState.ui32Indicators & UI_STATUS_KEY_CAPS)
    {
        PushButtonTextSet(&g_sStatus1, "CAPS");
        PushButtonTextColorSet(&g_sStatus1, ClrRed);
    }
    else
    {
        PushButtonTextSet(&g_sStatus1, "caps");
        PushButtonTextColorSet(&g_sStatus1, ClrBlack);
    }

    WidgetPaint((tWidget *)&g_sStatus1);
}
Exemplo n.º 4
0
void OnButtonPress_4(tWidget *psWidget)
{
    g_bHelloVisible_4 = !g_bHelloVisible_4;

    if(g_bHelloVisible_4)
    {
        PushButtonTextSet(&g_sPushBtn_4, "1");
        WidgetPaint(WIDGET_ROOT);		
		qut_set_gpio( 4, 1 );
    }
    else
    {
		PushButtonTextSet(&g_sPushBtn_4, "0");
        WidgetPaint(WIDGET_ROOT);		
		qut_set_gpio( 4, 0 );
    }
}
Exemplo n.º 5
0
//*****************************************************************************
//
// Function call when OUTPUT buttons are pressed
//
//*****************************************************************************
void OnButtonPress_0(tWidget *psWidget)
{
    g_bHelloVisible_0 = !g_bHelloVisible_0;

    if(g_bHelloVisible_0)
    {
        PushButtonTextSet(&g_sPushBtn_0, "1");
        WidgetPaint(WIDGET_ROOT);		
		qut_set_gpio( 0, 1 );
    }
    else
    {
		PushButtonTextSet(&g_sPushBtn_0, "0");
        WidgetPaint(WIDGET_ROOT);		
		qut_set_gpio( 0, 0 );
    }
}
Exemplo n.º 6
0
void OnButtonPress_7 (tWidget *psWidget)
{
    g_bHelloVisible_7 = !g_bHelloVisible_7;

    if(g_bHelloVisible_7)
    {
        PushButtonTextSet(&g_sPushBtn_7, "1");

        WidgetPaint(WIDGET_ROOT);
		
		qut_set_gpio( 7, 1 );
    }
    else
    {
        PushButtonTextSet(&g_sPushBtn_7, "0");

        WidgetPaint(WIDGET_ROOT);
		
		qut_set_gpio( 7, 0 );
    }
}
Exemplo n.º 7
0
void OnButtonPress_5 (tWidget *psWidget)
{
    g_bHelloVisible_5 = !g_bHelloVisible_5;

    if(g_bHelloVisible_5)
    {
        PushButtonTextSet(&g_sPushBtn_5, "1");

        WidgetPaint(WIDGET_ROOT);
		
		qut_set_gpio( 5, 1 );
    }
    else
    {
        PushButtonTextSet(&g_sPushBtn_5, "0");

        WidgetPaint(WIDGET_ROOT);
		
		qut_set_gpio( 5, 0 );
    }
}
Exemplo n.º 8
0
void OnButtonPress_3 (tWidget *psWidget)
{
    g_bHelloVisible_3 = !g_bHelloVisible_3;

    if(g_bHelloVisible_3)
    {
        PushButtonTextSet(&g_sPushBtn_3, "1");

        WidgetPaint(WIDGET_ROOT);
		
		qut_set_gpio( 3, 1 );
    }
    else
    {
        PushButtonTextSet(&g_sPushBtn_3, "0");

        WidgetPaint(WIDGET_ROOT);
		
		qut_set_gpio( 3, 0 );
    }
}
Exemplo n.º 9
0
void OnButtonPress_2 (tWidget *psWidget)
{
    g_bHelloVisible_2 = !g_bHelloVisible_2;

    if(g_bHelloVisible_2)
    {
        PushButtonTextSet(&g_sPushBtn_2, "1");

        WidgetPaint(WIDGET_ROOT);
		
		qut_set_gpio( 2, 1 );
    }
    else
    {
        PushButtonTextSet(&g_sPushBtn_2, "0");

        WidgetPaint(WIDGET_ROOT);
		
		qut_set_gpio( 2, 0 );
    }
}
Exemplo n.º 10
0
void OnButtonPress_1 (tWidget *psWidget)
{
    g_bHelloVisible_1 = !g_bHelloVisible_1;

    if(g_bHelloVisible_1)
    {
        PushButtonTextSet(&g_sPushBtn_1, "1");

        WidgetPaint(WIDGET_ROOT);
		
		qut_set_gpio( 1, 1 );
    }
    else
    {
        PushButtonTextSet(&g_sPushBtn_1, "0");

        WidgetPaint(WIDGET_ROOT);
		
		qut_set_gpio( 1, 0 );
    }
}
Exemplo n.º 11
0
void OnButtonPress_6 (tWidget *psWidget)
{
    g_bHelloVisible_6 = !g_bHelloVisible_6;

    if(g_bHelloVisible_6)
    {
        PushButtonTextSet(&g_sPushBtn_6, "1");

        WidgetPaint(WIDGET_ROOT);
		
		qut_set_gpio( 6, 1 );
    }
    else
    {
        PushButtonTextSet(&g_sPushBtn_6, "0");

        WidgetPaint(WIDGET_ROOT);
		
		qut_set_gpio( 6, 0 );
    }
}
Exemplo n.º 12
0
//*****************************************************************************
//
// Show the graphics demo
//
//*****************************************************************************
void
GraphicsDemoShow(void)
{
    //
    // Remove the keypad widget tree completely.
    //
    WidgetRemove((tWidget *)&g_sBlackBackground);

    //
    // Remember that we are showing the graphics demo.
    //
    g_ulMode = MODE_DEMO;

    //
    // Set the previous and next button text correctly for the first screen.
    //
    PushButtonTextSet(&g_sNext, "+");
    PushButtonTextSet(&g_sPrevious, "X");

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

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

    //
    // Issue the initial paint request to the widgets.
    //
    WidgetPaint(WIDGET_ROOT);
}
Exemplo n.º 13
0
//*****************************************************************************
//
// Handles press notifications for the push button widgets.
//
//*****************************************************************************
void
OnFirmwareUpdate(tWidget *pWidget)
{
    //
    // Play the key click sound.
    //
    SoundPlay(g_pusKeyClick, sizeof(g_pusKeyClick) / 2);

    //
    // Change the button text to show that the update is starting
    //
    PushButtonTextSet(&g_sFirmwareUpdateBtn, "Updating...");
    WidgetPaint((tWidget *)&g_sFirmwareUpdateBtn);

    //
    // Trigger a software update
    //
    g_bFirmwareUpdate = true;
}
//*****************************************************************************
//
// Handler for the "Sound Alarm" button.
//
//*****************************************************************************
void
OnAlarmButtonPress(tWidget *pWidget)
{
    //
    // Tell the user we're switching into "LinkTo" mode.
    //
    UpdateStatus(true, "Alarm raised!");

    //
    // Set the button background to red and change the text.
    //
    PushButtonFillColorSet((tPushButtonWidget *)pWidget, BRIGHT_RED);
    PushButtonTextSet((tPushButtonWidget *)pWidget, "ALARM!");
    WidgetPaint(pWidget);

    //
    // Set a flag indicating that the alarm has been raised.
    //
    g_bAlarmRaised = true;
}
Exemplo n.º 15
0
//****************************************************************************
//
// Handles updates to the current status.
//
//****************************************************************************
void
UIUpdateStatus(uint32_t ui32Indicators)
{
    if(g_eState == UI_NOT_CONNECTED)
    {
        PushButtonTextSet(&g_sToggle, "---");

        PushButtonTextColorSet(&g_sStatus1, ClrBlack);
        PushButtonTextSet(&g_sStatus1, "---");

        PushButtonTextColorSet(&g_sStatus2, ClrBlack);
        PushButtonTextSet(&g_sStatus2, "---");

        PushButtonTextColorSet(&g_sStatus3, ClrBlack);
        PushButtonTextSet(&g_sStatus3, "---");

        if(ui32Indicators & UI_STATUS_KEYBOARD)
        {
            WidgetRemove((tWidget *)&g_sKeyboard);
        }

        WidgetPaint((tWidget *)&g_sBackground);

        return;
    }

    //
    // See if there is a change to update.
    //
    if(ui32Indicators == g_sUIState.ui32Indicators)
    {
        return;
    }

    //
    // Was there a global change in the keyboard/mouse state.
    //
    if(((ui32Indicators ^ g_sUIState.ui32Indicators) & UI_STATUS_KEYBOARD) ||
       (ui32Indicators & UI_STATUS_UPDATE))
    {
        //
        // Update to keyboard mode or mouse mode for the UI.
        //
        if(ui32Indicators & UI_STATUS_KEYBOARD)
        {
            PushButtonTextSet(&g_sToggle, "Keyboard");
            WidgetPaint((tWidget *)&g_sToggle);
            UIUpdateCapsLock();
            UIUpdateScrollLock();
            UIUpdateNumLock();

            WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sKeyboard);

            WidgetPaint((tWidget *)&g_sKeyboard);
        }
        else
        {
            //
            // Switch back to a mouse UI.
            //
            PushButtonTextSet(&g_sToggle, "Mouse");

            PushButtonTextColorSet(&g_sStatus1, ClrBlack);
            PushButtonTextSet(&g_sStatus1, "Left");

            PushButtonTextColorSet(&g_sStatus2, ClrBlack);
            PushButtonTextSet(&g_sStatus2, "Middle");

            PushButtonTextColorSet(&g_sStatus3, ClrBlack);
            PushButtonTextSet(&g_sStatus3, "Right");

            WidgetRemove((tWidget *)&g_sKeyboard);

            WidgetPaint((tWidget *)&g_sBackground);
        }
    }

    //
    // Update the new state of the indicators.
    //
    g_sUIState.ui32Indicators = ui32Indicators & ~UI_STATUS_UPDATE;
}
Exemplo n.º 16
0
//*****************************************************************************
//
// A simple demonstration of the features of the Stellaris Graphics Library.
//
//*****************************************************************************
int
main(void)
{
    tContext sContext;
    tRectangle sRect;

    //
    // If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
    // a workaround to allow the PLL to operate reliably.
    //
    if(REVISION_IS_A2)
    {
        SysCtlLDOSet(SYSCTL_LDO_2_75V);
    }

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

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

    //
    // Turn on the backlight.
    //
    Kitronix320x240x16_SSD2119BacklightOn(255);

    //
    // Set graphics library text rendering defaults.
    //
    GrLibInit(&GRLIB_INIT_STRUCT);

    //
    // Set the string table and the default language.
    //
    GrStringTableSet(STRING_TABLE);

    //
    // Set the default language.
    //
    ChangeLanguage(GrLangEnUS);

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

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

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

    //
    // Load the static strings from the string table.  These strings are
    // independent of the language in use but we store them in the string
    // table nonetheless since (a) we may be using codepage remapping in
    // which case it would be difficult to hardcode them into the app source
    // anyway (ASCII or ISO8859-1 text would not render properly with the
    // remapped custom font) and (b) even if we're not using codepage remapping,
    // we may have generated a custom font from the string table output and
    // we want to make sure that all glyphs required by the application are
    // present in that font.  If we hardcode some text in the application
    // source and don't put it in the string table, we run the risk of having
    // characters missing in the font.
    //
    GrStringGet(STR_ENGLISH, g_pcEnglish, MAX_LANGUAGE_NAME_LEN);
    GrStringGet(STR_DEUTSCH, g_pcDeutsch, MAX_LANGUAGE_NAME_LEN);
    GrStringGet(STR_ESPANOL, g_pcEspanol, MAX_LANGUAGE_NAME_LEN);
    GrStringGet(STR_ITALIANO, g_pcItaliano, MAX_LANGUAGE_NAME_LEN);
    GrStringGet(STR_CHINESE, g_pcChinese, MAX_LANGUAGE_NAME_LEN);
    GrStringGet(STR_KOREAN, g_pcKorean, MAX_LANGUAGE_NAME_LEN);
    GrStringGet(STR_JAPANESE, g_pcJapanese, MAX_LANGUAGE_NAME_LEN);
    GrStringGet(STR_PLUS, g_pcPlus, 2);
    GrStringGet(STR_MINUS, g_pcMinus, 2);

    //
    // Put the application name in the middle of the banner.
    //
    GrStringGet(STR_APPNAME, g_pcBuffer, SCOMP_MAX_STRLEN);
    GrContextFontSet(&sContext, FONT_20PT);
    GrStringDrawCentered(&sContext, g_pcBuffer, -1,
                         GrContextDpyWidthGet(&sContext) / 2, 10, 0);

    //
    // Initialize the sound driver.
    //
    SoundInit();

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

    //
    // 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);

    //
    // Set the string for the title.
    //
    CanvasTextSet(&g_sTitle, g_pcTitle);

    //
    // Initialize the pointer to the button text.
    //
    PushButtonTextSet(&g_sFirmwareUpdateBtn, g_pcUpdateButton);

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

    //
    // Loop forever unless we receive a signal that a firmware update has been
    // requested.
    //
    while(!g_bFirmwareUpdate)
    {
        //
        // Process any messages in the widget message queue.
        //
        WidgetMessageQueueProcess();
    }

    //
    // If we drop out, a firmware update request has been made.  We call
    // WidgetMessageQueueProcess once more to ensure that any final messages
    // are processed then jump into the bootloader.
    //
    WidgetMessageQueueProcess();

    //
    // Wait a while for the last keyboard click sound to finish.  This is about
    // 500mS since the delay loop is 3 cycles long.
    //
    SysCtlDelay(SysCtlClockGet() / 6);

    //
    // Pass control to the bootloader.
    //
    JumpToBootLoader();

    //
    // The boot loader should take control, so this should never be reached.
    // Just in case, loop forever.
    //
    while(1)
    {
    }
}
Exemplo n.º 17
0
//*****************************************************************************
//
// Handles presses of the next panel button.
//
//*****************************************************************************
void
OnNext(tWidget *pWidget)
{
    //
    // If this button is pressed when the last panel is displayed, we exit
    // back to keypad display.
    //
    if(g_ulPanel == (NUM_PANELS - 1))
    {
        //
        // Play the key click sound.
        //
        SoundPlay(g_pusKeyClick, sizeof(g_pusKeyClick) / 2);

        //
        // Fix up the widget tree to move us back to keypad mode.
        //
        GraphicsDemoHide();
        return;
    }

    //
    // Remove the current panel.
    //
    WidgetRemove((tWidget *)(g_psPanels + g_ulPanel));

    //
    // Increment the panel index.
    //
    g_ulPanel++;

    //
    // Add and draw the new panel.
    //
    WidgetAdd((tWidget *)&g_sDemoBackground,
              (tWidget *)(g_psPanels + g_ulPanel));
    WidgetPaint((tWidget *)(g_psPanels + g_ulPanel));

    //
    // Set the title of this panel.
    //
    CanvasTextSet(&g_sTitle, g_pcPanelNames[g_ulPanel]);
    WidgetPaint((tWidget *)&g_sTitle);

    //
    // Set the button text to read "X" (exit) if this is the last panel,
    // otherwise revert to the usual "+".
    //
    PushButtonTextSet(&g_sNext, (g_ulPanel == (NUM_PANELS - 1)) ? "X" : "+");
    WidgetPaint((tWidget *)&g_sNext);

    //
    // Set the "previous" button text to read "X" if this is the first panel,
    // otherwise revert to the usual "-".
    //
    PushButtonTextSet(&g_sPrevious, (g_ulPanel == 0) ? "X" : "-");
    WidgetPaint((tWidget *)&g_sPrevious);

    //
    // Play the key click sound.
    //
    SoundPlay(g_pusKeyClick, sizeof(g_pusKeyClick) / 2);
}
Exemplo n.º 18
0
//*****************************************************************************
//
// Handles presses of the next panel button.
//
//*****************************************************************************
void
OnNext(tWidget *pWidget)
{
    //
    // Play the key click sound.
    //
    SoundPlay(g_pusKeyClick, g_ulKeyClickLen);

    //
    // If we are on the last panel, return to the main application menu.
    //
    if(g_ulPanel == (NUM_PANELS - 1))
    {
        ShowUIScreen(HOME_SCREEN);
        return;
    }

    //
    // Remove the current panel.
    //
    WidgetRemove((tWidget *)(g_psPanels + g_ulPanel));

    //
    // Increment the panel index.
    //
    g_ulPanel++;

    //
    // Add and draw the new panel.
    //
    WidgetAdd((tWidget *)&g_sDemoScreen, (tWidget *)(g_psPanels + g_ulPanel));
    WidgetPaint((tWidget *)(g_psPanels + g_ulPanel));

    //
    // Set the title of this panel.
    //
    CanvasTextSet(&g_sTitle, g_pcPanelNames[g_ulPanel]);
    WidgetPaint((tWidget *)&g_sTitle);

    //
    // See if the previous panel was the first panel.
    //
    if(g_ulPanel == 1)
    {
        //
        // Replace the original text on the "Previous" button.
        //
        PushButtonTextSet(&g_sPrevious, "-");
        WidgetPaint((tWidget *)&g_sPrevious);
    }

    //
    // See if this is the last panel.
    //
    if(g_ulPanel == (NUM_PANELS - 1))
    {
        //
        // Replace the text on the "Next" button to read "X".
        //
        PushButtonTextSet(&g_sNext, "X");
        WidgetPaint((tWidget *)&g_sNext);
    }
}