//.........这里部分代码省略.........
pMenuWidget->pSlideMenu = pChildMenu;
//
// Draw the new (child) menu into off-screen buffer A
//
SlideMenuDraw(pMenuWidget, &sContext, 0);
}
//
// Process child widget of this menu item. This only happens if there
// is no child menu.
//
else if(pChildWidget)
{
//
// Call the widget activated callback function. This will notify
// the application that a child widget has been activated by the
// menu system.
//
if(pMenuWidget->pfnActive)
{
pMenuWidget->pfnActive(pChildWidget,
&pMenu->pSlideMenuItems[pMenu->ulFocusIndex],
1);
}
//
// Link the new child widget into this SlideMenuWidget so
// it appears as a child to this widget. Normally the menu widget
// has no child widget.
//
pWidget->pChild = pChildWidget;
pChildWidget->pParent = pWidget;
//
// Fill a rectangle with the new child widget background color.
// This is done in off-screen buffer A. When the menu slides off,
// it will be replaced by a blank background that will then be
// controlled by the new child widget.
//
GrContextForegroundSet(
&sContext,
pMenu->pSlideMenuItems[pMenu->ulFocusIndex].ulChildWidgetColor);
GrRectFill(&sContext, &sContext.sClipRegion);
//
// Request a repaint for the child widget so it can draw itself once
// the menu slide is done.
//
WidgetPaint(pChildWidget);
}
//
// There is no child menu or child widget, so there is nothing to change
// on the display.
//
else
{
return(1);
}
//
// Initialize a drawing context for the display where the widget is to be
// drawn. This is the physical display, not an off-screen buffer.
//
GrContextInit(&sContext, pWidget->pDisplay);
//
// Initialize the clipping region on the physical display, based on the
// extents of this widget.
//
GrContextClipRegionSet(&sContext, &(pWidget->sPosition));
//
// Get the width of the menu widget which is used in calculations below
//
ulMenuWidth = pMenuWidget->pDisplayA->usWidth;
//
// The following loop draws the two off-screen buffers onto the physical
// display using a right-to-left-wipe. This will provide an appearance
// of sliding to the left. The new child menu, or child widget background
// will slide in from the right. The "old" menu is being held in
// off-screen buffer B and the new one is in buffer A. So when we are
// done, the correct image will be in buffer A.
//
for(uX = 0; uX <= ulMenuWidth; uX += 8)
{
GrImageDraw(&sContext, pMenuWidget->pDisplayB->pvDisplayData,
pWidget->sPosition.sXMin - uX, pWidget->sPosition.sYMin);
GrImageDraw(&sContext, pMenuWidget->pDisplayA->pvDisplayData,
pWidget->sPosition.sXMin + ulMenuWidth - uX,
pWidget->sPosition.sYMin);
}
//
// Return indication that we handled the key event.
//
return(1);
}
//*****************************************************************************
//
// A simple demonstration of the features of the Stellaris Graphics Library.
//
//*****************************************************************************
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
//
SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
SYSCTL_OSC_MAIN);
//
// Initialize the display driver.
//
Kentec320x240x16_SSD2119Init();
//
// Initialize the graphics context.
//
GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119);
//
// Fill the top 24 rows of the screen with blue to create the banner.
//
sRect.i16XMin = 0;
sRect.i16YMin = 0;
sRect.i16XMax = GrContextDpyWidthGet(&sContext) - 1;
sRect.i16YMax = 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);
//
// 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();
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);
CanvasTextSet(&g_sTitle, g_pcPanelNames[0]);
//
// Issue the initial paint request to the widgets.
//
WidgetPaint(WIDGET_ROOT);
//
// Loop forever handling widget messages.
//.........这里部分代码省略.........
//*****************************************************************************
//
// Provides a scribble pad using the display on the Intelligent Display Module.
//
//*****************************************************************************
int
main(void)
{
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);
//
// Initialize the graphics context.
//
GrContextInit(&g_sContext, &g_sKentec320x240x16_SSD2119);
//
// Draw the application frame.
//
FrameDraw(&g_sContext, "scribble");
//
// Print the instructions across the top of the screen in white with a 20
// point san-serif font.
//
GrContextForegroundSet(&g_sContext, ClrWhite);
GrContextFontSet(&g_sContext, g_psFontCmss20);
GrStringDrawCentered(&g_sContext, "Touch the screen to draw", -1,
GrContextDpyWidthGet(&g_sContext) / 2,
((GrContextDpyHeightGet(&g_sContext) - 32) / 2) + 14,
0);
//
// Flush any cached drawing operations.
//
GrFlush(&g_sContext);
//
// Set the color index to zero.
//
g_ui32ColorIdx = 0;
//
// Initialize the message queue we use to pass messages from the touch
// interrupt handler context to the main loop for processing.
//
RingBufInit(&g_sMsgQueue, (uint8_t *)g_psMsgQueueBuffer,
(MSG_QUEUE_SIZE * sizeof(tScribbleMessage)));
//
// Initialize the touch screen driver.
//
TouchScreenInit(ui32SysClock);
//
// Set the touch screen event handler.
//
TouchScreenCallbackSet(TSHandler);
//
// Loop forever. All the drawing is done in the touch screen event
// handler.
//
while(1) {
//
// Process any new touchscreen messages.
//
ProcessTouchMessages();
}
}
//*****************************************************************************
//
// This is the generic callback from host stack.
//
// pvData is actually a pointer to a tEventInfo structure.
//
// This function will be called to inform the application when a USB event has
// occurred that is outside those related to the mouse device. At this
// point this is used to detect unsupported devices being inserted and removed.
// It is also used to inform the application when a power fault has occurred.
// This function is required when the g_USBGenericEventDriver is included in
// the host controller driver array that is passed in to the
// USBHCDRegisterDrivers() function.
//
//*****************************************************************************
void
USBHCDEvents(void *pvData)
{
tEventInfo *pEventInfo;
tRectangle sRect;
//
// Fill the bottom rows of the screen with blue to create the status area.
//
sRect.i16XMin = 0;
sRect.i16YMin = GrContextDpyHeightGet(&g_sContext) -
DISPLAY_BANNER_HEIGHT - 1;
sRect.i16XMax = GrContextDpyWidthGet(&g_sContext) - 1;
sRect.i16YMax = sRect.i16YMin + DISPLAY_BANNER_HEIGHT;
GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_BG);
GrRectFill(&g_sContext, &sRect);
//
// Put a white box around the banner.
//
GrContextForegroundSet(&g_sContext, ClrWhite);
GrRectDraw(&g_sContext, &sRect);
//
// Set the font for the status message
//
GrContextFontSet(&g_sContext, g_psFontFixed6x8);
//
// Cast this pointer to its actual type.
//
pEventInfo = (tEventInfo *)pvData;
switch(pEventInfo->ui32Event)
{
//
// New mouse detected.
//
case USB_EVENT_CONNECTED:
{
//
// See if this is a HID Mouse.
//
if((USBHCDDevClass(pEventInfo->ui32Instance, 0) == USB_CLASS_HID) &&
(USBHCDDevProtocol(pEventInfo->ui32Instance, 0) ==
USB_HID_PROTOCOL_MOUSE))
{
//
// Indicate that the mouse has been detected.
//
GrStringDrawCentered(&g_sContext, "Mouse Connected", -1,
GrContextDpyWidthGet(&g_sContext) / 2,
sRect.i16YMin + 5, 0);
//
// Set initial mouse information.
//
GrStringDrawCentered(&g_sContext, "0,0", -1,
GrContextDpyWidthGet(&g_sContext) / 2, 26, 1);
GrStringDrawCentered(&g_sContext, "000", -1,
GrContextDpyWidthGet(&g_sContext) / 2, 46, 1);
//
// Proceed to the STATE_MOUSE_INIT state so that the main loop
// can finish initialized the mouse since USBHMouseInit()
// cannot be called from within a callback.
//
g_eUSBState = STATE_MOUSE_INIT;
}
break;
}
//
// Unsupported device detected.
//
case USB_EVENT_UNKNOWN_CONNECTED:
{
GrStringDrawCentered(&g_sContext, "Unknown Device", -1,
GrContextDpyWidthGet(&g_sContext) / 2,
sRect.i16YMin + 5, 0);
//
// An unknown device was detected.
//
g_eUSBState = STATE_UNKNOWN_DEVICE;
//.........这里部分代码省略.........
//*****************************************************************************
//
// This is the main loop that runs the application.
//
//*****************************************************************************
int
main(void)
{
uint_fast32_t ui32LastTickCount;
bool bLastSuspend;
tRectangle sRect;
tContext sContext;
int_fast32_t i32CenterX;
//
// 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 at 50MHz.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// Configure the required pins for USB operation.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
ROM_GPIOPinConfigure(GPIO_PG4_USB0EPEN);
ROM_GPIOPinTypeUSBDigital(GPIO_PORTG_BASE, GPIO_PIN_4);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
ROM_GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7);
ROM_GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Erratum workaround for silicon revision A1. VBUS must have pull-down.
//
if(CLASS_IS_BLIZZARD && REVISION_IS_A1)
{
HWREG(GPIO_PORTB_BASE + GPIO_O_PDR) |= GPIO_PIN_1;
}
//
// Enable the GPIO that is used for the on-board LED.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_2);
ROM_GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_2, 0);
//
// Initialize the buttons driver
//
ButtonsInit();
//
// Initialize the display driver.
//
CFAL96x64x16Init();
//
// Initialize the graphics context and find the middle X coordinate.
//
GrContextInit(&sContext, &g_sCFAL96x64x16);
i32CenterX = GrContextDpyWidthGet(&sContext) / 2;
//
// Fill the top part of the screen with blue to create the banner.
//
sRect.i16XMin = 0;
sRect.i16YMin = 0;
sRect.i16XMax = GrContextDpyWidthGet(&sContext) - 1;
sRect.i16YMax = 9;
GrContextForegroundSet(&sContext, ClrDarkBlue);
GrRectFill(&sContext, &sRect);
//
// Change foreground for white text.
//
GrContextForegroundSet(&sContext, ClrWhite);
//
// Put the application name in the middle of the banner.
//
GrContextFontSet(&sContext, g_psFontFixed6x8);
GrStringDrawCentered(&sContext, "usb-dev-keyboard", -1, i32CenterX, 4, 0);
//
// Not configured initially.
//
g_bConnected = false;
g_bSuspended = false;
bLastSuspend = false;
//
// Initialize the USB stack for device mode.
//
//.........这里部分代码省略.........
//*****************************************************************************
//
// Demonstrate the use of the boot loader.
//
//*****************************************************************************
int
main(void)
{
tRectangle sRect;
//
// Set the clocking to run directly from the crystal.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
//
// If running on Rev A0 silicon, write the FMPRE[2-3]/FMPPE[2-3] registers
// to zero. This is a workaround to allow the mass erase in the ROM-based
// boot loader to succeed if a locked device recovery has been performed.
//
if(REVISION_IS_A0)
{
HWREG(FLASH_FMPPE2) = 0;
HWREG(FLASH_FMPPE3) = 0;
HWREG(FLASH_FMPRE2) = 0;
HWREG(FLASH_FMPRE3) = 0;
}
//
// Enable the UART and GPIO modules.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
//
// Make the UART pins be peripheral controlled.
//
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Configure the UART for 115,200, 8-N-1 operation.
//
ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
//
// 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, "boot_demo1", -1,
GrContextDpyWidthGet(&g_sContext) / 2, 7, 0);
//
// Indicate what is happening.
//
GrStringDrawCentered(&g_sContext, "The boot loader is", -1,
GrContextDpyWidthGet(&g_sContext) / 2, 24, 0);
GrStringDrawCentered(&g_sContext, "now running and", -1,
GrContextDpyWidthGet(&g_sContext) / 2, 32, 0);
GrStringDrawCentered(&g_sContext, "awaiting an update", -1,
GrContextDpyWidthGet(&g_sContext) / 2, 40, 0);
GrStringDrawCentered(&g_sContext, "over UART0 at", -1,
GrContextDpyWidthGet(&g_sContext) / 2, 48, 0);
GrStringDrawCentered(&g_sContext, "115200, 8-N-1.", -1,
GrContextDpyWidthGet(&g_sContext) / 2, 56, 0);
//
//.........这里部分代码省略.........
//*****************************************************************************
//
// Demonstrate the use of the USB stick update example.
//
//*****************************************************************************
int
main(void)
{
uint_fast32_t ui32Count;
tContext sContext;
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 system clock to run at 50MHz from the PLL.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// Initialize the display driver.
//
CFAL96x64x16Init();
//
// Initialize the graphics context.
//
GrContextInit(&sContext, &g_sCFAL96x64x16);
//
// Fill the top 24 rows of the screen with blue to create the banner.
//
sRect.i16XMin = 0;
sRect.i16YMin = 0;
sRect.i16XMax = GrContextDpyWidthGet(&sContext) - 1;
sRect.i16YMax = 9;
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_psFontFixed6x8);
GrStringDrawCentered(&sContext, "usb-stick-demo", -1,
GrContextDpyWidthGet(&sContext) / 2, 4, 0);
//
// Indicate what is happening.
//
GrStringDrawCentered(&sContext, "Press the", -1,
GrContextDpyWidthGet(&sContext) / 2, 20, 0);
GrStringDrawCentered(&sContext, "select button to", -1,
GrContextDpyWidthGet(&sContext) / 2, 30, 0);
GrStringDrawCentered(&sContext, "start the USB", -1,
GrContextDpyWidthGet(&sContext) / 2, 40, 0);
GrStringDrawCentered(&sContext, "stick updater.", -1,
GrContextDpyWidthGet(&sContext) / 2, 50, 0);
//
// Flush any cached drawing operations.
//
GrFlush(&sContext);
//
// Enable the GPIO module which the select button is attached to.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
//
// Enable the GPIO pin to read the user button.
//
ROM_GPIODirModeSet(GPIO_PORTM_BASE, GPIO_PIN_4, GPIO_DIR_MODE_IN);
MAP_GPIOPadConfigSet(GPIO_PORTM_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
//
// Wait for the pullup to take effect or the next loop will exist too soon.
//
SysCtlDelay(1000);
//
// Wait until the select button has been pressed for ~40ms (in order to
// debounce the press).
//
ui32Count = 0;
while(1)
{
//
//.........这里部分代码省略.........
//*****************************************************************************
//
//! Draws a container widget.
//!
//! \param pWidget is a pointer to the container widget to be drawn.
//!
//! This function draws a container widget on the display. This is called in
//! response to a \b #WIDGET_MSG_PAINT message.
//!
//! \return None.
//
//*****************************************************************************
static void
ContainerPaint(tWidget *pWidget)
{
tContainerWidget *pContainer;
long lX1, lX2, lY;
tContext sCtx;
//
// Check the arguments.
//
ASSERT(pWidget);
//
// Convert the generic widget pointer into a container widget pointer.
//
pContainer = (tContainerWidget *)pWidget;
//
// Initialize a drawing context.
//
GrContextInit(&sCtx, pWidget->pDisplay);
//
// Initialize the clipping region based on the extents of this container.
//
GrContextClipRegionSet(&sCtx, &(pWidget->sPosition));
//
// See if the container fill style is selected.
//
if(pContainer->ulStyle & CTR_STYLE_FILL)
{
//
// Fill the container with the fill color.
//
GrContextForegroundSet(&sCtx, pContainer->ulFillColor);
GrRectFill(&sCtx, &(pWidget->sPosition));
}
//
// See if the container text style is selected.
//
if(pContainer->ulStyle & CTR_STYLE_TEXT)
{
//
// Set the font and colors used to draw the container text.
//
GrContextFontSet(&sCtx, pContainer->pFont);
GrContextForegroundSet(&sCtx, pContainer->ulTextColor);
GrContextBackgroundSet(&sCtx, pContainer->ulFillColor);
//
// Get the width of the container text.
//
lX2 = GrStringWidthGet(&sCtx, pContainer->pcText, -1);
//
// Determine the position of the text. The position depends on the
// the width of the string and if centering is enabled.
//
if(pContainer->ulStyle & CTR_STYLE_TEXT_CENTER)
{
lX1 = (pWidget->sPosition.sXMin +
((pWidget->sPosition.sXMax - pWidget->sPosition.sXMin + 1 -
lX2 - 8) / 2));
}
else
{
lX1 = pWidget->sPosition.sXMin + 4;
}
//
// Draw the container text.
//
GrStringDraw(&sCtx, pContainer->pcText, -1, lX1 + 4,
pWidget->sPosition.sYMin,
pContainer->ulStyle & CTR_STYLE_TEXT_OPAQUE);
//
// See if the container outline style is selected.
//
if(pContainer->ulStyle & CTR_STYLE_OUTLINE)
{
//
// Get the position of the right side of the string.
//
lX2 = lX1 + lX2 + 8;
//.........这里部分代码省略.........
//*****************************************************************************
//
// Print "Hello World!" to the display.
//
//*****************************************************************************
int
main(void)
{
tContext sContext;
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 directly from the crystal.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
SYSCTL_OSC_MAIN);
//
// Initialize the UART.
//
ConfigureUART();
UARTprintf("Hello, world!\n");
//
// Initialize the display driver.
//
CFAL96x64x16Init();
//
// Initialize the graphics context.
//
GrContextInit(&sContext, &g_sCFAL96x64x16);
//
// Fill the top 24 rows of the screen with blue to create the banner.
//
sRect.i16XMin = 0;
sRect.i16YMin = 0;
sRect.i16XMax = GrContextDpyWidthGet(&sContext) - 1;
sRect.i16YMax = 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_psFontCm12);
GrStringDrawCentered(&sContext, "hello", -1,
GrContextDpyWidthGet(&sContext) / 2, 10, 0);
//
// Say hello using the Computer Modern 40 point font.
//
GrContextFontSet(&sContext, g_psFontCm12/*g_psFontFixed6x8*/);
GrStringDrawCentered(&sContext, "Hello World!", -1,
GrContextDpyWidthGet(&sContext) / 2,
((GrContextDpyHeightGet(&sContext) - 24) / 2) + 24,
0);
//
// Flush any cached drawing operations.
//
GrFlush(&sContext);
//
// We are finished. Hang around doing nothing.
//
while(1)
{
}
}
//.........这里部分代码省略.........
RasterDMAFBConfig(SOC_LCDC_0_REGS,
(unsigned int)(g_pucBuffer+PALETTE_OFFSET),
(unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET,
1);
// Copy palette info into buffer
src = (unsigned char *) palette_32b;
dest = (unsigned char *) (g_pucBuffer+PALETTE_OFFSET);
for( i = 4; i < (PALETTE_SIZE+4); i++)
{
*dest++ = *src++;
}
GrOffScreen16BPPInit(&g_sSHARP480x272x16Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT);
// Initialize a drawing context.
GrContextInit(&g_sContext, &g_sSHARP480x272x16Display);
/* enable End of frame interrupt */
RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS);
/* enable raster */
RasterEnable(SOC_LCDC_0_REGS);
ConfigRasterDisplayEnable();
//
// 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 = DISPLAY_BANNER_HEIGHT;
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_sFontCm20);
GrStringDrawCentered(&g_sContext, "usb-dev-msc", -1,
GrContextDpyWidthGet(&g_sContext) / 2, 10, 0);
//
// Initialize the idle timeout and reset all flags.
//
g_ulIdleTimeout = 0;
g_ulFlags = 0;
//
// Initialize the state to idle.
//
g_eMSCState = MSC_DEV_IDLE;
//
// Draw the status bar and set it to idle.
//
UpdateStatus("Idle", 1);
#endif
//*****************************************************************************
//
//! Performs the sliding menu operation, in response to the "left" button.
//!
//! \param pWidget is a pointer to the slide menu widget to move to the left.
//!
//! This function will respond to the "left" key/button event. The left
//! button is used to ascend to the next menu up in the menu tree. The effect
//! is that the current menu, or active widget, slides off to the right, while
//! the parent menu slides in from the left.
//!
//! This function repeatedly draws the menu onto the display until the sliding
//! animation is finished and will not return to the caller until then. This
//! function is usually called from the thread context of
//! WidgetMessageQueueProcess().
//!
//! \return Returns a non-zero value if the menu was moved or was not moved
//! because it is already at the last position. If a child widget is active
//! then this function does nothing and returns a 0.
//
//*****************************************************************************
static long
SlideMenuLeft(tWidget *pWidget)
{
tSlideMenuWidget *pMenuWidget;
tSlideMenu *pMenu;
tSlideMenu *pParentMenu;
tContext sContext;
unsigned int uX;
unsigned long ulMenuWidth;
//
// Get handy pointers to the menu widget and active menu, and the parent
// menu if there is one.
//
pMenuWidget = (tSlideMenuWidget *)pWidget;
pMenu = pMenuWidget->pSlideMenu;
pParentMenu = pMenu->pParent;
//
// Initialize a context for the primary off-screen drawing buffer.
// Clip region is set to entire display by default, which is what we want.
//
GrContextInit(&sContext, pMenuWidget->pDisplayB);
//
// If this widget has a child, that means that the child widget is in
// control, and we are requested to go back to the previous menu item.
// Process the child widget.
//
if(pWidget->pChild)
{
//
// Call the widget de-activated callback function. This notifies the
// application that the widget is being deactivated.
//
if(pMenuWidget->pfnActive)
{
pMenuWidget->pfnActive(pWidget->pChild,
&pMenu->pSlideMenuItems[pMenu->ulFocusIndex],
0);
}
//
// Unlink the child widget from the slide menu widget. The menu
// widget will now no longer have a child widget.
//
pWidget->pChild->pParent = 0;
pWidget->pChild = 0;
//
// Fill a rectangle with the child widget background color. This will
// erase everything else that is shown on the widget but leave the
// background, which will make the change visually less jarring.
// This is done in off-screen buffer B, which is the buffer that is
// going to be slid off the screen.
//
GrContextForegroundSet(
&sContext,
pMenu->pSlideMenuItems[pMenu->ulFocusIndex].ulChildWidgetColor);
GrRectFill(&sContext, &sContext.sClipRegion);
}
//
// Otherwise there is not a child widget in control, so process the parent
// menu, if there is one.
//
else if(pParentMenu)
{
//
// Render the current menu into the off-screen buffer B. This will be
// the same menu appearance that is currently on the display.
//
SlideMenuDraw(pMenuWidget, &sContext, 0);
//
// Now switch the widget to the parent menu
//
pMenuWidget->pSlideMenu = pParentMenu;
}
//.........这里部分代码省略.........
请发表评论