//***************************************************************************** // // A simple demonstration of the features of the TivaWare Graphics Library. // //***************************************************************************** int main(void) { tContext sContext; uint32_t ui32SysClock; // // Run from the PLL at 120 MHz. // ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); // // Configure the device pins. // PinoutSet(); // // Initialize the display driver. // Kentec320x240x16_SSD2119Init(ui32SysClock); // // 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_sKentec320x240x16_SSD2119); // // Draw the application frame. // FrameDraw(&sContext, "lang-demo"); // // 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); // // Initialize the touch screen driver and have it route its messages to the // widget tree. // TouchScreenInit(ui32SysClock); 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_ui32Panel = 0; WidgetAdd(WIDGET_ROOT, (tWidget *)g_psPanels); // // Set the string for the title. // CanvasTextSet(&g_sTitle, g_pcTitle); // // Issue the initial paint request to the widgets. // WidgetPaint(WIDGET_ROOT); // // Loop forever, processing widget messages. // while(1) { // // Process any messages in the widget message queue. // WidgetMessageQueueProcess(); } }
//***************************************************************************** // // 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) { } }