コード例 #1
0
ファイル: Buttons.c プロジェクト: GevenM/giip
void ClearRightButton( tContext *context ){
	GrContextForegroundSet( context, ClrWhite);
	GrContextBackgroundSet( context, ClrBlack);
	GrRectFill( context, &myRectangleBotRight);
	GrContextForegroundSet( context, ClrBlack);
	GrContextBackgroundSet( context, ClrWhite);
}
コード例 #2
0
ファイル: controls.c プロジェクト: Sowhat2112/KreyosFirmware
void window_drawtime(tContext *pContext, long y, uint8_t times[3], uint8_t selected)
{
  char data[3];
  data[0] = data[1] = '0';
  data[2] = ':';
  #define SPACING 3
  uint8_t height = GrStringHeightGet(pContext);
  
  uint8_t width_all = GrStringWidthGet(pContext, data, 3) + 10;
  uint8_t width_digit = GrStringWidthGet(pContext, data, 2) + 4;

  long startx = (LCD_WIDTH - width_all - width_all - width_digit) / 2;
  if (startx < 0) startx = 0;

  for(int i = 0; i < 3; i++)
  {
    data[0] = '0' + times[i] / 10;
    data[1] = '0' + times[i] % 10;

    GrContextForegroundSet(pContext, ClrWhite);
    GrContextBackgroundSet(pContext, ClrBlack);

    if (selected & (1 << i))
      window_selecttext(pContext, data, 2, startx + SPACING + i * width_all, y);
    else
      GrStringDraw(pContext, data, 2, startx + SPACING + i * width_all, y, 0);

    if (i != 2)
    {
      GrContextForegroundSet(pContext, ClrWhite);
      GrContextBackgroundSet(pContext, ClrBlack);
      GrStringDraw(pContext, ":", 1, startx + SPACING + width_digit + i * width_all, y, 0);
    }
  }
}
コード例 #3
0
ファイル: PrintReminder.c プロジェクト: GevenM/giip
void PrintReminder(tContext *context, y_menus f_menuChoice){
	char outString[32] = "";
	unsigned char text_start = 18;

	// Draw top and bottom banner and buttons
	LoadLeftButton( context , "BACK");
	LoadMiddleButton( context , "SEL");
	//LoadRightButton("");


	// Menu options
	GrStringDraw( context, "Create Reminder", AUTO_STRING_LENGTH, 5, 18, OPAQUE_TEXT);
	GrStringDraw( context, "Remove Reminder", AUTO_STRING_LENGTH, 5, 31, OPAQUE_TEXT);


	// Highlight selected item
	switch (f_menuChoice) {
	case Reminder_Create:
		text_start = 18;
		strcpy(outString, "Create Reminder");
		break;
	case Reminder_Remove:
		text_start = 31;
		strcpy(outString, "Remove Reminder");
		break;
	default: break;
	}

	GrContextForegroundSet(context, ClrWhite); //ClrBlack       this affects the highlight color
	GrContextBackgroundSet(context, ClrBlack);    //ClrWhite      this affects the text color in the highlight
	GrStringDraw(context, outString, AUTO_STRING_LENGTH, 5, text_start, OPAQUE_TEXT);
	GrContextForegroundSet(context, ClrBlack);
	GrContextBackgroundSet(context, ClrWhite);

}
コード例 #4
0
//*****************************************************************************
//
// This function updates the contents of the directory text window.
//
// \param None.
//
// This function is will update the state of the directory window.  This can
// be the result of a DirUpdate() call which completely changed the contents
// of the window, or a selection changed and the screen needs to be updated.
//
// \return None.
//
//*****************************************************************************
void
UpdateWindow(void)
{
    int iIdx;
    int iLine;

    //
    // Set the first line of the directory text window.
    //
    iLine = TOP_HEIGHT;

    //
    // Clear out the text area for the entries.
    //
    ClearTextBox();

    //
    // Display all valid values.
    //
    for(iIdx = 0; iIdx < g_DirData.ulValidValues; iIdx++)
    {
        //
        // Change the backgound for the selected item.
        //
        if(g_DirData.ulSelectIndex == iIdx)
        {
            GrContextBackgroundSet(&g_sContext, ClrGray);
        }
        else
        {
            GrContextBackgroundSet(&g_sContext, ClrBlack);
        }

        //
        // Change the color for directories.
        //
        if (g_DirData.FileInfo[iIdx].fattrib & AM_DIR)
        {
            GrContextForegroundSet(&g_sContext, DIR_COLOR);
            GrStringDraw(&g_sContext, g_DirData.FileInfo[iIdx].fname,
                         100, 0, iLine, 1);
        }
        //
        // Change the color for files.
        //
        else
        {
            GrContextForegroundSet(&g_sContext, FILE_COLOR);
            GrStringDraw(&g_sContext, g_DirData.FileInfo[iIdx].fname,
                         100, 0, iLine, 1);
        }

        //
        // Move down by the height of the characters used.
        //
        iLine += g_sFontFixed6x8.ucHeight;
    }
}
コード例 #5
0
ファイル: Buttons.c プロジェクト: GevenM/giip
void LoadLeftButton( tContext *context, const char * text){
	GrRectFill( context, &myRectangleBotLeft);

	GrContextForegroundSet( context, ClrWhite);
	GrContextBackgroundSet( context, ClrBlack);
	GrStringDrawCentered( context, text, AUTO_STRING_LENGTH, 14, 88, TRANSPARENT_TEXT);
	GrContextForegroundSet( context, ClrBlack);
	GrContextBackgroundSet( context, ClrWhite);
}
コード例 #6
0
// Needed since the TivaWare Graphics Library seems to not have a function
// for clearing the display.
void BlankScreen(void)
{
    GrContextForegroundSet(&g_sContext, ClrWhite);
	GrContextBackgroundSet(&g_sContext, ClrBlack);
    GrRectFill(&g_sContext, &(g_sContext.sClipRegion));
    GrFlush(&g_sContext);
	GrContextForegroundSet(&g_sContext, ClrBlack);
	GrContextBackgroundSet(&g_sContext, ClrWhite);
}
コード例 #7
0
ファイル: FR59xx_EXP.c プロジェクト: Michael-DeSando/BMS
/**********************************************************************//**
 * @brief  Initializes the System
 *
 * @param  none
 *
 * @return none
 *************************************************************************/
