void renderLCDFrame(void) { // Clear the screen drawFill(COLOR_DARKGRAY); // Render V references fontsDrawString(245, 27, COLOR_BLACK, &dejaVuSansBold9ptFontInfo, "3.5V"); fontsDrawString(244, 26, COLOR_WHITE, &dejaVuSansBold9ptFontInfo, "3.5V"); fontsDrawString(245, 195, COLOR_BLACK, &dejaVuSansBold9ptFontInfo, "0.0V"); fontsDrawString(244, 194, COLOR_WHITE, &dejaVuSansBold9ptFontInfo, "0.0V"); // Div settings fontsDrawString( 10, 10, COLOR_BLACK, &dejaVuSansBold9ptFontInfo, "~100ms/Div"); fontsDrawString( 9, 9, COLOR_WHITE, &dejaVuSansBold9ptFontInfo, "~100ms/Div"); fontsDrawString( 95, 10, COLOR_BLACK, &dejaVuSansBold9ptFontInfo, "500mV/Div"); fontsDrawString( 94, 9, COLOR_WHITE, &dejaVuSansBold9ptFontInfo, "500mV/Div"); // Clear the ADC output level just in case drawRectangleFilled(175, 5, 250, 18, COLOR_DARKGRAY); // Render the channel text fontsDrawString( 25, 220, COLOR_BLACK, &dejaVuSansBold9ptFontInfo, "P1.4 (Analog)"); fontsDrawString( 24, 219, adcEnabled ? COLOR_YELLOW : COLOR_MEDIUMGRAY, &dejaVuSansBold9ptFontInfo, "P1.4 (Analog)"); fontsDrawString(135, 220, COLOR_BLACK, &dejaVuSansBold9ptFontInfo, "P2.0 (Digital)"); fontsDrawString(134, 219, digEnabled ? COLOR_GREEN : COLOR_MEDIUMGRAY, &dejaVuSansBold9ptFontInfo, "P2.0 (Digital)"); // ADC Warning fontsDrawString(245, 80, COLOR_BLACK, &dejaVuSansBold9ptFontInfo, "Warning:"); fontsDrawString(244, 79, COLOR_WHITE, &dejaVuSansBold9ptFontInfo, "Warning:"); fontsDrawString(244, 95, COLOR_WHITE, &dejaVuSans9ptFontInfo, "ADC input"); fontsDrawString(244, 110, COLOR_WHITE, &dejaVuSans9ptFontInfo, "is not 5.0V"); fontsDrawString(244, 125, COLOR_WHITE, &dejaVuSans9ptFontInfo, "tolerant!"); }
void main_page_msg(enum main_page_msg message) { drawRectangleFilled(10, 235, 230, 310, COLOR_BLUE); switch (message) { case MSG_UNSTABLE : { drawString(40, 235, COLOR_YELLOW, &verdanabold14ptFontInfo, "stabilising sensor"); break; } case MSG_STABLE : { drawString(10, 235, COLOR_YELLOW, &verdanabold14ptFontInfo, "sensor ready for use"); break; } case MSG_BLOW_PREPARE : { drawString(10, 235, COLOR_YELLOW, &verdanabold14ptFontInfo, "Be ready to blow after"); drawString(10, 262, COLOR_YELLOW, &verdanabold14ptFontInfo, "beep, stop after"); drawString(10, 289, COLOR_YELLOW, &verdanabold14ptFontInfo, "second beep"); break; } case MSG_BLOW_START : { drawString(10, 235, COLOR_YELLOW, &verdanabold14ptFontInfo, "Start blowing gently"); drawString(10, 262, COLOR_YELLOW, &verdanabold14ptFontInfo, "into the device"); break; } case MSG_BLOW_STOP : { drawString(10, 235, COLOR_YELLOW, &verdanabold14ptFontInfo, "Stop blowing"); break; } default : { ; } } }
void alphaRefreshScreen(void) { uint8_t x, y; /* Draw keypad */ for (y = 0; y < 6; y++) { for (x = 0; x < 5; x++) { alphaRenderButton(alphaPage, x, y, false); } } /* Render Text */ drawRectangleFilled(0, 0, lcdGetWidth() - 1, ALPHA_KEYPAD_TOP - (ALPHA_BTN_SPACING * 2), 0xFFFF); drawString(ALPHA_BTN_SPACING, ALPHA_BTN_SPACING, COLOR_BLACK, &dejaVuSans9ptFontInfo, (char *)&alphaString); }
void main_page_res(struct main_page_res * values) { char r0[16]; char rmax[16]; char rmin[16]; snprintf(r0, sizeof(r0), "%3.4f", (double)values->r0); snprintf(rmax, sizeof(rmax), "%3.4f", (double)values->rmax); snprintf(rmin, sizeof(rmin), "%3.4f", (double)values->rmin); drawRectangleFilled(10, 210, 230, 220, COLOR_BLUE); drawString(11, 210, COLOR_CYAN, &dejaVuSansBold9ptFontInfo, "Rmax: Rmin: "); drawString(53, 210, COLOR_WHITE, &dejaVuSansBold9ptFontInfo, rmax); drawString(160, 210, COLOR_WHITE, &dejaVuSansBold9ptFontInfo, rmin); drawString(100, 220, COLOR_CYAN, &dejaVuSansBold9ptFontInfo, "Ro: "); drawString(125, 220, COLOR_WHITE, &dejaVuSansBold9ptFontInfo, r0); }
void main_page_overview(struct main_page_overview * values) { char resistance[16]; char voltage[16]; char current[16]; char temperature[16]; if (values->resistance < 0.0) { snprintf(resistance, sizeof(resistance), "N/A"); } else { snprintf(resistance, sizeof(resistance), "%03.4f", (double)values->resistance); } snprintf(voltage, sizeof(voltage), "%03.3f", (double)values->voltage); snprintf(current, sizeof(current), "%03.3f", (double)values->current); snprintf(temperature, sizeof(temperature), "%03.3f", (double)values->temperature); drawRectangleFilled(170, 120, 240, 190, COLOR_BLUE); drawString(170, 120, COLOR_WHITE, &dejaVuSansBold9ptFontInfo, resistance); drawString(170, 140, COLOR_WHITE, &dejaVuSansBold9ptFontInfo, voltage); drawString(170, 160, COLOR_WHITE, &dejaVuSansBold9ptFontInfo, current); drawString(170, 180, COLOR_WHITE, &dejaVuSansBold9ptFontInfo, temperature); }
char* alphaShowDialogue(void) { char result; /* These need to be instantiated here since the width and height of the lcd is retrieved dynamically depending on screen orientation */ alphaBtnX[0] = ALPHA_COL1_LEFT; alphaBtnX[1] = ALPHA_COL2_LEFT; alphaBtnX[2] = ALPHA_COL3_LEFT; alphaBtnX[3] = ALPHA_COL4_LEFT; alphaBtnX[4] = ALPHA_COL5_LEFT; alphaBtnY[0] = ALPHA_ROW1_TOP; alphaBtnY[1] = ALPHA_ROW2_TOP; alphaBtnY[2] = ALPHA_ROW3_TOP; alphaBtnY[3] = ALPHA_ROW4_TOP; alphaBtnY[4] = ALPHA_ROW5_TOP; alphaBtnY[5] = ALPHA_ROW6_TOP; /* Initialise the string buffer */ memset(&alphaString[0], 0, sizeof(alphaString)); alphaString_ptr = alphaString; alphaPage = 0; /* Draw the background and render the buttons */ drawFill(COLOR_WHITE); drawRectangleFilled(0, ALPHA_KEYPAD_TOP - ALPHA_BTN_SPACING, lcdGetWidth() - 1, lcdGetHeight() - 1, COLOR_DARKGRAY); drawLine(0, (ALPHA_KEYPAD_TOP - ALPHA_BTN_SPACING) + 1, lcdGetWidth() - 1, (ALPHA_KEYPAD_TOP - ALPHA_BTN_SPACING) + 1, COLOR_LIGHTGRAY); alphaRefreshScreen(); /* Capture results until the 'OK' button is pressed */ while(1) { result = alphaHandleTouchEvent(); if (result == '>') return (char *)&alphaString; } }
void renderLCDGrid(void) { if ((!adcEnabled) && (!digEnabled)) { return; } // Redraw the grid drawRectangle(9, 24, 236, 201, COLOR_LIGHTGRAY); drawRectangleFilled(10, 25, 235, 200, COLOR_BLACK); // Horizontal lines drawLine(10, 50, 235, 50, COLOR_DARKERGRAY); drawLine(10, 75, 235, 75, COLOR_DARKERGRAY); drawLine(10, 100, 235, 100, COLOR_DARKERGRAY); drawLine(10, 125, 235, 125, COLOR_DARKERGRAY); drawLine(10, 150, 235, 150, COLOR_DARKERGRAY); drawLine(10, 175, 235, 175, COLOR_DARKERGRAY); // Vertical lines drawLine( 35, 25, 35, 200, COLOR_DARKERGRAY); drawLine( 60, 25, 60, 200, COLOR_DARKERGRAY); drawLine( 85, 25, 85, 200, COLOR_DARKERGRAY); drawLine(110, 25, 110, 200, COLOR_DARKERGRAY); drawLine(135, 25, 135, 200, COLOR_DARKERGRAY); drawLine(160, 25, 160, 200, COLOR_DARKERGRAY); drawLine(185, 25, 185, 200, COLOR_DARKERGRAY); drawLine(210, 25, 210, 200, COLOR_DARKERGRAY); // Render the individual data points uint32_t counter; for (counter = 0; counter < 9; counter++) { // Draw historical data uint32_t arrayPosition = 9 - counter; // Draw analog data points (Yellow) if (adcEnabled) { drawLine(10 + counter * 25, adcValToPixel(adcBuffer[arrayPosition]), 10 + (counter + 1) * 25, adcValToPixel(adcBuffer[arrayPosition - 1]), COLOR_YELLOW); } // Draw digital data points (Green) if (digEnabled) { drawLine(10 + counter * 25, adcValToPixel(digBuffer[arrayPosition]), 10 + (counter + 1) * 25, adcValToPixel(digBuffer[arrayPosition - 1]), COLOR_GREEN); } } // Render ADC value in text if present if (adcEnabled) { char text[10]; // Assuming 3.3V supply and 8-bit ADC values, 1 unit = 12.89mV (3300/256) sprintf(text, "%u.%u V", ((adcBuffer[0] * 1289) / 100) / 1000, ((adcBuffer[0] * 1294) / 100) % 1000); // Clear the previous text drawRectangleFilled(175, 5, 250, 18, COLOR_DARKGRAY); // Render the latest value in mV fontsDrawString(180, 10, COLOR_BLACK, &dejaVuSansBold9ptFontInfo, text); fontsDrawString(179, 9, COLOR_YELLOW, &dejaVuSansBold9ptFontInfo, text); } }