static void showTouches_Draw(GL_PageControls_TypeDef* pThis, _Bool force) { if (!force) { return; } // Clear screen GL_Clear(LCD_COLOR_YELLOW); // Draw title & directions GL_SetFont(GL_FONTOPTION_16x24); GL_SetTextColor(LCD_COLOR_NAVY); GL_PrintString(10, TITLE_TOP, "Check Calibration", 1); GL_SetTextColor(LCD_COLOR_BLACK); GL_SetFont(GL_FONTOPTION_8x12Bold); GL_PrintString(10, DIRECTIONS_TOP, "Tap screen to test touch-screen", 1); GL_PrintString(10, DIRECTIONS_TOP + 12, "calibration and display marker.", 1); GL_SetTextColor(LCD_COLOR_BLUE); GL_PrintString(10, DIRECTIONS_TOP + 30, "Tap same location 3 times to quit.", 1); // Do we have a value to display if (s_haveTouch) { GL_PrintString(30, DISPLAY_TOP, "Coordinates read:", 1); char buf[15]; sprintf(buf, "X Coord: %3d", s_lastTouchX); GL_PrintString(30, DISPLAY_TOP + 12, buf, 1); sprintf(buf, "Y Coord: %3d", s_lastTouchY); GL_PrintString(30, DISPLAY_TOP + 24, buf, 1); // Draw cross hairs GL_SetTextColor(LCD_COLOR_NAVY); GL_DrawLine(s_lastTouchX - TOUCH_POINT_RADIUS, s_lastTouchY, TOUCH_POINT_RADIUS * 2, LCD_WriteRAMDir_Right); GL_DrawLine(s_lastTouchX, s_lastTouchY - TOUCH_POINT_RADIUS, TOUCH_POINT_RADIUS * 2, LCD_WriteRAMDir_Down); } }
static void calibration_Draw(GL_PageControls_TypeDef* pThis, _Bool force) { if (!force) { return; } // Clear screen GL_Clear(LCD_COLOR_GREY); // Draw title & directions GL_SetFont(GL_FONTOPTION_16x24); GL_SetTextColor(LCD_COLOR_NAVY); GL_PrintString(10, TITLE_TOP, "Calibration Screen", 1); GL_SetFont(GL_FONTOPTION_8x12Bold); // Are we still getting user input? if (currentTouchPoint < TS_NUM_CALIBRATION_POINTS) { GL_PrintString(40, DIRECTIONS_TOP, "Tap the center of the + ...", 1); // Draw cross hairs uint16_t x, y; TS_GetCalibrationTarget(currentTouchPoint, &x, &y); GL_SetTextColor(LCD_COLOR_NAVY); GL_DrawLine(x - TOUCH_POINT_RADIUS, y, TOUCH_POINT_RADIUS * 2, LCD_WriteRAMDir_Right); GL_DrawLine(x, y - TOUCH_POINT_RADIUS, TOUCH_POINT_RADIUS * 2, LCD_WriteRAMDir_Down); } else { // Draw finished directions // (Unused if advancing to other screen immediately) GL_PrintString(40, DIRECTIONS_TOP, "Calibration complete.", 1); GL_PrintString(30, DONE_TOP, "Tap screen to continue", 1); } }
static void insideDrawHandler(GL_PageControls_TypeDef* pThis, _Bool force, int relX, int relY) { // Setup impossible values (at least for the idx) static UserModeType previousUserMode = -1; static int16_t previousRxTx = -1; UserModeType curUserMode = Mode_GetCurrentUserMode(); int16_t curRxTx = RxTx_InTxMode(); // Redraw only when needed: _Bool redrawUserMode = force || curUserMode != previousUserMode; _Bool redrawRxTx = force || curRxTx != previousRxTx; // Draw the user mode if (redrawUserMode) { GL_SetFont(GL_FONTOPTION_8x12Bold); GL_SetTextColor(BIGBUTTON_COLOR_NORMAL_TEXT); GL_SetBackColor(BIGBUTTON_COLOR_NORMAL_BACK); int writeX = relX + OFFSETX_TEXT; int writeY = relY + OFFSETY_MODE; GL_PrintString(writeX, writeY, Mode_GetCurrentUserModeName(), 0); previousUserMode = curUserMode; } // Draw Rx/Tx if (redrawRxTx) { GL_SetFont(GL_FONTOPTION_8x12Bold); int writeX = relX + OFFSETX_TEXT; int writeY = relY + OFFSETY_RXTX; if (RxTx_InRxMode()) { GL_SetBackColor(LCD_COLOR_GREEN); GL_SetTextColor(LCD_COLOR_BLACK); GL_PrintString(writeX, writeY, " RX ", 0); } else { GL_SetBackColor(LCD_COLOR_RED); GL_SetTextColor(LCD_COLOR_WHITE); GL_PrintString(writeX, writeY, " TX ", 0); } previousRxTx = curRxTx; } }
/** * @brief update the graphics of the selected group window * @param group: selected group * @retval None */ static void GL_UpdateGroupSelectionLabel (uint8_t group) { GL_SetFont(GL_FONT_SMALL); switch ( group) { case CONNECTIVITY_GROUP : GL_SetTextColor(GL_Yellow); GL_DisplayAdjStringLine(40 + BF_XSIZE - 1, 310, (uint8_t *)" Connect.", GL_TRUE); GL_SetTextColor(GL_White); GL_DisplayAdjStringLine(103 + BF_XSIZE - 1, 316, (uint8_t *)"Multimedia", GL_TRUE); GL_DisplayAdjStringLine(166 + BF_XSIZE - 1, 310, (uint8_t *)"Utilities", GL_TRUE); break; case MULTIMEDIA_GROUP : GL_SetTextColor(GL_Yellow); GL_DisplayAdjStringLine(103 + BF_XSIZE - 1, 316, (uint8_t *)"Multimedia", GL_TRUE); GL_SetTextColor(GL_White); GL_DisplayAdjStringLine(40 + BF_XSIZE - 1, 310, (uint8_t *)" Connect.", GL_TRUE); GL_DisplayAdjStringLine(166 + BF_XSIZE - 1, 310, (uint8_t *)"Utilities", GL_TRUE); break; case UTILITIES_GROUP : GL_SetTextColor(GL_Yellow); GL_DisplayAdjStringLine(166 + BF_XSIZE - 1, 310, (uint8_t *)"Utilities", GL_TRUE); GL_SetTextColor(GL_White); GL_DisplayAdjStringLine(103 + BF_XSIZE - 1, 316, (uint8_t *)"Multimedia", GL_TRUE); GL_DisplayAdjStringLine(40 + BF_XSIZE - 1, 310, (uint8_t *)" Connect.", GL_TRUE); break; default : break; } }
static void drawHandler(GL_PageControls_TypeDef* pThis, _Bool force) { LabelData *pInstData = getInstDataFromPageCtrl(pThis); // Check if a call to Widget_ChangeLabelText() has happened: _Bool change = 0; // Allow code to update itself (via an update handler, if any). if (pInstData->pUpdateHandler != 0) { change |= pInstData->pUpdateHandler(pThis, force); } change |= pInstData->isRedrawRequired; int x = pThis->objCoordinates.MinX; int y = pThis->objCoordinates.MinY; // Redraw? if (force || change) { GL_SetTextColor(pInstData->textColor); GL_SetBackColor(pInstData->backColor); GL_SetFont(pInstData->font); GL_PrintString(x, y, pInstData->strText, pInstData->isTransparent); } pInstData->isRedrawRequired = 0; }
static void displayAGCVariables(int RSL) { // Display AGC Variables for Testing / Troubleshooting //GL_SetTextColor(LCD_COLOR_RED); //GL_SetBackColor(LCD_COLOR_BLACK); //char test2[7]; //intToCommaString((int)AGC_Mag, test2, 7); //GL_PrintString(75, 80, test2, 0); GL_SetFont(GL_FONTOPTION_8x16); GL_SetTextColor(LCD_COLOR_RED); GL_SetBackColor(LCD_COLOR_BLACK); char test3[3]; intToCommaString(PGAGain, test3, 3); GL_PrintString(110, 80, test3, 0); GL_SetTextColor(LCD_COLOR_RED); GL_SetBackColor(LCD_COLOR_BLACK); char test4[5]; intToCommaString(AGC_Signal, test4, 5); GL_PrintString(180, 80, test4, 0); GL_SetTextColor(LCD_COLOR_RED); GL_SetBackColor(LCD_COLOR_BLACK); char test5[5]; intToCommaString(RSL, test5, 5); GL_PrintString(277, 80, test5, 0); }
static void displayFrequencyOffsetText(_Bool force) { // Update the frequency offset displayed (text): static double oldSelectedFreq = -1; static double old_m_SQOpen = -1; if (force || oldSelectedFreq != NCO_Frequency || old_m_SQOpen != m_SQOpen) { oldSelectedFreq = NCO_Frequency; old_m_SQOpen = m_SQOpen; int textY = FFT_HEIGHT - 18; int numberX = 4 * CHARACTER_WIDTH; int labelX = 1; GL_SetFont(GL_FONTOPTION_8x16); GL_SetBackColor(LCD_COLOR_BLACK); GL_SetTextColor(LCD_COLOR_WHITE); GL_PrintString(labelX, textY, "AF", 0); // Display location on label. if (m_SQOpen == 0) GL_SetTextColor(LCD_COLOR_RED); else GL_SetTextColor(LCD_COLOR_GREEN); char number[MAX_FREQ_DIGITS + 1]; intToCommaString((int) NCO_Frequency, number, MAX_FREQ_DIGITS + 1); GL_PrintString(numberX, textY, number, 0); } }
static void insideDrawHandler(GL_PageControls_TypeDef* pThis, _Bool force, int relX, int relY) { // Setup impossible values (as much as possible static BandPreset previousBand = -1; static uint32_t previousFreq = -1; static uint32_t previousStep = -1; BandPreset curBand = FrequencyManager_GetSelectedBand(); uint32_t curFreq = FrequencyManager_GetCurrentFrequency(); uint32_t curStep = FrequencyManager_GetFrequencyStepSize(); // Redraw only when needed: _Bool redrawBand = force || curBand != previousBand; _Bool redrawFreq = force || curFreq != previousFreq || curStep != previousStep; // Draw the band if (redrawBand) { GL_SetFont(GL_FONTOPTION_8x12Bold); GL_SetTextColor(BIGBUTTON_COLOR_NORMAL_TEXT); GL_SetBackColor(BIGBUTTON_COLOR_NORMAL_BACK); int writeX = relX + OFFSETX_TEXT; int writeY = relY + OFFSETY_BAND; GL_PrintString(writeX, writeY, FrequencyManager_GetBandName(FrequencyManager_GetSelectedBand()), 0); previousBand = curBand; } // Draw the Frequency if (redrawFreq) { GL_SetFont(GL_FONTOPTION_8x12Bold); GL_SetTextColor(BIGBUTTON_COLOR_EDIT_TEXT); GL_SetBackColor(BIGBUTTON_COLOR_EDIT_BACK); int writeX = relX + OFFSETX_TEXT; int writeY = relY + OFFSETY_FREQ; displayFrequency(FrequencyManager_GetCurrentFrequency(), writeX, writeY, FrequencyManager_GetFrequencyStepSize()); previousFreq = curFreq; previousStep = curStep; } }
/** * @brief Error callback function * @param None * @retval None */ void vApplicationMallocFailedHook( void ) { char temp[128]; GL_Clear(Black); GL_SetTextColor(GL_White); GL_SetFont(GL_FONT_SMALL); sprintf(temp, "Actual heap size : %d Bytes" , (int)xPortGetFreeHeapSize() ); GL_DisplayAdjStringLine(214, 310, (uint8_t *)"[Memory Error]", GL_TRUE); GL_DisplayAdjStringLine(227, 310, (uint8_t *)temp, GL_TRUE); while (1) {} }
static void insideDrawHandler(GL_PageControls_TypeDef* pThis, _Bool force, int relX, int relY) { // Setup impossible values (at least for the idx) static int lastOptIdx = -1; static int16_t lastOptValue = -30215; // Random-ish number int selOptIdx = Options_GetSelectedOption(); int16_t value = Options_GetValue(selOptIdx); // Redraw only when needed: _Bool redrawName = force || selOptIdx != lastOptIdx; _Bool redrawValue = force || redrawName || lastOptValue != value; // Change name display if (redrawName) { GL_SetFont(GL_FONTOPTION_8x12Bold); GL_SetTextColor(BIGBUTTON_COLOR_NORMAL_TEXT); GL_SetBackColor(BIGBUTTON_COLOR_NORMAL_BACK); GL_PrintString(relX + OFFSETX_OPTION, relY + OFFSETY_OPTION, Options_GetName(selOptIdx), 0); lastOptIdx = selOptIdx; } // Change value display if (redrawValue) { #define MAX_LEN 10 char numberStr[MAX_LEN]; intToCommaString(value, numberStr, MAX_LEN); GL_SetFont(GL_FONTOPTION_8x12Bold); GL_SetTextColor(BIGBUTTON_COLOR_EDIT_TEXT); GL_SetBackColor(BIGBUTTON_COLOR_EDIT_BACK); GL_PrintString(relX + OFFSETX_VALUE, relY + OFFSETY_VALUE, numberStr, 0); lastOptValue = value; } }
/** * @brief Background main window custom draw callback * @param None * @retval None */ static void DrawBackgroundZone (void) { LCD_SetTextColor(0x1253); GL_LCD_FillRect(38, 319, 202, 75); GL_LCD_FillRect(0, 319, 38, 320); LCD_SetTextColor(GL_Black); LCD_DrawLine(40, 243,200,Vertical); LCD_DrawLine(39, 244, 245,Horizontal); LCD_DrawLine(39, 320, 75,Horizontal); LCD_SetTextColor(GL_Grey); LCD_DrawLine(39, 244,201,Vertical); LCD_DrawLine(38, 244, 245,Horizontal); LCD_DrawLine(38, 320, 75,Horizontal); GL_SetTextColor(GL_White); GL_SetFont(GL_FONT_SMALL); GL_UpdateGroupSelectionLabel (GL_Group); GL_DisplayAdjStringLine(10 , 250, (uint8_t *)"STM32 Demonstration builder", GL_TRUE); }
void GL_TestDisplayScreen(void) { #if 0 LCD_Clear(LCD_COLOR_BLUE); /* * Test fonts */ _Bool isTransparent = 1; GL_SetBackColor(LCD_COLOR_DGREEN); GL_SetTextColor(LCD_COLOR_YELLOW); GL_SetFont(GL_FONTOPTION_16x24); GL_PrintString(10, 10, "|/-\\ Hello World! abc&ABC", isTransparent); GL_SetFont(GL_FONTOPTION_12x12); GL_PrintString(10, 60, "|/-\\ Hello World! abc&ABC", isTransparent); GL_SetFont(GL_FONTOPTION_8x12); GL_PrintString(10, 100, "|/-\\ Hello World! abc&ABC", isTransparent); GL_SetFont(GL_FONTOPTION_8x12Bold); GL_PrintString(10, 140, "|/-\\ Hello World! abc&ABC", isTransparent); GL_SetFont(GL_FONTOPTION_8x16); GL_PrintString(10, 160, "|/-\\ Hello World! abc&ABC", isTransparent); GL_SetFont(GL_FONTOPTION_8x8); GL_PrintString(10, 200, "|/-\\ Hello World! abc&ABC", isTransparent); volatile int a = 0; while (1) a ++; #endif }
static void WidgetFFT_DrawHandler(GL_PageControls_TypeDef* pThis, _Bool force) { // Bail if nothing to draw. if (!force && !DSP_Flag) { return; } int x = pThis->objCoordinates.MinX; int y = pThis->objCoordinates.MinY; /* * Calculate the data to draw: * - Use FFT_Magnitude[0..127] which is 0 to +4kHz of frequency * (don't use last half which is -4kHz to 0kHz) * - Scale the values up to fill a wider portion of the display. * (by averaging with neighboring data). This helps allow the * user to tap on frequencies to select them with better resolution. * - Average with "old" data from the previous pass to give it an * effective time-based smoothing (as in, display does not change * as abruptly as it would when using new data samples each time). */ //uint8_t FFT_Display[256]; static uint8_t FFT_Output[128]; // static because use last rounds data now. // TODO: Where are all these FFT constants from? for (int16_t j = 0; j < 128; j++) { // Changed for getting right display with SR6.3 // Convert from Q15 (fractional numeric representation) into integer FFT_Output[j] = (uint8_t) (6 * log((float32_t) (FFT_Magnitude[j] + 1))); if (FFT_Output[j] > 64) FFT_Output[j] = 64; FFT_Display[2 * j] = FFT_Output[j]; // Note that calculation uses values from last pass through. FFT_Display[2 * j + 1] = 0; //FFT_Display[2 * j + 1] = (FFT_Output[j] + FFT_Output[j + 1]) / 2; } /* * Display the FFT * - Drop the bottom 8, and top 8 frequency-display bins to discard * noisy sections near band edges due to filtering. */ float selectedFreqX = (float) (NCO_Frequency - 125) / 15.625; if (selectedFreqX < 0) { selectedFreqX = 0; } // Draw the FFT using direct memory writes (fast). LCD_SetDisplayWindow(x, y, FFT_HEIGHT, FFT_WIDTH); LCD_WriteRAM_PrepareDir(LCD_WriteRAMDir_Down); for (int x = 0; x < FFT_WIDTH; x++) { // Plot this column of the FFT. for (int y = 0; y < FFT_HEIGHT; y++) { // Draw red line for selected frequency if (x == (int) selectedFreqX) { // Leave some white at the top if (y <= SELFREQ_ADJ) { LCD_WriteRAM(LCD_COLOR_WHITE); } else { LCD_WriteRAM(LCD_COLOR_RED); } } // Draw data else if (FFT_HEIGHT - y < FFT_Display[x + 8]) { LCD_WriteRAM(LCD_COLOR_BLUE); } // Draw background else { LCD_WriteRAM(LCD_COLOR_WHITE); } } } // Update the frequency offset displayed (text): static double oldSelectedFreq = -1; if (force || oldSelectedFreq != NCO_Frequency) { oldSelectedFreq = NCO_Frequency; int textY = y + FFT_HEIGHT + TEXT_OFFSET_BELOW_FFT; int numberX = x + FFT_WIDTH - MAX_FREQ_DIGITS * CHARACTER_WIDTH; int labelX = numberX - CHARACTER_WIDTH * 8; // 7=# letters in label w/ a space GL_SetFont(GL_FONTOPTION_8x16); GL_SetBackColor(LCD_COLOR_BLACK); GL_SetTextColor(LCD_COLOR_WHITE); GL_PrintString(labelX, textY, "Offset:", 0); // Display location on label. GL_SetTextColor(LCD_COLOR_RED); char number[MAX_FREQ_DIGITS + 1]; intToCommaString((int)NCO_Frequency, number, MAX_FREQ_DIGITS + 1); GL_PrintString(numberX, textY, number, 0); } DSP_Flag = 0; // added per Charley }
static void drawHandler(GL_PageControls_TypeDef* pThis, _Bool force) { // Setup unlikely values to start static uint32_t lastOnAirHash = 0; static uint32_t lastTxHash = 0; static uint32_t lastKeyboardHash = 0; static uint32_t lastCallHash = 0; static uint32_t lastNameHash = 0; extern unsigned char NewChar; // uint32_t curOnAirHash = calculateStringHash((char*) LCD_buffer); uint32_t curTxHash = calculateStringHash(XmitBuffer); uint32_t curKeyboardHash = calculateStringHash((char*) kybd_string); uint32_t curCallHash = calculateStringHash(Get_Contact(0)); uint32_t curNameHash = calculateStringHash(Get_Contact(1)); // Redraw only when needed: //_Bool redrawTitle = force; _Bool redrawOnAirBuffer = force || NewChar != 0; // _Bool redrawOnAirBuffer = force || lastOnAirHash != curOnAirHash; _Bool redrawTxBuffer = force || lastTxHash != curTxHash; _Bool redrawKeyboardBuffer = force || lastKeyboardHash != curKeyboardHash; _Bool redrawCallBuffer = force || lastCallHash != curCallHash; _Bool redrawNameBuffer = force || lastNameHash != curNameHash; int x = pThis->objCoordinates.MinX; int y = pThis->objCoordinates.MinY; // Display title: //if (redrawTitle) { // // Title // GL_SetFont(FONT_TITLE); // GL_SetTextColor(TITLE_COLOUR); // GL_SetBackColor(TITLE_BACKGROUND); // GL_PrintString(x + OFFSETX_TITLE, y + OFFSETY_TITLE, "Rx/Tx/Keyboard PSK Data:", 0); // //} // Display Call if (redrawCallBuffer){ GL_SetFont(GL_FONTOPTION_8x16); GL_SetBackColor(LCD_COLOR_BLACK); GL_SetTextColor(LCD_COLOR_WHITE); GL_PrintString(25, 170,Get_Contact(0), 0); lastCallHash = curCallHash; } //Display Name if (redrawNameBuffer) { GL_SetFont(GL_FONTOPTION_8x16); GL_SetBackColor(LCD_COLOR_BLACK); GL_SetTextColor(LCD_COLOR_WHITE); //GL_PrintString(175, 170,Get_Contact(1), 0); GL_PrintString(151, 170,Get_Contact(1), 0); lastNameHash = curNameHash; } // Display the on-air buffer // (Was previously displayed in main()) GL_SetFont(FONT_DATA); GL_SetTextColor(DATA_COLOUR); GL_SetBackColor(DATA_BACKGROUND); if (redrawOnAirBuffer) { DisplayText (NewChar); NewChar = 0; // GL_PrintString(x + OFFSETX_ONAIR, y + OFFSETY_ONAIR, (char*) LCD_buffer, 0); // lastOnAirHash = curOnAirHash; } // Display the Queue if (redrawTxBuffer) { //GL_PrintString(x + OFFSETX_TX, y + OFFSETY_TX, XmitBuffer, 0); //lastTxHash = curTxHash; } // Display the keyboard buffer if (redrawKeyboardBuffer) { //GL_PrintString(x + OFFSETX_KEYBOARD, y + OFFSETY_KEYBOARD, (char*) kybd_string, 0); //lastKeyboardHash = curKeyboardHash; } }