void SystemInit(void)
{
    // Set the DCO to 8MHz (it's also the device's power-on setting). Do not change this frequency!
    // It impacts the cap touch scan window.
    CS_setDCOFreq(__MSP430_BASEADDRESS_CS__, CS_DCORSEL_0, CS_DCOFSEL_6);

    // Configure clock source and clock dividers. After this the clock configuration will be as follows:
    // ACLK=LFXT1/1=32,768Hz; SMCLK=DCOCLK/1=8MHz; and MCLK=DCOCLK/1=8MHz.
    CS_clockSignalInit(__MSP430_BASEADDRESS_CS__, CS_ACLK, CS_LFXTCLK_SELECT, CS_CLOCK_DIVIDER_1);
    CS_clockSignalInit(__MSP430_BASEADDRESS_CS__, CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1);
    CS_clockSignalInit(__MSP430_BASEADDRESS_CS__, CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1);

    // Set all GPIO to output low to minimize current draw by eliminating floating pins.
    GPIO_setOutputLowOnPin(GPIO_PORT_PA, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7 | GPIO_PIN8 | GPIO_PIN9 | GPIO_PIN10 | GPIO_PIN11 | GPIO_PIN12 | GPIO_PIN13 | GPIO_PIN14 | GPIO_PIN15);
    GPIO_setOutputLowOnPin(GPIO_PORT_PB, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7 | GPIO_PIN8 | GPIO_PIN9 | GPIO_PIN10 | GPIO_PIN11 | GPIO_PIN12 | GPIO_PIN13 | GPIO_PIN14 | GPIO_PIN15);
    GPIO_setOutputLowOnPin(GPIO_PORT_PJ, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN6 | GPIO_PIN7 | GPIO_PIN8 | GPIO_PIN9 | GPIO_PIN10 | GPIO_PIN11 | GPIO_PIN12 | GPIO_PIN13 | GPIO_PIN14 | GPIO_PIN15);
    GPIO_setAsOutputPin(GPIO_PORT_PA, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7 | GPIO_PIN8 | GPIO_PIN9 | GPIO_PIN10 | GPIO_PIN11 | GPIO_PIN12 | GPIO_PIN13 | GPIO_PIN14 | GPIO_PIN15);
    GPIO_setAsOutputPin(GPIO_PORT_PB, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7 | GPIO_PIN8 | GPIO_PIN9 | GPIO_PIN10 | GPIO_PIN11 | GPIO_PIN12 | GPIO_PIN13 | GPIO_PIN14 | GPIO_PIN15);
    GPIO_setAsOutputPin(GPIO_PORT_PJ, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN6 | GPIO_PIN7 | GPIO_PIN8 | GPIO_PIN9 | GPIO_PIN10 | GPIO_PIN11 | GPIO_PIN12 | GPIO_PIN13 | GPIO_PIN14 | GPIO_PIN15);

    // Configure the left button (S2) connected to P4.6. For this enable the internal pull-up resistor and
    // setup the pin interrupt to trigger on rising edges.
    GPIO_setAsInputPinWithPullUpresistor(GPIO_PORT_P4, GPIO_PIN5);
    GPIO_interruptEdgeSelect(GPIO_PORT_P4, GPIO_PIN5, GPIO_LOW_TO_HIGH_TRANSITION);
    GPIO_clearInterruptFlag(GPIO_PORT_P4, GPIO_PIN5);
    GPIO_enableInterrupt(GPIO_PORT_P4, GPIO_PIN5);

    // Configure the right button (S3) connected to P1.1. For this enable the internal pull-up resistor and
    // setup the pin interrupt to trigger on rising edges.
    GPIO_setAsInputPinWithPullUpresistor(GPIO_PORT_P1, GPIO_PIN1);
    GPIO_interruptEdgeSelect(GPIO_PORT_P1, GPIO_PIN1, GPIO_LOW_TO_HIGH_TRANSITION);
    GPIO_clearInterruptFlag(GPIO_PORT_P1, GPIO_PIN1);
    GPIO_enableInterrupt(GPIO_PORT_P1, GPIO_PIN1);

    // CapSense Setup. GPIO pins P1.3-1.5 and P3.4-3.6 are used for capacitive touch so let's
    // switch them to inputs.
 //   GPIO_setAsInputPin(GPIO_PORT_P1, GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5);
    GPIO_setAsInputPin(GPIO_PORT_P3, GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6);

    // Enable LFXT functionality on PJ.4 and PJ.5. For this we only need to configure PJ.4 to
    // LFXIN and the port module logic takes care of the rest.
    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_PJ, GPIO_PIN4, GPIO_PRIMARY_MODULE_FUNCTION);

    // Disable the GPIO power-on default high-impedance mode to activate previously configured port settings
    PMM_unlockLPM5(__MSP430_BASEADDRESS_PMM_FRAM__);

    // Perform the required LFXT startup procedure now that all of the port pins are configured.
    CS_setExternalClockSource(__MSP430_BASEADDRESS_CS__, 32768, 0);
    CS_LFXTStart(__MSP430_BASEADDRESS_CS__, CS_LFXT_DRIVE0);

    // Initialize LCD driver and the context for the LCD
    Sharp96x96_LCDInit();
    TA0_enableVCOMToggle();
    GrContextInit(&sContext, &g_sharp96x96LCD);
    GrContextForegroundSet(&sContext, ClrBlack);
    GrContextBackgroundSet(&sContext, ClrWhite);


    onLED();                                   //blink LED1
}
コード例 #8
0
ファイル: freertos_demo.c プロジェクト: RevaReva/tiva-c
//*****************************************************************************
//
// This hook is called by FreeRTOS when an stack overflow error is detected.
//
//*****************************************************************************
void
vApplicationStackOverflowHook(xTaskHandle *pxTask, signed char *pcTaskName)
{
    tContext sContext;

    //
    // A fatal FreeRTOS error was detected, so display an error message.
    //
    GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119);
    GrContextForegroundSet(&sContext, ClrRed);
    GrContextBackgroundSet(&sContext, ClrBlack);
    GrContextFontSet(&sContext, g_psFontCm20);
    GrStringDrawCentered(&sContext, "Fatal FreeRTOS error!", -1,
                         GrContextDpyWidthGet(&sContext) / 2,
                         (((GrContextDpyHeightGet(&sContext) - 24) / 2) +
                          24), 1);

    //
    // This function can not return, so loop forever.  Interrupts are disabled
    // on entry to this function, so no processor interrupts will interrupt
    // this loop.
    //
    while(1)
    {
    }
}
コード例 #9
0
//*****************************************************************************
//
// This hook is called by SafeRTOS when an error is detected.
//
//*****************************************************************************
static void
SafeRTOSErrorHook(xTaskHandle xHandleOfTaskWithError,
                  signed portCHAR *pcNameOfTaskWithError,
                  portBASE_TYPE xErrorCode)
{
    tContext sContext;

    //
    // A fatal SafeRTOS error was detected, so display an error message.
    //
    GrContextInit(&sContext, &g_sKitronix320x240x16_SSD2119);
    GrContextForegroundSet(&sContext, ClrRed);
    GrContextBackgroundSet(&sContext, ClrBlack);
    GrContextFontSet(&sContext, g_pFontCm20);
    GrStringDrawCentered(&sContext, "Fatal SafeRTOS error!", -1,
                         GrContextDpyWidthGet(&sContext) / 2,
                         (((GrContextDpyHeightGet(&sContext) - 24) / 2) +
                          24), 1);

    //
    // This function can not return, so loop forever.  Interrupts are disabled
    // on entry to this function, so no processor interrupts will interrupt
    // this loop.
    //
    while(1)
    {
    }
}
コード例 #10
0
ファイル: main.c プロジェクト: ansonb/CCS-codes-backup
void lcd_init(){
	Dogs102x64_UC1701Init();
	GrContextInit(&g_sContext, &g_sDogs102x64_UC1701);
	GrContextForegroundSet(&g_sContext, ClrBlack);
	GrContextBackgroundSet(&g_sContext, ClrWhite);
	GrContextFontSet(&g_sContext, &g_sFontFixed6x8);
	GrClearDisplay(&g_sContext);
}
コード例 #11
0
ファイル: screen.c プロジェクト: peterliu2/tivaWare
//*****************************************************************************
//
// Draws a toggle button.
//
//*****************************************************************************
void
DrawToggle(const tButtonToggle *psButton, bool bOn)
{
    tRectangle sRect;
    int16_t i16X, i16Y;

    //
    // Copy the data out of the bounds of the button.
    //
    sRect = psButton->sRectButton;

    GrContextForegroundSet(&g_sContext, ClrLightGrey);
    GrRectFill(&g_sContext, &psButton->sRectContainer);

    //
    // Copy the data out of the bounds of the button.
    //
    sRect = psButton->sRectButton;

    GrContextForegroundSet(&g_sContext, ClrDarkGray);
    GrRectFill(&g_sContext, &psButton->sRectButton);

    if(bOn) {
        sRect.i16XMin += 2;
        sRect.i16YMin += 2;
        sRect.i16XMax -= 15;
        sRect.i16YMax -= 2;
    } else {
        sRect.i16XMin += 15;
        sRect.i16YMin += 2;
        sRect.i16XMax -= 2;
        sRect.i16YMax -= 2;
    }
    GrContextForegroundSet(&g_sContext, ClrLightGrey);
    GrRectFill(&g_sContext, &sRect);

    GrContextFontSet(&g_sContext, &g_sFontCm16);
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrContextBackgroundSet(&g_sContext, ClrLightGrey);

    i16X = sRect.i16XMin + ((sRect.i16XMax - sRect.i16XMin) / 2);
    i16Y = sRect.i16YMin + ((sRect.i16YMax - sRect.i16YMin) / 2);

    if(bOn) {
        GrStringDrawCentered(&g_sContext, psButton->pcOn, -1, i16X, i16Y,
                             true);
    } else {
        GrStringDrawCentered(&g_sContext, psButton->pcOff, -1, i16X, i16Y,
                             true);
    }

    if(psButton->pcLabel) {
        GrStringDraw(&g_sContext, psButton->pcLabel, -1,
                     psButton->sRectButton.i16XMax + 2,
                     psButton->sRectButton.i16YMin + 6,
                     true);
    }
}
コード例 #12
0
ファイル: main.c プロジェクト: ansonb/CCS-codes-backup
void print_string(int column,int row,char *s){
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrContextBackgroundSet(&g_sContext, ClrWhite);

    GrStringDraw(&g_sContext,
    		s,
    		AUTO_STRING_LENGTH,
    		column,
    		row,OPAQUE_TEXT);
}
コード例 #13
0
void print_char(int column,int row,const char s){
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrContextBackgroundSet(&g_sContext, ClrWhite);

    char S[2] = {s, 0};
    GrStringDraw(&g_sContext,
    		S,
    		AUTO_STRING_LENGTH,
    		column,
    		row,OPAQUE_TEXT);
}
コード例 #14
0
ファイル: PrintBasal_TmpActive.c プロジェクト: GevenM/giip
void PrintBasTmpActive(tContext *context, y_menus f_menuChoice){
    char outString[32];
    unsigned char text_start = 18;

    // Draw top and bottom banner and buttons
	LoadLeftButton( context , "BACK");
	LoadMiddleButton( context , "SEL");
	//LoadRightButton("");


	// Menu options
	GrStringDraw(context, "Start Profile", AUTO_STRING_LENGTH, 5, 18, OPAQUE_TEXT);
	GrStringDraw(context, "Stop Temporary", AUTO_STRING_LENGTH, 5, 31, OPAQUE_TEXT);
	GrStringDraw(context, "Manage Profiles", AUTO_STRING_LENGTH, 5, 44, OPAQUE_TEXT);

    // Highlight selected item
    switch (f_menuChoice) {
    case Basal_StartProfile:
        text_start = 18;
        strcpy(outString, "Start Profile");
        break;
    case Basal_StopTmp:
        text_start = 31;
        strcpy(outString, "Stop Temporary");
        break;
    case Basal_Manage:
        text_start = 44;
        strcpy(outString, "Manage Profiles");
        break;

    default: break;
    }

    GrContextForegroundSet(context, ClrWhite); //ClrBlack       this affects the highlight color
    GrContextBackgroundSet(context, ClrBlack);    //ClrWhite      this affects the text color in the highlight
    GrStringDraw(context, outString, AUTO_STRING_LENGTH, 5, text_start, OPAQUE_TEXT);
	GrContextForegroundSet(context, ClrBlack);
	GrContextBackgroundSet(context, ClrWhite);
}
コード例 #15
0
ファイル: main.c プロジェクト: ansonb/CCS-codes-backup
void print_int(int column,int row,int n){
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrContextBackgroundSet(&g_sContext, ClrWhite);

    char s[10];
    snprintf(s,10,"%d",n);

    GrStringDraw(&g_sContext,
    		s,
    		AUTO_STRING_LENGTH,
    		column,
    		row,TRANSPARENT_TEXT);
}
コード例 #16
0
ファイル: screen.c プロジェクト: peterliu2/tivaWare
//*****************************************************************************
//
// Animate Buttons.
//
//*****************************************************************************
void
AnimateButtons(bool bInit)
{
    if(bInit) {
        g_sButtons.i32X = 0;
        g_sButtons.i32Y = 0;
        g_sButtons.bEnabled = true;
        g_sButtons.bActive = false;
        g_sButtons.ui32Delay = 0;
    } else if(g_sButtons.bEnabled == false) {
        //
        // Just return if the buttons are not on screen.
        //
        return;
    }

    if(g_sButtons.ui32Delay == 0) {
        g_sButtons.ui32Delay = 6;

        GrContextForegroundSet(&g_sContext, ClrBlack);
        GrContextBackgroundSet(&g_sContext, ClrGray);

        if((bInit == false) || (g_sButtons.bActive == true)) {
            //
            // Update the buttons.
            //
            DrawButtons(g_sButtons.i32X - g_sButtons.i32Y, true);

            if(g_sButtons.i32X < 3) {
                g_sButtons.i32X++;
            } else {
                g_sButtons.i32Y++;
            }
        }

        if(g_sButtons.bActive == false) {
            //
            // Update the buttons.
            //
            DrawButtons(g_sButtons.i32X - g_sButtons.i32Y, false);

            if(g_sButtons.i32Y >= 3) {
                g_sButtons.bActive = true;
                g_sButtons.ui32Delay = 6;
            }
        } else if((g_i32ScreenIdx == SCREEN_SUMMARY) ||
                  (g_i32ScreenIdx == SCREEN_DETAILS)) {
            ButtonsDisable();
        }
    }
}
コード例 #17
0
ファイル: peripherals.c プロジェクト: Lumbini/MSP430_Hero
void configDisplay(void)
{
    // Enable use of external clock crystals
    P5SEL |= (BIT5|BIT4|BIT3|BIT2);

    // Set up LCD -- These function calls are part on a TI supplied library
    Dogs102x64_UC1701Init();
    GrContextInit(&g_sContext, &g_sDogs102x64_UC1701);
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrContextBackgroundSet(&g_sContext, ClrWhite);
    GrContextFontSet(&g_sContext, &g_sFontFixed6x8);
    GrClearDisplay(&g_sContext);
    GrFlush(&g_sContext);
}
コード例 #18
0
//*****************************************************************************
//
// This function updates the status area of the screen.  It uses the current
// state of the application to print the status bar.
//
//*****************************************************************************
void
UpdateStatus(char *pcString, tBoolean bClrBackground)
{
    tRectangle sRect;

    //
    // Fill the bottom rows of the screen with blue to create the status area.
    //
    sRect.sXMin = 0;
    sRect.sYMin = GrContextDpyHeightGet(&g_sContext) -
                  DISPLAY_BANNER_HEIGHT - 1;
    sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1;
    sRect.sYMax = sRect.sYMin + DISPLAY_BANNER_HEIGHT;

    //
    //
    //
    GrContextBackgroundSet(&g_sContext, DISPLAY_BANNER_BG);

    if(bClrBackground)
    {
        //
        // Draw the background of the banner.
        //
        GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_BG);
        GrRectFill(&g_sContext, &sRect);

        //
        // Put a white box around the banner.
        //
        GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_FG);
        GrRectDraw(&g_sContext, &sRect);
    }

    //
    // Write the current state to the left of the status area.
    //
    GrContextFontSet(&g_sContext, g_pFontFixed6x8);

    //
    // Update the status on the screen.
    //
    if(pcString != 0)
    {
        GrStringDraw(&g_sContext, pcString, -1, 4, sRect.sYMin + 4, 1);
    }
}
コード例 #19
0
/*******************************************************************************
 * @fn          devpkLcdInvert
 *
 * @brief       Inverts the foreground and background colours
 *
 * @return      true if success
 */
