//***************************************************************************** // // Display the interrupt state on the display. The currently active and pending // interrupts are displayed. // //***************************************************************************** void DisplayIntStatus(void) { uint32_t ui32Temp; char pcBuffer[6]; // // Display the currently active interrupts. // ui32Temp = HWREG(NVIC_ACTIVE0); pcBuffer[0] = ' '; pcBuffer[1] = (ui32Temp & 1) ? '1' : ' '; pcBuffer[2] = (ui32Temp & 2) ? '2' : ' '; pcBuffer[3] = (ui32Temp & 4) ? '3' : ' '; pcBuffer[4] = ' '; pcBuffer[5] = '\0'; GrStringDrawCentered(&g_sContext, pcBuffer, -1, 130, 150, 1); // // Display the currently pending interrupts. // ui32Temp = HWREG(NVIC_PEND0); pcBuffer[1] = (ui32Temp & 1) ? '1' : ' '; pcBuffer[2] = (ui32Temp & 2) ? '2' : ' '; pcBuffer[3] = (ui32Temp & 4) ? '3' : ' '; GrStringDrawCentered(&g_sContext, pcBuffer, -1, 270, 150, 1); // // Flush the display. // GrFlush(&g_sContext); }
//***************************************************************************** // // The touch screen driver calls this function to report all state changes. // //***************************************************************************** static long WatchdogTouchCallback(unsigned long ulMessage, long lX, long lY) { // // If the screen is tapped, we will receive a PTR_DOWN then a PTR_UP // message. We pick one (pretty much at random) to use as the trigger to // stop feeding the watchdog. // if(ulMessage == WIDGET_MSG_PTR_UP) { // // Let the user know that the tap has been registered and that the // watchdog is being starved. // GrContextFontSet(&g_sContext, g_pFontCmss20); GrStringDrawCentered(&g_sContext, "Watchdog is not being fed!", -1, GrContextDpyWidthGet(&g_sContext) / 2 , (GrContextDpyHeightGet(&g_sContext) / 2), 1); GrContextFontSet(&g_sContext, g_pFontCmss14); GrStringDrawCentered(&g_sContext, " System will reset shortly. ", -1, GrContextDpyWidthGet(&g_sContext) / 2 , (GrContextDpyHeightGet(&g_sContext) / 2) + 20, 1); // // Set the flag that tells the interrupt handler not to clear the // watchdog interrupt. // g_bFeedWatchdog = false; } return(0); }
static void drawGridTime(tContext *pContext) { char buf[20]; uint8_t time[3]; time[0] = workout_time % 60; time[1] = (workout_time / 60 ) % 60; time[2] = workout_time / 3600; GrContextForegroundSet(pContext, ClrBlack); switch(window_readconfig()->sports_grid) { case GRID_3: GrContextFontSet(pContext, (tFont*)&g_sFontExIcon16); GrStringDraw(pContext, "i", 1, 10, 15, 0); GrContextFontSet(pContext, &g_sFontGothic18); GrStringDraw(pContext, datapoints[0].name, -1, 28, 15, 0); GrContextFontSet(pContext, &g_sFontGothic28b); sprintf(buf, "%02d:%02d:%02d", time[2], time[1], time[0]); GrStringDrawCentered(pContext, buf, -1, LCD_WIDTH/2, 50, 0); break; case GRID_4: case GRID_5: GrContextFontSet(pContext, &g_sFontGothic28b); sprintf(buf, "%02d:%02d:%02d", time[2], time[1], time[0]); GrStringDrawCentered(pContext, buf, -1, LCD_WIDTH/2, 18, 0); break; } }
//***************************************************************************** // // This function is called when the select button is pressed. // //***************************************************************************** static int32_t SelectButtonPressed(void) { // // Find the X center of the display // int32_t i32CenterX = GrContextDpyWidthGet(&g_sContext) / 2; // // Let the user know that the button has been pressed and that the // watchdog is being starved. // GrStringDrawCentered(&g_sContext, "Starving", -1, i32CenterX, 14, 1); GrStringDrawCentered(&g_sContext, "Watchdog", -1, i32CenterX, 24, 1); GrStringDrawCentered(&g_sContext, "System", -1, i32CenterX, 36, 1); GrStringDrawCentered(&g_sContext, " will ", -1, i32CenterX, 46, 1); GrStringDrawCentered(&g_sContext, "reset ...", -1, i32CenterX, 56, 1); // // Set the flag that tells the interrupt handler not to clear the // watchdog interrupt. // g_bFeedWatchdog = false; return(0); }
void Timer1IntHandler(void) { //debugled(10); ROM_TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT); //debugled(3); int angle=0; if(max2>0 && max1>0 && abs(maxi1-maxi2)<PULSE_SAMPLE) { //float dt=abs(maxi1-maxi2)/SAMPLING_FREQUENCY; //angle=asin(dt*lambda/distance)*180/3.1412; angle=abs(maxi1-maxi2); } //debugled(3); acount++; //rcount=0; //ROM_IntMasterDisable(); snprintf(text,sizeof(text),"%3ld,%3ld",rcount,g_ulADCCount); GrContextForegroundSet(&sDisplayContext, ClrDarkBlue); GrRectFill(&sDisplayContext, &sRect1); GrContextForegroundSet(&sDisplayContext, ClrWhite); //GrRectDraw(&sDisplayContext, &sRect1); GrContextFontSet(&sDisplayContext, g_pFontCm12); GrStringDrawCentered(&sDisplayContext,text, -1, GrContextDpyWidthGet(&sDisplayContext) / 2, 10, 0); GrContextForegroundSet(&sDisplayContext, ClrDarkBlue); GrRectFill(&sDisplayContext, &sRect2); GrContextForegroundSet(&sDisplayContext, ClrWhite); sprintf(text,"%4d,%4d",buffer_increment,rem); GrContextFontSet(&sDisplayContext, g_pFontCm12/*g_pFontFixed6x8*/); GrStringDrawCentered(&sDisplayContext, text, -1, GrContextDpyWidthGet(&sDisplayContext) / 2, ((GrContextDpyHeightGet(&sDisplayContext) - 24) / 2) + 24, 0); // GrFlush(&sDisplayContext); max1=0; max2=0; res=0; res1=0; maxi1=0; maxi2=0; buffer_index=0; for(i=0;i<buffer_size;i++) { buffer[0][i]=0; buffer[1][i]=0; } i=0; j=0; ind2=buffer_index-buffer_increment+1; }
void PrintSettings_DateTime_NotAllowed(tContext *context) { GrStringDrawCentered(context, "Cannot edit", AUTO_STRING_LENGTH, 47, 27, OPAQUE_TEXT); GrStringDrawCentered(context, "while insulin", AUTO_STRING_LENGTH, 47, 38, OPAQUE_TEXT); GrStringDrawCentered(context, "delivery is", AUTO_STRING_LENGTH, 47, 49, OPAQUE_TEXT); GrStringDrawCentered(context, "in progress", AUTO_STRING_LENGTH, 47, 60, OPAQUE_TEXT); LoadMiddleButton( context , "OK"); }
//***************************************************************************** // // 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); } }
//***************************************************************************** // // The touch screen driver calls this function to report all state changes. // //***************************************************************************** static int32_t WatchdogTouchCallback(uint32_t ui32Message, int32_t i32X, int32_t i32Y) { // // If the screen is tapped, we will receive a PTR_DOWN then a PTR_UP // message. Use PTR_UP as the trigger to stop feeding the watchdog. // if(ui32Message == WIDGET_MSG_PTR_UP) { // // See if the left or right side of the screen was touched. // if(i32X <= (GrContextDpyWidthGet(&g_sContext) / 2)) { // // Let the user know that the tap has been registered and that the // watchdog0 is being starved. // GrContextFontSet(&g_sContext, g_psFontCmss20); GrContextForegroundSet(&g_sContext, ClrRed); GrStringDrawCentered(&g_sContext, "Watchdog 0 starved, reset shortly", -1, GrContextDpyWidthGet(&g_sContext) / 2 , (GrContextDpyHeightGet(&g_sContext) / 2) + 40, 1); GrContextForegroundSet(&g_sContext, ClrWhite); // // Set the flag that tells the interrupt handler not to clear the // watchdog0 interrupt. // g_bFeedWatchdog0 = false; } else { // // Let the user know that the tap has been registered and that the // watchdog1 is being starved. // GrContextFontSet(&g_sContext, g_psFontCmss20); GrContextForegroundSet(&g_sContext, ClrRed); GrStringDrawCentered(&g_sContext, "Watchdog 1 starved, reset shortly", -1, GrContextDpyWidthGet(&g_sContext) / 2 , (GrContextDpyHeightGet(&g_sContext) / 2) + 60, 1); GrContextForegroundSet(&g_sContext, ClrWhite); // // Set the flag that tells the interrupt handler not to clear the // watchdog1 interrupt. // g_bFeedWatchdog1 = false; } } return(0); }
//***************************************************************************** // // Draw a string with a white drop shadow at a give position on the display. // //***************************************************************************** void CenteredStringWithShadow(const tFont *pFont, char *pcString, short sX, short sY, tBoolean bOpaque) { GrContextFontSet(&g_sScreenContext, pFont); GrContextForegroundSet(&g_sScreenContext, SHADOW_COLOR); GrStringDrawCentered(&g_sScreenContext, pcString, -1, sX+1, sY+1, bOpaque); GrContextForegroundSet(&g_sScreenContext, HIGHLIGHT_COLOR); GrStringDrawCentered(&g_sScreenContext, pcString, -1, sX, sY, false); }
void PrintBolusCreateNotAllowed( tContext *context ){ // Draw top and bottom banner and buttons LoadLeftButton( context , "BACK"); // Menu options GrStringDrawCentered(context, "Bolus Preset", AUTO_STRING_LENGTH, 47, 31, OPAQUE_TEXT); GrStringDrawCentered(context, "Creation", AUTO_STRING_LENGTH, 47, 44, OPAQUE_TEXT); GrStringDrawCentered(context, "not Allowed", AUTO_STRING_LENGTH, 47, 57, OPAQUE_TEXT); }
void PrintNoBasProf(tContext *context){ // Draw top and bottom banner and buttons LoadLeftButton( context , "BACK"); //LoadMiddleButton("SEL"); //LoadRightButton(""); // Menu options GrStringDrawCentered(context, "No Basal", AUTO_STRING_LENGTH, 47, 31, OPAQUE_TEXT); GrStringDrawCentered(context, "Profile", AUTO_STRING_LENGTH, 47, 44, OPAQUE_TEXT); GrStringDrawCentered(context, "Available", AUTO_STRING_LENGTH, 47, 57, OPAQUE_TEXT); }
//***************************************************************************** // // Initialize the file system. // //***************************************************************************** void fs_init(void) { FRESULT fresult; DIR g_sDirObject; // // Initialze the flag to indicate that we are disabled. // g_bFatFsEnabled = false; // // Initialize and mount the Fat File System. // fresult = f_mount(0, &g_sFatFs); if(fresult != FR_OK) { return; } // // Open the root directory for access. // fresult = f_opendir(&g_sDirObject, "/"); // // Flag and display which file system we are using. // GrStringDrawCentered(&g_sContext, "Web Server Using", -1, GrContextDpyWidthGet(&g_sContext) / 2, 180, false); if(fresult == FR_OK) { // // Indicate and display that we are using the SD file system. // g_bFatFsEnabled = true; GrStringDrawCentered(&g_sContext, "SDCard File System", -1, GrContextDpyWidthGet(&g_sContext) / 2, 200, false); } else { // // Indicate and display that we are using the internal file system. // g_bFatFsEnabled = false; GrStringDrawCentered(&g_sContext, "Internal File System", -1, GrContextDpyWidthGet(&g_sContext) / 2, 200, false); } }
//***************************************************************************** // // 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) { } }
/****************************************************************************** * * * \brief Shows the status string on the color STN display. * * * * \param psContext is a pointer to the graphics context representing the * * display. * * * * \param pcStatus is a pointer to the string to be shown. * * * * \return none. * * * ******************************************************************************/ void DisplayStatus(tContext *psContext, char *pcStatus) { tRectangle rectLine; int lY; /* Calculate the Y coordinate of the top left of the character cell for our line of text. */ lY = (GrContextDpyHeightGet(psContext) / 8) - (GrFontHeightGet(TEXT_FONT) / 2); /* Determine the bounding rectangle for this line of text. We add 4 pixels to the height just to ensure that we clear a couple of pixels above and below the line of text. */ rectLine.sXMin = 0; rectLine.sXMax = GrContextDpyWidthGet(psContext) - 1; rectLine.sYMin = lY; rectLine.sYMax = lY + GrFontHeightGet(TEXT_FONT) + 3; /* Clear the line with black. */ GrContextForegroundSet(&g_sContext, ClrBlack); GrRectFill(psContext, &rectLine); /* Draw the new status string */ GrContextForegroundSet(&g_sContext, ClrWhite); GrStringDrawCentered(psContext, pcStatus, -1, GrContextDpyWidthGet(psContext) / 2, GrContextDpyHeightGet(psContext) / 8 , false); }
//***************************************************************************** // // 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) { } }
//***************************************************************************** // // Shows the status string on the color STN display. // // \param psContext is a pointer to the graphics context representing the // display. // \param pcStatus is a pointer to the string to be shown. // // This implementation assumes we are using a 6 pixel wide font, giving us // space for 16 characters across the display. // //***************************************************************************** void DisplayStatus(tContext *psContext, char *pcStatus) { tRectangle sRectLine; // // Determine the bounding rectangle for this line of text. // sRectLine.i16XMin = 0; sRectLine.i16XMax = GrContextDpyWidthGet(psContext) - 1; sRectLine.i16YMin = GrContextDpyHeightGet(psContext) - (TEXT_HEIGHT + 2); sRectLine.i16YMax = sRectLine.i16YMin + GrFontHeightGet(TEXT_FONT) + 1; // // Clear the line with black. // GrContextForegroundSet(&g_sContext, ClrBlack); GrRectFill(psContext, &sRectLine); // // Draw the new status string // GrContextForegroundSet(&g_sContext, ClrWhite); GrStringDrawCentered(psContext, pcStatus, -1, GrContextDpyWidthGet(psContext) / 2, sRectLine.i16YMin + (TEXT_HEIGHT / 2), false); }
//***************************************************************************** // // Display a status string on the LCD and also transmit it via the serial port. // //***************************************************************************** void UpdateStatus(char *pcStatus) { tRectangle sRect; // // Dump that status string to the serial port. // UARTprintf("%s\n", pcStatus); // // Clear any previous status message. // sRect.i16XMin = 0; sRect.i16XMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.i16YMin = STATUS_Y - 16; sRect.i16YMax = STATUS_Y + 16; GrContextForegroundSet(&g_sContext, ClrBlack); GrRectFill(&g_sContext, &sRect); // // Display the new status string. // GrContextFontSet(&g_sContext, g_psFontCmss20); GrContextForegroundSet(&g_sContext, ClrWhite); GrStringDrawCentered(&g_sContext, pcStatus, -1, GrContextDpyWidthGet(&g_sContext) / 2, STATUS_Y, 0); }
static void onDraw(tContext *pContext) { char buf[30]; GrContextForegroundSet(pContext, ClrBlack); #if defined(PRODUCT_W002) || defined(PRODUCT_W004) GrRectFill(pContext, &client_clip); #else GrRectFill(pContext, &fullscreen_clip); #endif GrContextForegroundSet(pContext, ClrWhite); if (state == WALK) { #if defined(PRODUCT_W002) || defined(PRODUCT_W004) sprintf(buf, "%d", ped_get_steps()); drawItem(pContext, 0, ICON_STEPS, "Step Taken", buf); sprintf(buf, "%02d:%02d", ped_get_time() / 60, ped_get_time() % 60); drawItem(pContext, 1, ICON_TIME, "Walk Time", buf); uint16_t cals = ped_get_calorie() / 100 / 1000; sprintf(buf, "%d", cals); drawItem(pContext, 2, ICON_CALORIES, "Calories", buf); uint16_t dist = ped_get_distance() / 100; sprintf(buf, "%dm", dist); drawItem(pContext, 3, ICON_DISTANCE, "Distance", buf); #else sprintf(buf, "%d", ped_get_steps()); drawItem(pContext, 0, ICON_STEPS, "Steps", buf); uint16_t cals = ped_get_calorie() / 100 / 1000; sprintf(buf, "%d", cals); drawItem(pContext, 1, ICON_CALORIES, "Calories", buf); uint16_t dist = ped_get_distance() / 100; sprintf(buf, "%dm", dist); drawItem(pContext, 2, ICON_DISTANCE, "Distance", buf); sprintf(buf, "%02d:%02d", ped_get_time() / 60, ped_get_time() % 60); drawItem(pContext, 3, ICON_TIME, "Active", buf); #endif // draw progress #if defined(PRODUCT_W002) || defined(PRODUCT_W004) #else uint16_t goal = window_readconfig()->goal_steps; uint32_t steps = ped_get_steps(); if (steps < goal) window_progress(pContext, 5 + 4 * LINEMARGIN, steps * 100 / goal); else window_progress(pContext, 5 + 4 * LINEMARGIN, 100); sprintf(buf, "%d%% of %d", (uint16_t)(steps * 100 / goal), goal); GrContextForegroundSet(pContext, ClrWhite); GrStringDrawCentered(pContext, buf, -1, LCD_WIDTH/2, 148, 0); #endif } }
//***************************************************************************** // // This function updates the status area of the screen. It uses the current // state of the application to print the status area. // //***************************************************************************** void UpdateStatus(char *pcString) { // // Write the current state to the bottom of screen. // GrStringDrawCentered(&g_sContext, pcString, -1, 160, 78, true); }
//***************************************************************************** // // Shows the status string on the display. // // \param psContext is a pointer to the graphics context representing the // display. // \param pi8Status is a pointer to the string to be shown. // //***************************************************************************** void DisplayStatus(tContext *psContext, char *pcStatus) { // // Clear the line with black. // GrContextForegroundSet(&g_sContext, ClrBlack); GrStringDrawCentered(psContext, " ", -1, GrContextDpyWidthGet(psContext) / 2, 16, true); // // Draw the new status string // DEBUG_PRINT("%s\n", pcStatus); GrContextForegroundSet(&g_sContext, ClrWhite); GrStringDrawCentered(psContext, pcStatus, -1, GrContextDpyWidthGet(psContext) / 2, 16, true); }
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); }
static void DisplayGR(void) { tRectangle sRect; // 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); GrStringDrawCentered(&sContext, "Touch here to proceed ", -1, GrContextDpyWidthGet(&sContext) / 2, 140, 0); // Initialize the sound driver. // 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); WidgetMessageQueueAdd(WIDGET_ROOT, WIDGET_MSG_PAINT, 0, 0, 0, 0); }
//***************************************************************************** // // Print "Hello World!" to the display on the Intelligent Display Module. // //***************************************************************************** int main(void) { tContext sContext; uint32_t ui32SysClock; // // Run from the PLL at 120 MHz. // ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); // // Configure the device pins. // PinoutSet(); // // Initialize the display driver. // Kentec320x240x16_SSD2119Init(ui32SysClock); // // Initialize the graphics context. // GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119); // // Draw the application frame. // FrameDraw(&sContext, "hello"); // // Say hello using the Computer Modern 40 point font. // GrContextFontSet(&sContext, g_psFontCm40); GrStringDrawCentered(&sContext, "Hello World!", -1, GrContextDpyWidthGet(&sContext) / 2, ((GrContextDpyHeightGet(&sContext) - 32) / 2) + 24, 0); // // Flush any cached drawing operations. // GrFlush(&sContext); // // We are finished. Hang around doing nothing. // while(1) { } }
void main(void) { CAP_BUTTON keypressed_state; int countdownCount; State state = STATE_WELCOME; // Stop WDT WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer //Perform initializations (see peripherals.c) configTouchPadLEDs(); configDisplay(); configCapButtons(); GrClearDisplay(&g_sContext); GrStringDrawCentered(&g_sContext, "MSP430 H3R0", AUTO_STRING_LENGTH, 51, 32, TRANSPARENT_TEXT); GrFlush(&g_sContext); /* Monitor Capacitive Touch Pads in endless "forever" loop */ while(1) { switch(state) { case STATE_WELCOME: if(checkButtons() & BUTTON1) { state = STATE_COUNTDOWN; } break; case STATE_COUNTDOWN: centerText("3"); configLED1_3(BIT3); wait(COUNTDOWN_TIMER); centerText("2"); configLED1_3(BIT2); wait(COUNTDOWN_TIMER); centerText("1"); configLED1_3(BIT1); wait(COUNTDOWN_TIMER); centerText("GO!"); configLED1_3(BIT3 | BIT2 | BIT1); wait(COUNTDOWN_TIMER); //TODO: next state break; } } }
static void onDraw(tContext *pContext) { GrContextForegroundSet(pContext, ClrBlack); GrRectFill(pContext, &client_clip); GrContextForegroundSet(pContext, ClrWhite); GrContextFontSet(pContext, &g_sFontGothic18b); GrStringDrawCentered(pContext, "Firmware Upgrade", -1, 72, 60, 0); if (progress == PROGRESS_FINISH) GrStringDrawCentered(pContext, "Done", -1, 72, 96, 0); else if (progress == PROGRESS_TIMEOUT) GrStringDrawCentered(pContext, "Failed due to timeout", -1, 72, 96, 0); else GrStringDrawCentered(pContext, "Don't do any operation", -1, 72, 96, 0); if (progress == PROGRESS_FINISH) window_button(pContext, KEY_ENTER, "Reboot"); else if (progress == PROGRESS_TIMEOUT) window_button(pContext, KEY_ENTER, "Exit"); else window_progress(pContext, 110, progress); }
/* * Bounder set */ void Bounder_set(void) { // the whole boundler sRect.i16XMin = 0; sRect.i16YMin = 0; sRect.i16XMax = GrContextDpyWidthGet(&context) - 1; sRect.i16YMax = 239; GrContextForegroundSet(&context, ClrSeashell); GrRectFill(&context, &sRect); int i,j; for ( i = 0; i < 4; ++i) { for ( j = 0; j < 4; ++j) { sRect.i16XMin = 64+i*48 +1;//16 sRect.i16YMin = 24+j*48 +1;//64 sRect.i16XMax = 112+i*48 -1; sRect.i16YMax = 72+j*48 -1; GrContextForegroundSet(&context, ClrSkyBlue); GrRectFill(&context, &sRect); } } GrContextForegroundSet(&context, ClrSkyBlue); GrContextFontSet(&context, &g_sFontCm20); GrStringDrawCentered(&context, "Total 256", -1, GrContextDpyWidthGet(&context) / 2, 8, 0); GrContextFontSet(&context, &g_sFontCm20); GrStringDrawCentered(&context, "Project2 ^_^ Jack&Peter", -1, GrContextDpyWidthGet(&context) / 2, 225, 0); }
void window_button(tContext *pContext, uint8_t key, const char* text) { long forecolor, backcolor; if (key & 0x80) { forecolor = ClrBlack; backcolor = ClrWhite; key &= ~(0x80); } else { forecolor = ClrWhite; backcolor = ClrBlack; } GrContextFontSet(pContext, &g_sFontGothic18); // draw black box if (text) { const tRectangle *rect = &button_rect[key]; GrContextForegroundSet(pContext, forecolor); GrRectFill(pContext, rect); // draw triagle for(int i = 0; i <= (rect->sYMax - rect->sYMin) /2 ; i++) { if (rect->sXMin < 20) { GrLineDrawH(pContext, rect->sXMin - i, rect->sXMin, rect->sYMin + i); GrLineDrawH(pContext, rect->sXMin - i, rect->sXMin, rect->sYMax - i); } else { GrLineDrawH(pContext, rect->sXMax, rect->sXMax + i, rect->sYMin + i); GrLineDrawH(pContext, rect->sXMax, rect->sXMax + i, rect->sYMax - i); } } GrContextForegroundSet(pContext, backcolor); GrStringDrawCentered(pContext, text, -1, (rect->sXMin + rect->sXMax) /2, (rect->sYMin + rect->sYMax) /2, 0); } else { GrContextForegroundSet(pContext, backcolor); GrRectFill(pContext, &button_rect[key]); } }
//***************************************************************************** // // The function that is called when the help text canvas is painted to the // screen. // //***************************************************************************** static void OnPaint(tWidget *pWidget, tContext *pContext) { unsigned long ulIdx; tRectangle sRect; // // Prepare the drawing context. // GrContextForegroundSet(pContext, ClrWhite); GrContextFontSet(pContext, g_pFontFixed6x8); // // Loop through the ten lines of the display. // for(ulIdx = 0; ulIdx < 10; ulIdx++) { // // See if this line of help text is a heading. // if(g_ppcHelpText[g_ulDelta + ulIdx][0] == '\001') { // // Draw a shaded rectangle across this entire line of the display. // sRect.sXMin = 0; sRect.sYMin = (ulIdx * 8) + 16; sRect.sXMax = 127; sRect.sYMax = sRect.sYMin + 7; GrContextForegroundSet(pContext, ClrSelected); GrRectFill(pContext, &sRect); // // Draw this line of text centered on the display. // GrContextForegroundSet(pContext, ClrWhite); GrStringDrawCentered(pContext, g_ppcHelpText[g_ulDelta + ulIdx] + 1, -1, 63, (ulIdx * 8) + 19, 0); } else { // // Draw this line of text on the display. // GrStringDraw(pContext, g_ppcHelpText[g_ulDelta + ulIdx], -1, 0, (ulIdx * 8) + 16, 0); } } }
//***************************************************************************** // // Update one of the status boxes at the bottom of the screen. // //***************************************************************************** static void UpdateStatusBox(tRectangle *psRect, const char *pcString, bool bActive) { uint32_t ui32TextColor; // // Change the status box to green for active devices. // if(bActive) { GrContextForegroundSet(&g_sContext, ClrOrange); ui32TextColor = ClrBlack; } else { GrContextForegroundSet(&g_sContext, ClrBlack); ui32TextColor = ClrWhite; } // // Draw the background box. // GrRectFill(&g_sContext, psRect); // // Put a white box around the banner. // GrContextForegroundSet(&g_sContext, ClrWhite); // // Draw the box border. // GrRectDraw(&g_sContext, psRect); // // Put a white box around the banner. // GrContextForegroundSet(&g_sContext, ui32TextColor); // // Unknown device is currently connected. // GrStringDrawCentered(&g_sContext, pcString, -1, psRect->i16XMin + (BUTTON_WIDTH / 2), psRect->i16YMin + 8, false); }
//***************************************************************************** // // Initialize the display. This function is specific to the EK-LM4F232 board // and contains nothing directly relevant to the timer configuration or // operation. // //***************************************************************************** void InitDisplay(void) { tRectangle sRect; // // Initialize the display driver. // CFAL96x64x16Init(); // // Initialize the graphics context and find the middle X coordinate. // GrContextInit(&g_sContext, &g_sCFAL96x64x16); // // Fill the top part of the screen with blue to create the banner. // sRect.i16XMin = 0; sRect.i16YMin = 0; sRect.i16XMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.i16YMax = 9; GrContextForegroundSet(&g_sContext, ClrDarkBlue); GrRectFill(&g_sContext, &sRect); // // Change foreground for white text. // GrContextForegroundSet(&g_sContext, ClrWhite); // // Put the application name in the middle of the banner. // GrContextFontSet(&g_sContext, g_psFontFixed6x8); GrStringDrawCentered(&g_sContext, "edge-count", -1, GrContextDpyWidthGet(&g_sContext) / 2, 4, 0); // // Initialize timer status display. // GrContextFontSet(&g_sContext, g_psFontFixed6x8); GrStringDraw(&g_sContext, "Countdown:", -1, 8, 26, 0); GrStringDraw(&g_sContext, "Interrupts:", -1, 8, 36, 0); }