示例#1
0
int initTFT()
{
	int Status;
	XTft_Config *TftConfigPtr;

	/*
	 * Get address of the XTft_Config structure for the given device id.
	 */
	TftConfigPtr = XTft_LookupConfig(TFT_DEVICE_ID);
	if (TftConfigPtr == (XTft_Config *)NULL) 
	{
		return XST_FAILURE;
	}

	/*
	 * Initialize all the TftInstance members and fills the screen with
	 * default background color.
	 */
	Status = XTft_CfgInitialize(&TftInstance, TftConfigPtr,
			TftConfigPtr->BaseAddress);
	if (Status != XST_SUCCESS) 
	{
		return XST_FAILURE;
	}

	/*
	 * Wait till Vsync(Video address latch) status bit is set before writing
	 * the frame address into the Address Register. This ensures that the
	 * current frame has been displayed and we can display a new frame of
	 * data. Checking the Vsync state ensures that there is no data flicker
	 * when displaying frames in real time though there is some delay due to
	 * polling.
	 */
	while (XTft_GetVsyncStatus(&TftInstance) !=
			XTFT_IESR_VADDRLATCH_STATUS_MASK);

	/*
	 * Change the Video Memory Base Address from default value to
	 * a valid Memory Address and clear the screen.
	 */
	XTft_SetFrameBaseAddr(&TftInstance, TFT_FRAME_ADDR);
	XTft_ClearScreen(&TftInstance);

	XTft_SetPos(&TftInstance, 0,0);
	XTft_SetPosChar(&TftInstance, 0,0);

	XTft_SetColor(&TftInstance, 0x00000000, 0x00ffffff);

	XTft_FillScreen(&TftInstance, 0, 0,639,479,0x00ffffff); // white



	return XST_SUCCESS;
}
示例#2
0
/**
*
* This function performs one of the following three operations based on the
* CharValue passed :
* - Move the position to the next line at the same position.
* - Move the position to the next line.
* - Write a particular character and update the column position by the
*   width of the character.
*
* @param	InstancePtr is a pointer to the XTft instance.
* @param	CharValue is the ASCII code value of the character to be
*		written.
*
* @return	None.
*
* @note		As the character bitmap array does not support some of the
*		ASCII values, to support some of those which carry
*		significance in display are added in the switch case. If
*		there is a necessity for any other characters, it can be
*		added here.
*
****************************************************************************/
void XTft_Write(XTft *InstancePtr, u8 CharValue)
{
	/*
	 * Assert validates the input arguments.
	 */
	Xil_AssertVoid(InstancePtr != NULL);
	Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);

	/*
	 * First two cases handle the special input values
	 * and default case performs a character write operation
	 * and it updates the column position in the instance structure.
	 */
	switch (CharValue) {
		case 0xd:
			/*
			 * Action to be taken for carriage return.
			 */
			XTft_SetPos(InstancePtr, XTFT_DEF_COLVAL,
					InstancePtr->RowVal);
			break;
		case 0xa:
			/*
			 * Action to be taken for line feed.
			 */
			XTft_SetPos(InstancePtr, XTFT_DEF_COLVAL,
				InstancePtr->RowVal + XTFT_CHAR_HEIGHT);
			break;
		default:
			/*
			 * Set the position and write the character and
			 * update the column position by width of
			 * character.
			 */
			XTft_SetPosChar(InstancePtr, InstancePtr->ColVal,
					InstancePtr->RowVal);
			XTft_WriteChar(
				InstancePtr, CharValue,
				InstancePtr->ColVal, InstancePtr->RowVal,
				InstancePtr->FgColor, InstancePtr->BgColor);

			InstancePtr->ColVal += XTFT_CHAR_WIDTH;
			break;
	}

}