bool devpkLcdInvert(void)
{
  if (hLcdPin != NULL)
  {
    uint32_t tmp;

    // Swap background and foreground
    tmp = display.fg;
    display.fg = display.bg;
    display.bg = tmp;

    GrContextForegroundSet(&g_sContext, display.fg);
    GrContextBackgroundSet(&g_sContext, display.bg);
    GrClearDisplay(&g_sContext);

    GrFlush(&g_sContext);
  }

  return hLcdPin != 0;
}
コード例 #20
0
//*****************************************************************************
//
// This function clears out the text area used to display the directory
// contents.
//
// \param None.
//
// This function is used to clear out the text area used to display the
// directory contents.
//
// \return None.
//
//*****************************************************************************
void
ClearTextBox(void)
{
    tRectangle TextBox;

    TextBox.sXMin = 0;
    TextBox.sYMin = TOP_HEIGHT;
    TextBox.sXMax = g_sFormike128x128x16.usWidth - 1;
    TextBox.sYMax = g_sFormike128x128x16.usHeight - 1;

    //
    // Set the fill color.
    //
    GrContextForegroundSet(&g_sContext, BACKGROUND_COLOR);

    //
    // Fill the text area with the fill color.
    //
    GrRectFill(&g_sContext, &TextBox);

    GrContextForegroundSet(&g_sContext, FILE_COLOR);
    GrContextBackgroundSet(&g_sContext, ClrBlack);
}
コード例 #21
0
ファイル: displayBasics.c プロジェクト: hitubaldaniya/lumweb
/**
 * Show the Text for the Bootscreen
 */
