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); }
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); } } }
//***************************************************************************** // // Display the interrupt state on the CSTN. 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'; GrStringDraw(&g_sContext, pcBuffer, -1, 48, 32, 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' : ' '; GrStringDraw(&g_sContext, pcBuffer, -1, 48, 44, 1); // // Flush the display. // GrFlush(&g_sContext); }
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 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; } }
uint8_t test_motor(uint8_t ev, uint16_t lparam, void* rparam) { switch(ev) { case EVENT_WINDOW_CREATED: data = 0; break; case EVENT_KEY_PRESSED: { switch(lparam) { case KEY_UP: data++; if (data > 16) data = 1; break; case KEY_DOWN: data--; if (data == 0) data = 16; break; case KEY_ENTER: data = 0; break; } motor_on(data, 0); window_invalid(NULL); break; } case EVENT_WINDOW_PAINT: { char buf[32]; tContext *pContext = (tContext*)rparam; GrContextForegroundSet(pContext, ClrBlack); GrRectFill(pContext, &client_clip); GrContextForegroundSet(pContext, ClrWhite); GrContextFontSet(pContext, (tFont*)&g_sFontGothic18); GrStringDraw(pContext, "Test Motor", -1, 32, 50, 0); sprintf(buf, "Motor Level: %d", data); GrStringDraw(pContext, buf, -1, 5, 70, 0); window_button(pContext, KEY_UP, "+"); window_button(pContext, KEY_DOWN, "-"); window_button(pContext, KEY_ENTER, "Reset"); break; } case EVENT_EXIT_PRESSED: motor_on(0, 0); return 0; // return 0 to close the window default: return 0; } return 1; }
//***************************************************************************** // // Handles scrolling the text on the screen. // //***************************************************************************** static void ScrollText(void) { int32_t i32Idx; uint32_t ui32Line, ui32Start; ui32Line = 0; // // Skip the oldest entry in the circular list. // if(g_ui32CurrentLine == (MAX_LINES - 1)) { // // If at the end of the list wrap to entry 1. // ui32Start = 1; } else { // // The oldest is 1 in front of the most recent. // ui32Start = g_ui32CurrentLine + 2; } // // Print lines from the current position down first. // for(i32Idx = ui32Start; i32Idx < MAX_LINES; i32Idx++) { GrStringDraw(&g_sContext, g_ppcLines[i32Idx], strlen(g_ppcLines[i32Idx]), DISPLAY_TEXT_BORDER_H, DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER + (ui32Line * GrFontHeightGet(g_psFontFixed6x8)), 1); ui32Line++; } // // If not the special case of the last line where everything has already // printed, print the remaining lines. // if(g_ui32CurrentLine != (MAX_LINES - 1)) { for(i32Idx = 0; i32Idx <= g_ui32CurrentLine; i32Idx++) { GrStringDraw(&g_sContext, g_ppcLines[i32Idx], strlen(g_ppcLines[i32Idx]), DISPLAY_TEXT_BORDER_H, DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER + (ui32Line * GrFontHeightGet(g_psFontFixed6x8)), 1); ui32Line++; } } // // Reset the column to zero. // g_ui32Column = 0; }
//***************************************************************************** // // The main loop of the application. This implementation is specific to the // EK-LM4F232 board and merely displays the current timer count value and the // number of interrupts taken. It contains nothing directly relevant to the // timer configuration or operation. // //***************************************************************************** void MainLoopRun(void) { uint32_t ui32Count, ui32LastCount; // // Set up for the main loop. // ui32LastCount = 10; // // Loop forever while the timer runs. // while(1) { // // Get the current timer count. // ui32Count = ROM_TimerValueGet(TIMER4_BASE, TIMER_A); // // Has it changed? // if(ui32Count != ui32LastCount) { // // Yes - update the display. // usnprintf(g_pcPrintBuff, PRINT_BUFF_SIZE, "%d ", ui32Count); GrStringDraw(&g_sContext, g_pcPrintBuff, -1, 80, 26, true); // // Remember the new count value. // ui32LastCount = ui32Count; } // // Has there been an interrupt since last we checked? // if(HWREGBITW(&g_ui32Flags, 0)) { // // Clear the bit. // HWREGBITW(&g_ui32Flags, 0) = 0; // // Update the interrupt count. // usnprintf(g_pcPrintBuff, PRINT_BUFF_SIZE, "%d ", g_ui32IntCount); GrStringDraw(&g_sContext, g_pcPrintBuff, -1, 80, 36, true); } } }
//***************************************************************************** // // Handles paint requests for the introduction canvas widget. // //***************************************************************************** void OnIntroPaint(tWidget *psWidget, tContext *psContext) { // // Display the introduction text in the canvas. // GrContextFontSet(psContext, g_psFontCm16); GrContextForegroundSet(psContext, ClrSilver); GrStringDraw(psContext, "This application demonstrates the ", -1, 10, 30, 0); GrStringDraw(psContext, "TivaWare Graphics Library.", -1, 10, (30+16), 0); GrStringDraw(psContext, "Each panel shows a different feature of", -1, 10, (30+(16*2)), 0); GrStringDraw(psContext, "the graphics library. Widgets on the panels", -1, 10, (30+(16*3)), 0); GrStringDraw(psContext, "are fully operational; pressing them will", -1, 10, (30+(16*4)), 0); GrStringDraw(psContext, "result in visible feedback of some kind.", -1, 10, (30+(16*5)), 0); GrStringDraw(psContext, "Press the + and - buttons at the bottom", -1, 10, (30+(16*6)), 0); GrStringDraw(psContext, "of the screen to move between the panels.", -1, 10, (30+(16*7)), 0); }
int main(void) { SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ); Kentec320x240x16_SSD2119Init(); GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119); ClrScreen(); GrImageDraw(&sContext, g_pui8Image, 0, 0); GrFlush(&sContext); SysCtlDelay(SysCtlClockGet()); // Later lab steps go between here ClrScreen(); sRect.i16XMin = 1; sRect.i16YMin = 1; sRect.i16XMax = 318; sRect.i16YMax = 238; GrContextForegroundSet(&sContext, ClrRed); GrContextFontSet(&sContext, &g_sFontCmss30b); GrStringDraw(&sContext, "Texas", -1, 110, 2, 0); GrStringDraw(&sContext, "Instruments", -1, 80, 32, 0); GrStringDraw(&sContext, "Graphics", -1, 100, 62, 0); GrStringDraw(&sContext, "Lab", -1, 135, 92, 0); GrContextForegroundSet(&sContext, ClrWhite); GrRectDraw(&sContext, &sRect); GrFlush(&sContext); SysCtlDelay(SysCtlClockGet()); GrContextForegroundSet(&sContext, ClrYellow); GrCircleFill(&sContext, 80, 182, 50); sRect.i16XMin = 160; sRect.i16YMin = 132; sRect.i16XMax = 312; sRect.i16YMax = 232; GrContextForegroundSet(&sContext, ClrGreen); GrRectDraw(&sContext, &sRect); SysCtlDelay(SysCtlClockGet()); // and here ClrScreen(); while(1) { } }
static void drawItem(tContext *pContext, uint8_t n, char icon, const char* text, const char* value) { if (icon) { GrContextFontSet(pContext, (tFont*)&g_sFontExIcon16); GrStringDraw(pContext, &icon, 1, 3, 12 + n * LINEMARGIN, 0); } // draw text GrContextFontSet(pContext, &g_sFontGothic24b); GrStringDraw(pContext, text, -1, 20, 10 + n * LINEMARGIN, 0); uint8_t width = GrStringWidthGet(pContext, value, -1); GrStringDraw(pContext, value, -1, LCD_WIDTH - width - 4, 10 + n * LINEMARGIN, 0); }
//***************************************************************************** // // Handles paint requests for the firmware update canvas widget. // //***************************************************************************** void OnFirmwarePaint(tWidget *pWidget, tContext *pContext) { unsigned long ulLines; long lLineHeight, lOffset; lLineHeight = GrFontHeightGet(FONT_14PT); lOffset = 32; // // Display the firmware update instruction text in the canvas. // GrContextFontSet(pContext, FONT_14PT); GrContextForegroundSet(pContext, ClrSilver); GrStringGet(STR_UPDATE_TEXT, g_pcBuffer, SCOMP_MAX_STRLEN); ulLines = DrawStringWrapped(pContext, g_pcBuffer, lLineHeight, 1, lOffset, g_pLanguageTable[g_ulLangIdx].bBreakOnSpace ); // // Move down by 1/4 of a line. // lOffset += lLineHeight/4; // // Format the UART setting information string // GrStringGet(STR_UART, g_pcBuffer, SCOMP_MAX_STRLEN); GrStringDraw(pContext, g_pcBuffer, -1, 1, lOffset + (ulLines * lLineHeight), 0); }
/******************************************************************************* * @fn devpkLcdText * * @brief Write a text string to a specific line/column of the display * * @param str - text to apply * @param line - line index (0 .. 11) * @param col - column index (0 .. 15) * * @return true if success */ bool devpkLcdText(const char *str, uint8_t line, uint8_t col) { if (hLcdPin != NULL) { uint8_t xp, yp; Semaphore_pend(hSemLCD, BIOS_WAIT_FOREVER); xp = col * CHAR_WIDTH + 1; yp = line * CHAR_HEIGHT + 0; // Draw a text on the display GrStringDraw(&g_sContext, str, AUTO_STRING_LENGTH, xp, yp, OPAQUE_TEXT); GrFlush(&g_sContext); Semaphore_post(hSemLCD); } return hLcdPin != NULL; }
void output(int n,int (*drawArray)[10]){ static char pcCanvasText[5]; int i,j,color; 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; color = drawArray[i][j]%5; GrContextForegroundSet(&context, DrawColor[color]); GrRectFill(&context, &sRect); usprintf(pcCanvasText, "%3d", drawArray[i][j]); GrContextForegroundSet(&context, ClrBlack); GrContextFontSet(&context, &g_sFontCm20); GrStringDraw(&context, pcCanvasText, -1, 64+i*48 +1, 24+j*48 +16, 0); } } }
void lcdPutChar(char_t c) { if(c == '\r') { lcdColumn = 0; } else if(c == '\n') { lcdColumn = 0; lcdLine++; } else if(lcdLine < 26 && lcdColumn < 40) { char_t buffer[2]; buffer[0] = c; buffer[1] = '\0'; //Display current character GrStringDraw(&grContext, buffer, 1, lcdColumn * 6, lcdLine * 12, TRUE); //Advance the cursor position if(++lcdColumn >= 40) { lcdColumn = 0; lcdLine++; } } }
//***************************************************************************** // // Handles paint requests for the firmware update canvas widget. // //***************************************************************************** void OnFirmwarePaint(tWidget *pWidget, tContext *pContext) { // // Display the firmware update instruction text in the canvas. // GrContextFontSet(pContext, g_pFontCm18); GrContextForegroundSet(pContext, ClrSilver); GrStringDraw(pContext, "You may replace the software image", -1, 10, 32, 0); GrStringDraw(pContext, "flashed by pressing the \"Update\" button", -1, 10, 50, 0); GrStringDraw(pContext, "then using the LMFlash utility to send", -1, 10, 68, 0); GrStringDraw(pContext, "a new image via the serial interface.", -1, 10, 86, 0); }
uint8_t test_dut(uint8_t ev, uint16_t lparam, void* rparam) { //uint8_t buf[sizeof(HCI_VS_DRPb_Tester_Packet_TX_RX_Cmd)]; switch(ev) { case EVENT_WINDOW_CREATED: //bluetooth_enableDUTMode(); break; case EVENT_WINDOW_PAINT: { tContext *pContext = (tContext*)rparam; GrContextForegroundSet(pContext, ClrBlack); GrRectFill(pContext, &client_clip); GrContextForegroundSet(pContext, ClrWhite); GrContextFontSet(pContext, (tFont*)&g_sFontGothic18); GrStringDraw(pContext, "BT DUT mode is on", -1, 32, 50, 0); break; } default: return 0; } return 1; }
uint8_t test_mpu6050(uint8_t ev, uint16_t lparam, void* rparam) { switch(ev) { case EVENT_WINDOW_CREATED: data = mpu6050_selftest(); break; case EVENT_KEY_PRESSED: { if (lparam == KEY_ENTER) { data = mpu6050_selftest(); window_invalid(NULL); } break; } case EVENT_WINDOW_PAINT: { tContext *pContext = (tContext*)rparam; GrContextForegroundSet(pContext, ClrBlack); GrRectFill(pContext, &client_clip); GrContextForegroundSet(pContext, ClrWhite); GrContextFontSet(pContext, (tFont*)&g_sFontGothic18); if (data == 0) { GrStringDraw(pContext, "MPU6050 passed self testing", -1, 32, 50, 0); } else { GrStringDraw(pContext, "MPU6050 failed self testing", -1, 32, 50, 0); } GrStringDraw(pContext, "watch face up", -1, 32, 70, 0); window_button(pContext, KEY_ENTER, "Retest"); break; } default: return 0; } return 1; }
//***************************************************************************** // // 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); } }
//***************************************************************************** // // 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); }
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); }
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); }
uint8_t test_codec(uint8_t ev, uint16_t lparam, void* rparam) { switch(ev) { case EVENT_WINDOW_CREATED: codec_wakeup(); hci_send_cmd(&hci_vs_set_pcm_loopback_enable, 1); break; case EVENT_WINDOW_PAINT: { tContext *pContext = (tContext*)rparam; GrContextForegroundSet(pContext, ClrBlack); GrRectFill(pContext, &client_clip); GrContextForegroundSet(pContext, ClrWhite); GrContextFontSet(pContext, (tFont*)&g_sFontGothic18); GrStringDraw(pContext, "Speaker is looping back to mic", -1, 0, 50, 0); window_volume(pContext, 30, 125, 8, codec_getvolume()); window_button(pContext, KEY_UP, "+"); window_button(pContext, KEY_DOWN, "-"); break; } case EVENT_KEY_PRESSED: switch(lparam) { case KEY_UP: { codec_changevolume(+1); break; } case KEY_DOWN: { // decrease voice codec_changevolume(-1); break; } } window_invalid(NULL); break; case EVENT_EXIT_PRESSED: hci_send_cmd(&hci_vs_set_pcm_loopback_enable, 1); codec_suspend(); return 0; // return 0 to close the window default: return 0; } return 1; }
static void drawItem(tContext *pContext, uint8_t n, char icon, const char* text, const char* value) { if (icon) { #if defined(PRODUCT_W002) || defined(PRODUCT_W004) GrContextFontSet(pContext, (tFont*)&g_sFontExIcons32); GrStringDraw(pContext, &icon, 1, 12, 21 + n * LINEMARGIN, 0); #else GrContextFontSet(pContext, (tFont*)&g_sFontExIcon16); GrStringDraw(pContext, &icon, 1, 3, 12 + n * LINEMARGIN, 0); #endif } // draw text #if defined(PRODUCT_W002) || defined(PRODUCT_W004) GrContextFontSet(pContext, &g_sFontBaby16); GrStringDraw(pContext, text, -1, 57, 24 + n * LINEMARGIN, 0); uint8_t width = GrStringWidthGet(pContext, value, -1); GrStringDraw(pContext, value, -1, 57, 39 + n * LINEMARGIN, 0); #else GrContextFontSet(pContext, &g_sFontGothic24b); GrStringDraw(pContext, text, -1, 20, 10 + n * LINEMARGIN, 0); uint8_t width = GrStringWidthGet(pContext, value, -1); GrStringDraw(pContext, value, -1, LCD_WIDTH - width - 4, 10 + n * LINEMARGIN, 0); #endif }
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); }
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); }
//***************************************************************************** // // 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); } } }
//***************************************************************************** // // 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); } }
void window_selecttext(tContext *pContext, const char* pcString, long lLength, long lX, long lY) { int height = GrStringHeightGet(pContext); int width, textwidth; if (lLength == -1) { width = GrStringWidthGet(pContext, pcString, lLength); textwidth = width; } else { char data = '8'; width = GrStringWidthGet(pContext, &data, 1) * lLength; textwidth = GrStringWidthGet(pContext, pcString, lLength); } tRectangle rect = {lX - 2, lY - 2, lX + width + 2, lY + height + 2}; GrContextForegroundSet(pContext, ClrWhite); #if defined(PRODUCT_W002) || defined(PRODUCT_W004) GrRectFillRound(pContext, &rect, 0); #else GrRectFillRound(pContext, &rect, 3); #endif GrContextForegroundSet(pContext, ClrBlack); GrStringDraw(pContext, pcString, lLength, lX + (width - textwidth)/2, lY, 0); GrContextForegroundSet(pContext, ClrWhite); #if defined(PRODUCT_W002) || defined(PRODUCT_W004) #else // there is something more long x = lX + width/2; long y0 = lY - 5 - 6; long y1 = lY + height + 5 + 6; for(int i = 0; i < 6; i++) { GrLineDrawH(pContext, x - i, x + i, y1 - i); GrLineDrawH(pContext, x - i, x + i, y0 + i); } #endif }
void output(int n,int (*drawArray)[10]) { int i,j; static char pcCanvasText[5]; GrContextForegroundSet(&context, ClrSilver); GrContextFontSet(&context, &g_sFontCm20); for ( i = 0; i < 4; ++i) { for ( j = 0; j < 4; ++j) { // printf("%d",drawArray[i][j]); usprintf(pcCanvasText, "%3d", drawArray[i][j]); GrStringDraw(&context, pcCanvasText, -1, 64+i*48 +1, 24+j*48 +1, 0); } } }