示例#1
0
/**
 * @brief	Callback for the format button
 * @param	Event: The event that caused the callback
 * @param	ButtonId: The button ID that the event happened on
 * @retval	None
 */
void guiUart1FormatButtonCallback(GUITouchEvent Event, uint32_t ButtonId)
{
	if (Event == GUITouchEvent_Up)
	{
		UARTSettings* settings = uart1GetSettings();
		SemaphoreHandle_t* settingsSemaphore = uart1GetSettingsSemaphore();
		/* Try to take the settings semaphore */
		if (*settingsSemaphore != 0 && xSemaphoreTake(*settingsSemaphore, 100) == pdTRUE)
		{
			if (settings->textFormat == GUITextFormat_ASCII)
			{
				settings->textFormat = GUITextFormat_HexWithSpaces;
				GUIButton_SetTextForRow(GUIButtonId_Uart1Format, "Hex", 1);
			}
			else if (settings->textFormat == GUITextFormat_HexWithSpaces)
			{
				settings->textFormat = GUITextFormat_ASCII;
				GUIButton_SetTextForRow(GUIButtonId_Uart1Format, "ASCII", 1);
			}

			/* Give back the semaphore now that we are done */
			xSemaphoreGive(*settingsSemaphore);

			/* Update the text format for the text box */
			GUITextBox_ChangeTextFormat(GUITextBoxId_Uart1Main, settings->textFormat, GUITextFormatChangeStyle_LockEnd);

			/* Refresh the main text box */
			guiUart1ManageMainTextBox(true);
		}
	}
}
示例#2
0
/**
 * @brief	Manages how data is displayed in the main text box when the source is an UART channel
 * @param	constStartFlashAddress: The address in SPI FLASH where the first data is for the channel
 * @param	currentWriteAddress: The current write address for the channel
 * @param	pSettings: Pointer to the settings for the channel
 * @param	pSemaphore: Pointer to the settings semaphore
 * @param	TextBoxId: ID for the text box which should be used
 * @retval	None
 */
void lcdManageGenericUartMainTextBox(const uint32_t constStartFlashAddress, uint32_t currentWriteAddress, UARTSettings* pSettings,
                                     SemaphoreHandle_t* pSemaphore, uint32_t TextBoxId, bool ShouldRefresh)
{
    /* Try to take the settings semaphore */
    if (*pSemaphore != 0 && xSemaphoreTake(*pSemaphore, 100) == pdTRUE)
    {
        /* The text box should refresh the data that is displayed */
        if (ShouldRefresh)
        {
            /* Update the text format for the text box */
            GUITextBox_ChangeTextFormat(TextBoxId, pSettings->textFormat, GUITextFormatChangeStyle_LockEnd);
            GUITextBox_RefreshCurrentDataFromMemory(TextBoxId);
        }

        uint32_t readEndAddress = GUITextBox_GetReadEndAddress(TextBoxId);
        /* New data has been written that we have not displayed yet */
        if (readEndAddress != 0 && readEndAddress < currentWriteAddress)
        {
            /* If we are not scrolling we should append this new data to the end of the displayed data */
            if (!GUITextBox_IsScrolling(TextBoxId))
            {
                GUITextBox_AppendDataFromMemory(TextBoxId, currentWriteAddress);
            }
            /* If we are scrolling just update the last valid address of the text box */
            else
            {
                GUITextBox_SetLastValidByteAddress(TextBoxId, currentWriteAddress);
            }
        }

        /* Get how many rows the offset equals */
        int32_t rowDiff = prvMainContainerYPosOffset / 16;

        /* Manage offset caused by scrolling */
        if (prvMainContainerYPosOffset != 0 && rowDiff != 0)
        {
            GUITextBox_MoveDisplayedDataNumOfRows(TextBoxId, rowDiff);

            /* Set it to 0 now that we have managed it */
            prvMainContainerYPosOffset = 0;
        }

#if 0
        /* DEBUG */
        GUITextBox_SetWritePosition(GUITextBoxId_Debug, 5, 5);
        GUITextBox_Clear(GUITextBoxId_Debug);
        GUITextBox_WriteString(GUITextBoxId_Debug, "Data Count: ");
        GUITextBox_WriteNumber(GUITextBoxId_Debug, currentWriteAddress-constStartFlashAddress);
        GUITextBox_WriteString(GUITextBoxId_Debug, ", numChar: ");
        GUITextBox_WriteNumber(GUITextBoxId_Debug, numOfCharactersDisplayed);
#endif

        /* Give back the semaphore now that we are done */
        xSemaphoreGive(*pSemaphore);
    }
}