void vShowBootText(char* text)
{

	/* Header Rectangle */
	tRectangle sRect;

	if (g_sContext.pDisplay == 0)
	{
		GrContextInit(&g_sContext, DISPLAY_DRIVER);
	}

	//
	// Fill the top 24 rows of the screen with blue to create the banner.
	//
	sRect.sXMin = 0;
	sRect.sYMin = 0;
	sRect.sXMax = GrContextDpyWidthGet(&g_sContext);
	sRect.sYMax = GrContextDpyHeightGet(&g_sContext);

	GrContextForegroundSet(&g_sContext, DISPLAY_BOOT_SCREEN_BACKGROUND_COLOR);
	GrContextBackgroundSet(&g_sContext, DISPLAY_BOOT_SCREEN_BACKGROUND_COLOR);
	GrRectFill(&g_sContext, &sRect);

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

	GrContextForegroundSet(&g_sContext, DISPLAY_BOOT_SCREEN_COLOR);
	//
	// Put the application name in the middle of the banner.
	//
	GrContextFontSet(&g_sContext, DISPLAY_BOOT_SCREEN_FONT);
	GrStringDrawCentered(&g_sContext, text, -1,
			GrContextDpyWidthGet(&g_sContext) / 2, GrContextDpyHeightGet(&g_sContext) / 2, 0);
}
コード例 #22
0
/*******************************************************************************
 * @fn          devpkLcdOpen
 *
 * @brief       Initialize the LCD
 *
 * @descr       Initializes the pins used by the LCD, creates resource access
 *              protection semaphore, turns on the LCD device, initializes the
 *              frame buffer, initializes to white background/dark foreground,
 *              and finally clears the display.
 *
 * @return      true if success
 */
