Exemplo n.º 1
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);
}
Exemplo n.º 2
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);
    }
}
Exemplo n.º 3
0
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;
	}
}
Exemplo n.º 4
0
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
}