bool devpkLcdOpen(void)
{
  hLcdPin = PIN_open(&pinState, BoardDevpackLCDPinTable);

  if (hLcdPin != 0)
  {
    display.bg = ClrBlack;
    display.fg = ClrWhite;

    // Open the SPI driver
    bspSpiOpen();

    // Exclusive access
    Semaphore_Params_init(&semParamsLCD);
    semParamsLCD.mode = Semaphore_Mode_BINARY;
    Semaphore_construct(&semLCD, 1, &semParamsLCD);
    hSemLCD = Semaphore_handle(&semLCD);

    // Turn on the display
    PIN_setOutputValue(hLcdPin,Board_DEVPK_LCD_DISP,1);

    // Graphics library init
    GrContextInit(&g_sContext, &g_sharp96x96LCD);

    // Graphics properties
    GrContextForegroundSet(&g_sContext, display.fg);
    GrContextBackgroundSet(&g_sContext, display.bg);
    GrContextFontSet(&g_sContext, &g_sFontFixed6x8);

    // Clear display
    GrClearDisplay(&g_sContext);
    GrFlush(&g_sContext);
  }

  return hLcdPin != 0;
}
コード例 #23
0
ファイル: container.c プロジェクト: VENGEL/StellarisWare
//*****************************************************************************
//
//! 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;

            //
            // Get the position of the vertical center of the text.
            //
            lY = (pWidget->sPosition.sYMin +
                  (GrFontBaselineGet(pContainer->pFont) / 2));

            //
            // Set the color to draw the outline.
            //
            GrContextForegroundSet(&sCtx, pContainer->ulOutlineColor);

            //
            // Draw the outline around the container widget, leaving a gap
            // where the text reside across the top of the widget.
            //
            GrLineDraw(&sCtx, lX1, lY, pWidget->sPosition.sXMin, lY);
            GrLineDraw(&sCtx, pWidget->sPosition.sXMin, lY,
                       pWidget->sPosition.sXMin, pWidget->sPosition.sYMax);
            GrLineDraw(&sCtx, pWidget->sPosition.sXMin,
                       pWidget->sPosition.sYMax, pWidget->sPosition.sXMax,
                       pWidget->sPosition.sYMax);
            GrLineDraw(&sCtx, pWidget->sPosition.sXMax,
                       pWidget->sPosition.sYMax, pWidget->sPosition.sXMax, lY);
            GrLineDraw(&sCtx, pWidget->sPosition.sXMax, lY, lX2, lY);
        }
    }

    //
    // Otherwise, see if the container outline style is selected.
    //
    else if(pContainer->ulStyle & CTR_STYLE_OUTLINE)
    {
        //
        // Outline the container with the outline color.
        //
        GrContextForegroundSet(&sCtx, pContainer->ulOutlineColor);
        GrRectDraw(&sCtx, &(pWidget->sPosition));
    }
}
コード例 #24
0
ファイル: checkbox.c プロジェクト: hitubaldaniya/lumweb
//*****************************************************************************
//
//! Draws a check box widget.
//!
//! \param pWidget is a pointer to the check box 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 check box widget on the display.  This is called in
//! response to a \b #WIDGET_MSG_PAINT message.
//!
//! \return None.
//
//*****************************************************************************
static void
CheckBoxPaint(tWidget *pWidget, unsigned long bClick)
{
    tCheckBoxWidget *pCheck;
    tRectangle sRect;
    tContext sCtx;
    long lY;

    //
    // Check the arguments.
    //
    ASSERT(pWidget);

    //
    // Convert the generic widget pointer into a check box widget pointer.
    //
    pCheck = (tCheckBoxWidget *)pWidget;

    //
    // Initialize a drawing context.
    //
    GrContextInit(&sCtx, pWidget->pDisplay);

    //
    // Initialize the clipping region based on the extents of this check box.
    //
    GrContextClipRegionSet(&sCtx, &(pWidget->sPosition));

    //
    // See if the check box fill style is selected.
    //
    if((pCheck->usStyle & CB_STYLE_FILL) && !bClick)
    {
        //
        // Fill the check box with the fill color.
        //
        GrContextForegroundSet(&sCtx, pCheck->ulFillColor);
        GrRectFill(&sCtx, &(pWidget->sPosition));
    }

    //
    // See if the check box outline style is selected.
    //
    if((pCheck->usStyle & CB_STYLE_OUTLINE) && !bClick)
    {
        //
        // Outline the check box with the outline color.
        //
        GrContextForegroundSet(&sCtx, pCheck->ulOutlineColor);
        GrRectDraw(&sCtx, &(pWidget->sPosition));
    }

    //
    // Draw the check box.
    //
    sRect.sXMin = pWidget->sPosition.sXMin + 2;
    sRect.sYMin = (pWidget->sPosition.sYMin +
                   ((pWidget->sPosition.sYMax - pWidget->sPosition.sYMin -
                     pCheck->usBoxSize + 1) / 2));
    sRect.sXMax = sRect.sXMin + pCheck->usBoxSize - 1;
    sRect.sYMax = sRect.sYMin + pCheck->usBoxSize - 1;
    if(!bClick)
    {
        GrContextForegroundSet(&sCtx, pCheck->ulOutlineColor);
        GrRectDraw(&sCtx, &sRect);
    }

    //
    // Select the foreground color based on whether or not the check box is
    // selected.
    //
    if(pCheck->usStyle & CB_STYLE_SELECTED)
    {
        GrContextForegroundSet(&sCtx, pCheck->ulOutlineColor);
    }
    else
    {
        GrContextForegroundSet(&sCtx, pCheck->ulFillColor);
    }

    //
    // Draw an "X" in the check box.
    //
    GrLineDraw(&sCtx, sRect.sXMin + 1, sRect.sYMin + 1, sRect.sXMax - 1,
               sRect.sYMax - 1);
    GrLineDraw(&sCtx, sRect.sXMin + 1, sRect.sYMax - 1, sRect.sXMax - 1,
               sRect.sYMin + 1);

    //
    // See if the check box text or image style is selected.
    //
    if((pCheck->usStyle & (CB_STYLE_TEXT | CB_STYLE_IMG)) && !bClick)
    {
        //
        // Shrink the clipping region by the size of the check box so that it
        // is not overwritten by further "decorative" portions of the widget.
        //
        sCtx.sClipRegion.sXMin += pCheck->usBoxSize + 4;

        //
        // If the check box 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(pCheck->usStyle & CB_STYLE_OUTLINE)
        {
            sCtx.sClipRegion.sYMin++;
            sCtx.sClipRegion.sXMax--;
            sCtx.sClipRegion.sYMax--;
        }

        //
        // See if the check box image style is selected.
        //
        if(pCheck->usStyle & CB_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(pCheck->pucImage) >
               (sCtx.sClipRegion.sYMax - sCtx.sClipRegion.sYMin))
            {
                lY = sCtx.sClipRegion.sYMin;
            }
            else
            {
                lY = (sCtx.sClipRegion.sYMin +
                      ((sCtx.sClipRegion.sYMax - sCtx.sClipRegion.sYMin -
                        GrImageHeightGet(pCheck->pucImage) + 1) / 2));
            }

            //
            // Set the foreground and background colors to use for 1 BPP
            // images.
            //
            GrContextForegroundSet(&sCtx, pCheck->ulTextColor);
            GrContextBackgroundSet(&sCtx, pCheck->ulFillColor);

            //
            // Draw the image next to the check box.
            //
            GrImageDraw(&sCtx, pCheck->pucImage, sCtx.sClipRegion.sXMin, lY);
        }

        //
        // See if the check box text style is selected.
        //
        if(pCheck->usStyle & CB_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(pCheck->pFont) >
               (sCtx.sClipRegion.sYMax - sCtx.sClipRegion.sYMin))
            {
                lY = sCtx.sClipRegion.sYMin;
            }
            else
            {
                lY = (sCtx.sClipRegion.sYMin +
                      ((sCtx.sClipRegion.sYMax - sCtx.sClipRegion.sYMin -
                        GrFontHeightGet(pCheck->pFont) + 1) / 2));
            }

            //
            // Draw the text next to the check box.
            //
            GrContextFontSet(&sCtx, pCheck->pFont);
            GrContextForegroundSet(&sCtx, pCheck->ulTextColor);
            GrContextBackgroundSet(&sCtx, pCheck->ulFillColor);
            GrStringDraw(&sCtx, pCheck->pcText, -1, sCtx.sClipRegion.sXMin,
                         lY, pCheck->usStyle & CB_STYLE_TEXT_OPAQUE);
        }
    }
}
コード例 #25
0
ファイル: radiobutton.c プロジェクト: mileat/proj-emb
//*****************************************************************************
//
//! 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);
        }
    }
}
コード例 #26
0
ファイル: imgbutton.c プロジェクト: VENGEL/StellarisWare
//*****************************************************************************
//
//! Draws an image button.
//!
//! \param pWidget is a pointer to the image button widget to be drawn.
//!
//! This function draws a rectangular image button on the display.  This is
//! called in response to a \b #WIDGET_MSG_PAINT message.
//!
//! \return None.
//
//*****************************************************************************
static void
ImageButtonPaint(tWidget *pWidget)
{
    const unsigned char *pucImage;
    tImageButtonWidget *pPush;
    tContext sCtx;
    long lX, lY;

    //
    // Check the arguments.
    //
    ASSERT(pWidget);

    //
    // Convert the generic widget pointer into a image button widget pointer.
    //
    pPush = (tImageButtonWidget *)pWidget;

    //
    // Initialize a drawing context.
    //
    GrContextInit(&sCtx, pWidget->pDisplay);

    //
    // Initialize the clipping region based on the extents of this rectangular
    // image button.
    //
    GrContextClipRegionSet(&sCtx, &(pWidget->sPosition));

    //
    // Compute the center of the image button.
    //
    lX = (pWidget->sPosition.sXMin +
          ((pWidget->sPosition.sXMax - pWidget->sPosition.sXMin + 1) / 2));
    lY = (pWidget->sPosition.sYMin +
          ((pWidget->sPosition.sYMax - pWidget->sPosition.sYMin + 1) / 2));

    //
    // Do we need to fill the widget background with a color?
    //
    if(pPush->ulStyle & IB_STYLE_FILL)
    {
        //
        // Yes. Set the appropriate color depending upon whether or not
        // the widget is currently pressed.
        //
        GrContextForegroundSet(&sCtx,
                               ((pPush->ulStyle & IB_STYLE_PRESSED) ?
                                pPush->ulPressedColor :
                                pPush->ulBackgroundColor));
        GrRectFill(&sCtx, &(pWidget->sPosition));
    }

    //
    // Set the foreground and background colors to use for 1 BPP
    // images and text
    //
    GrContextForegroundSet(&sCtx, pPush->ulForegroundColor);
    GrContextBackgroundSet(&sCtx,
                           ((pPush->ulStyle & IB_STYLE_PRESSED) ?
                            pPush->ulPressedColor :
                            pPush->ulBackgroundColor));

    //
    // Do we need to draw the background image?
    //
    if(!(pPush->ulStyle & IB_STYLE_IMAGE_OFF))
    {
        //
        // Get the background image to be drawn.
        //
        pucImage = ((pPush->ulStyle & IB_STYLE_PRESSED) ?
                    pPush->pucPressImage : pPush->pucImage);

        //
        // Draw the image centered in the image button.
        //
        GrImageDraw(&sCtx, pucImage, lX - (GrImageWidthGet(pucImage) / 2),
                    lY - (GrImageHeightGet(pucImage) / 2));
    }

    //
    // Adjust the drawing position if the button is pressed.
    //
    lX += ((pPush->ulStyle & IB_STYLE_PRESSED) ? pPush->sXOffset : 0);
    lY += ((pPush->ulStyle & IB_STYLE_PRESSED) ? pPush->sYOffset : 0);

    //
    // If there is a keycap image and it is not disabled, center this on the
    // top of the button, applying any offset defined if the button is
    // currently pressed.
    //
    if(pPush->pucKeycapImage && !(pPush->ulStyle & IB_STYLE_KEYCAP_OFF))
    {
        //
        // Draw the keycap image.
        //
        GrImageDraw(&sCtx, pPush->pucKeycapImage,
                    lX - (GrImageWidthGet(pPush->pucKeycapImage) / 2),
                    lY - (GrImageHeightGet(pPush->pucKeycapImage) / 2));
    }

    //
    // See if the button text style is selected.
    //
    if(pPush->ulStyle & IB_STYLE_TEXT)
    {
        //
        // Draw the text centered in the middle of the button with offset
        // applied if the button is currently pressed.
        //
        GrContextFontSet(&sCtx, pPush->pFont);
        GrStringDrawCentered(&sCtx, pPush->pcText, -1, lX, lY, 0);
    }
}
コード例 #27
0
//*****************************************************************************
//
//! Paints the clock set widget on the display.
//!
//! \param psWidget is a pointer to the clock setting widget to be drawn.
//!
//! This function draws the date and time fields of the clock setting widget
//! onto the display.  One of the fields can be highlighted.  This is
//! called in response to a \b WIDGET_MSG_PAINT message.
//!
//! \return None.
//
//*****************************************************************************
static void
ClockSetPaint(tWidget *psWidget)
{
    tClockSetWidget *psClockWidget;
    tContext sContext;
    tRectangle sRect, sRectSel;
    struct tm *psTime;
    char pcBuf[8];
    int32_t i32X, i32Y, i32Width, i32Height;
    uint32_t ui32Idx, ui32FontHeight, ui32FontWidth, ui32SelWidth;

    //
    // Check the arguments.
    //
    ASSERT(psWidget);
    ASSERT(psWidget->psDisplay);

    //
    // Convert the generic widget pointer into a clock set widget pointer.
    //
    psClockWidget = (tClockSetWidget *)psWidget;
    ASSERT(psClockWidget->psTime);

    //
    // Get pointer to the time structure
    //
    psTime = psClockWidget->psTime;

    //
    // Initialize a drawing context.
    //
    GrContextInit(&sContext, psWidget->psDisplay);

    //
    // Initialize the clipping region based on the extents of this widget.
    //
    GrContextClipRegionSet(&sContext, &(psWidget->sPosition));

    //
    // Set the font for the context, and get font height and width - they
    // are used a lot later.
    //
    GrContextFontSet(&sContext, psClockWidget->psFont);
    ui32FontHeight = GrFontHeightGet(psClockWidget->psFont);
    ui32FontWidth = GrFontMaxWidthGet(psClockWidget->psFont);

    //
    // Fill the widget with the background color.
    //
    GrContextForegroundSet(&sContext, psClockWidget->ui32BackgroundColor);
    GrRectFill(&sContext, &sContext.sClipRegion);

    //
    // Draw a border around the widget
    //
    GrContextForegroundSet(&sContext, psClockWidget->ui32ForegroundColor);
    GrContextBackgroundSet(&sContext, psClockWidget->ui32BackgroundColor);
    GrRectDraw(&sContext, &sContext.sClipRegion);

    //
    // Compute a rectangle for the screen title.  Put it at the top of
    // the widget display, and sized to be the height of the font, plus
    // a few pixels of space.
    //
    sRect.i16XMin = sContext.sClipRegion.i16XMin;
    sRect.i16XMax = sContext.sClipRegion.i16XMax;
    sRect.i16YMin = sContext.sClipRegion.i16YMin;
    sRect.i16YMax = ui32FontHeight * 2;
    GrRectDraw(&sContext, &sRect);

    //
    // Print a title for the widget
    //
    GrContextFontSet(&sContext, psClockWidget->psFont);
    GrStringDrawCentered(&sContext, "CLOCK SET", -1,
                         (1 + sRect.i16XMax - sRect.i16XMin) / 2,
                         (1 + sRect.i16YMax - sRect.i16YMin) / 2, 1);

    //
    // Reset the rectangle to cover the non-title area of the display
    //
    sRect.i16YMin = sRect.i16YMax + 1;
    sRect.i16YMax = sContext.sClipRegion.i16YMax;

    //
    // Compute the width and height of the area remaining for showing the
    // clock fields.
    //
    i32Width = 1 + (sRect.i16XMax - sRect.i16XMin);
    i32Height = 1 + (sRect.i16YMax - sRect.i16YMin);

    //
    // Compute the X and Y starting point for the row that will show the
    // date.
    //
    i32X = sRect.i16XMin + (i32Width - (ui32FontWidth * 10)) / 2;
    i32Y = sRect.i16YMin + ((i32Height * 1) / 6) - (ui32FontHeight / 2);

    //
    // Draw the date field separators on the date row.
    //
    GrStringDraw(&sContext, "/", -1, i32X + (ui32FontWidth * 4), i32Y, 0);
    GrStringDraw(&sContext, "/", -1, i32X + (ui32FontWidth * 7), i32Y, 0);

    //
    // Compute the X and Y starting point for the row that will show the
    // time.
    //
    i32X = sRect.i16XMin + (i32Width - (ui32FontWidth * 5)) / 2;
    i32Y = sRect.i16YMin + ((i32Height * 3) / 6) - (ui32FontHeight / 2);

    //
    // Draw the time field separators on the time row.
    //
    GrStringDraw(&sContext, ":", -1, i32X + (ui32FontWidth * 2), i32Y, 0);

    //
    // Process each of the fields to be shown on the widget
    //
    for(ui32Idx = 0; ui32Idx < NUM_FIELDS; ui32Idx++)
    {
        //
        // Compute the X and Y for the text for each field, and print the
        // text into a buffer.
        //
        switch(ui32Idx)
        {
            //
            // Year
            //
            case FIELD_YEAR:
            {
                usnprintf(pcBuf, sizeof(pcBuf), "%4u", psTime->tm_year+1900);
                i32X = sRect.i16XMin + (i32Width - (ui32FontWidth * 10)) / 2;
                i32Y = sRect.i16YMin + ((i32Height * 1) / 6) -
                       (ui32FontHeight / 2);
                ui32SelWidth = 4;
                break;
            }

            //
            // Month
            //
            case FIELD_MONTH:
            {
                usnprintf(pcBuf, sizeof(pcBuf), "%02u", psTime->tm_mon + 1);
                i32X += ui32FontWidth * 5;
                ui32SelWidth = 2;
                break;
            }

            //
            // Day
            //
            case FIELD_DAY:
            {
                usnprintf(pcBuf, sizeof(pcBuf), "%02u", psTime->tm_mday);
                i32X += ui32FontWidth * 3;
                ui32SelWidth = 2;
                break;
            }

            //
            // Hour
            //
            case FIELD_HOUR:
            {
                usnprintf(pcBuf, sizeof(pcBuf), "%02u", psTime->tm_hour);
                i32X = sRect.i16XMin + (i32Width - (ui32FontWidth * 5)) / 2;
                i32Y = sRect.i16YMin + ((i32Height * 3) / 6) -
                       (ui32FontHeight / 2);
                ui32SelWidth = 2;
                break;
            }

            //
            // Minute
            //
            case FIELD_MINUTE:
            {
                usnprintf(pcBuf, sizeof(pcBuf), "%02u", psTime->tm_min);
                i32X += ui32FontWidth * 3;
                ui32SelWidth = 2;
                break;
            }

            //
            // OK
            //
            case FIELD_OK:
            {
                usnprintf(pcBuf, sizeof(pcBuf), "OK");
                i32X = (i32Width - (ui32FontWidth * 9)) / 2;
                i32X += sRect.i16XMin;
                i32Y = ((i32Height * 5) / 6) - (ui32FontHeight / 2);
                i32Y += sRect.i16YMin;
                ui32SelWidth = 2;
                break;
            }

            //
            // CANCEL (default case is purely to keep the compiler from
            // issuing a warning that ui32SelWidth may be used ininitialized).
            //
            case FIELD_CANCEL:
            default:
            {
                usnprintf(pcBuf, sizeof(pcBuf), "CANCEL");
                i32X += ui32FontWidth * 3;
                ui32SelWidth = 6;
                break;
            }
        }


        //
        // If the current field index is the highlighted field, then this
        // text field will be drawn with highlighting.
        //
        if(ui32Idx == psClockWidget->ui32Highlight)
        {
            //
            // Compute a rectangle for the highlight area.
            //
            sRectSel.i16XMin = i32X;
            sRectSel.i16XMax = (ui32SelWidth * ui32FontWidth) + i32X;
            sRectSel.i16YMin = i32Y - 2;
            sRectSel.i16YMax = ui32FontHeight + i32Y + 2;

            //
            // Set the foreground color to the text color, and then fill the
            // highlight rectangle.  The text field will be highlighted by
            // inverting the normal colors.
            // Then draw the highlighting rectangle.
            //
            GrContextForegroundSet(&sContext,
                                   psClockWidget->ui32ForegroundColor);
            GrRectFill(&sContext, &sRectSel);

            //
            // Change the foreground color to the normal background color.
            // This will be used for drawing the text for the highlighted
            // field, which has the colors inverted (FG <--> BG)
            //
            GrContextForegroundSet(&sContext,
                                   psClockWidget->ui32BackgroundColor);
        }
        else
        {
            //
            // This text field is not highlighted so just set the normal
            // foreground color.
            //
            GrContextForegroundSet(&sContext,
                                   psClockWidget->ui32ForegroundColor);
        }

        //
        // Print the text from the buffer to the display at the computed
        // location.
        //
        GrStringDraw(&sContext, pcBuf, -1, i32X, i32Y, 0);
    }
}
コード例 #28
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);

}
コード例 #29
0
ファイル: slider.c プロジェクト: saintent/LM4F120
//*****************************************************************************
//
//! Draws a slider.
//!
//! \param pWidget is a pointer to the slider widget to be drawn.
//! \param pDirty is the subrectangle of the widget which is to be redrawn.
//! This is expressed in screen coordinates.
//!
//! This function draws a slider on the display.  This is called in response to
//! a \b #WIDGET_MSG_PAINT message or when the slider position changes.
//!
//! \return None.
//
//*****************************************************************************
static void
SliderPaint(tWidget *pWidget, tRectangle *pDirty)
{
    tRectangle sClipRect, sValueRect, sEmptyRect, sActiveClip;
    tSliderWidget *pSlider;
    tContext sCtx;
    long lX, lY, bIntersect;
    short sPos;

    //
    // Check the arguments.
    //
    ASSERT(pWidget);

    //
    // Convert the generic widget pointer into a slider widget pointer.
    //
    pSlider = (tSliderWidget *)pWidget;

    //
    // Initialize a drawing context.
    //
    GrContextInit(&sCtx, pWidget->pDisplay);

    //
    // Initialize the clipping region based on the update rectangle passed.
    //
    bIntersect = GrRectIntersectGet(pDirty, &(pSlider->sBase.sPosition),
                                    &sClipRect);
    GrContextClipRegionSet(&sCtx, &sClipRect);

    //
    // Draw the control outline if necessary.
    //
    if(pSlider->ulStyle & SL_STYLE_OUTLINE)
    {
        //
        // Outline the slider with the outline color.
        //
        GrContextForegroundSet(&sCtx, pSlider->ulOutlineColor);
        GrRectDraw(&sCtx, &(pWidget->sPosition));

        //
        // Adjust the clipping rectangle to prevent the outline from being
        // corrupted later.
        //
        if(sClipRect.sXMin == pWidget->sPosition.sXMin)
        {
            sClipRect.sXMin++;
        }

        if(sClipRect.sYMin == pWidget->sPosition.sYMin)
        {
            sClipRect.sYMin++;
        }

        if(sClipRect.sXMax == pWidget->sPosition.sXMax)
        {
            sClipRect.sXMax--;
        }

        if(sClipRect.sYMax == pWidget->sPosition.sYMax)
        {
            sClipRect.sYMax--;
        }
    }

    //
    // Determine the position associated with the current slider value.
    //
    sPos = SliderValueToPosition(pSlider, pSlider->lValue);

    //
    // Remember this so that the dirty rectangle code in the click handler
    // draws the correct thing the first time it is called.
    //
    pSlider->sPos = sPos;

    //
    // Determine the rectangles for the active and empty portions of the
    // widget.
    //
    if(pSlider->ulStyle & SL_STYLE_VERTICAL)
    {
        //
        // Determine the rectangle corresponding to the bottom (value) portion
        // of the slider.
        //
        sValueRect.sXMin = pWidget->sPosition.sXMin;
        sValueRect.sXMax = pWidget->sPosition.sXMax;
        sValueRect.sYMin = sPos;
        sValueRect.sYMax = pWidget->sPosition.sYMax;

        //
        // Determine the rectangle corresponding to the top (empty) portion
        // of the slider.
        //
        sEmptyRect.sXMin = pWidget->sPosition.sXMin;
        sEmptyRect.sXMax = pWidget->sPosition.sXMax;
        sEmptyRect.sYMin = pWidget->sPosition.sYMin;
        sEmptyRect.sYMax = max(sEmptyRect.sYMin, sValueRect.sYMin - 1);
    }
    else
    {
        //
        // Determine the rectangle corresponding to the bottom (value) portion
        // of the slider.
        //
        sValueRect.sYMin = pWidget->sPosition.sYMin;
        sValueRect.sYMax = pWidget->sPosition.sYMax;
        sValueRect.sXMin = pWidget->sPosition.sXMin;
        sValueRect.sXMax = sPos;

        //
        // Determine the rectangle corresponding to the top (empty) portion
        // of the slider.
        //
        sEmptyRect.sYMin = pWidget->sPosition.sYMin;
        sEmptyRect.sYMax = pWidget->sPosition.sYMax;
        sEmptyRect.sXMax = pWidget->sPosition.sXMax;
        sEmptyRect.sXMin = min(sEmptyRect.sXMax, sValueRect.sXMax + 1);
    }

    //
    // Compute the center of the slider.  This will be needed later if drawing
    // text or an image.
    //
    lX = (pWidget->sPosition.sXMin +
          ((pWidget->sPosition.sXMax - pWidget->sPosition.sXMin + 1) / 2));
    lY = (pWidget->sPosition.sYMin +
          ((pWidget->sPosition.sYMax - pWidget->sPosition.sYMin + 1) / 2));

    //
    // Get the required clipping rectangle for the active/value part of
    // the slider.
    //
    bIntersect = GrRectIntersectGet(&sClipRect, &sValueRect, &sActiveClip);

    //
    // Does any part of the value rectangle intersect with the region we are
    // supposed to be redrawing?
    //
    if(bIntersect)
    {
        //
        // Yes - we have something to draw.
        //

        //
        // Set the new clipping rectangle.
        //
        GrContextClipRegionSet(&sCtx, &sActiveClip);

        //
        // Do we need to fill the active area with a color?
        //
        if(pSlider->ulStyle & SL_STYLE_FILL)
        {
            GrContextForegroundSet(&sCtx, pSlider->ulFillColor);
            GrRectFill(&sCtx, &sValueRect);
        }

        //
        // Do we need to draw an image in the active area?
        //
        if(pSlider->ulStyle & SL_STYLE_IMG)
        {
            GrContextForegroundSet(&sCtx, pSlider->ulTextColor);
            GrContextBackgroundSet(&sCtx, pSlider->ulFillColor);
            GrImageDraw(&sCtx, pSlider->pucImage,
                        lX - (GrImageWidthGet(pSlider->pucImage) / 2),
                        lY - (GrImageHeightGet(pSlider->pucImage) / 2));
        }

        //
        // Do we need to render a text string over the top of the active area?
        //
        if(pSlider->ulStyle & SL_STYLE_TEXT)
        {
            GrContextFontSet(&sCtx, pSlider->pFont);
            GrContextForegroundSet(&sCtx, pSlider->ulTextColor);
            GrContextBackgroundSet(&sCtx, pSlider->ulFillColor);
            GrStringDrawCentered(&sCtx, pSlider->pcText, -1, lX, lY,
                                 pSlider->ulStyle & SL_STYLE_TEXT_OPAQUE);
        }
    }

    //
    // Now get the required clipping rectangle for the background portion of
    // the slider.
    //
    bIntersect = GrRectIntersectGet(&sClipRect, &sEmptyRect, &sActiveClip);

    //
    // Does any part of the background rectangle intersect with the region we
    // are supposed to be redrawing?
    //
    if(bIntersect)
    {
        //
        // Yes - we have something to draw.
        //

        //
        // Set the new clipping rectangle.
        //
        GrContextClipRegionSet(&sCtx, &sActiveClip);

        //
        // Do we need to fill the active area with a color?
        //
        if(pSlider->ulStyle & SL_STYLE_BACKG_FILL)
        {
            GrContextForegroundSet(&sCtx, pSlider->ulBackgroundFillColor);
            GrRectFill(&sCtx, &sEmptyRect);
        }

        //
        // Do we need to draw an image in the active area?
        //
        if(pSlider->ulStyle & SL_STYLE_BACKG_IMG)
        {
            GrContextForegroundSet(&sCtx, pSlider->ulBackgroundTextColor);
            GrContextBackgroundSet(&sCtx, pSlider->ulBackgroundFillColor);
            GrImageDraw(&sCtx, pSlider->pucBackgroundImage,
                    lX - (GrImageWidthGet(pSlider->pucBackgroundImage) / 2),
                    lY - (GrImageHeightGet(pSlider->pucBackgroundImage) / 2));
        }

        //
        // Do we need to render a text string over the top of the active area?
        //
        if(pSlider->ulStyle & SL_STYLE_BACKG_TEXT)
        {
            GrContextFontSet(&sCtx, pSlider->pFont);
            GrContextForegroundSet(&sCtx, pSlider->ulBackgroundTextColor);
            GrContextBackgroundSet(&sCtx, pSlider->ulBackgroundFillColor);
            GrStringDrawCentered(&sCtx, pSlider->pcText, -1, lX, lY,
                                 pSlider->ulStyle & SL_STYLE_BACKG_TEXT_OPAQUE);
        }
    }
}
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();
    }
}