예제 #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 initializes a TFT Driver Instance.
*
* @param	InstancePtr is a pointer to the XTft instance.
* @param	ConfigPtr is a pointer to a XTft_Config configuration
*		structure.This structure will contain the requested
*		configuration for the device. Typically, this is a local
*		structure and the content of which will be copied into the
*		configuration structure within XTft.
* @param	EffectiveAddr is the device base address in the virtual
*		memory address space. If the address translation is not used
*		then the physical address is passed. Unexpected errors may
*		occur if the address mapping is changed after this function
*		is invoked.
*		This address is taken into consideration only if the
*		the TFT controller Register interface is connected to the
*		PLB bus.
*
* @return
*		- XST_SUCCESS if successful.
*		- XST_FAILURE if unsuccessful.
*
* @note		None.
*
****************************************************************************/
int XTft_CfgInitialize(XTft *InstancePtr, XTft_Config *ConfigPtr,
			 u32 EffectiveAddr)
{
	/*
	 * Assert validates the input arguments.
	 */
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(ConfigPtr != NULL);

	/*
	 * Setup the DeviceId, Video Memory Address and Base Address
	 * and Plb Access from the configuration structure.
	 */
	InstancePtr->TftConfig.DeviceId = ConfigPtr->DeviceId;
	InstancePtr->TftConfig.BaseAddress = EffectiveAddr;
	InstancePtr->TftConfig.VideoMemBaseAddr =
				ConfigPtr->VideoMemBaseAddr;
	InstancePtr->TftConfig.PlbAccess = ConfigPtr->PlbAccess;
	InstancePtr->TftConfig.DcrBaseAddr = ConfigPtr->DcrBaseAddr;

	/*
	 * Initialize the XTft Instance members to default values.
	 */
	InstancePtr->ColVal = XTFT_DEF_COLVAL;
	InstancePtr->RowVal = XTFT_DEF_ROWVAL;
	InstancePtr->FgColor = XTFT_DEF_FGCOLOR;
	InstancePtr->BgColor = XTFT_DEF_BGCOLOR;

	/*
	 * Indicate the XTft Instance is now ready to use, initialized
	 * without error.
	 */
	InstancePtr->IsReady = XIL_COMPONENT_IS_READY;

	/*
	 * Fills the screen with the default background color.
	 */
	XTft_FillScreen(InstancePtr, XTFT_DEF_COLVAL, XTFT_DEF_ROWVAL,
			(XTFT_DISPLAY_WIDTH - 1), (XTFT_DISPLAY_HEIGHT - 1),
			InstancePtr->BgColor);

	return XST_SUCCESS;
}
예제 #3
0
/**
*
* This function re-initializes all the pixels to the default background color.
*
* @param	InstancePtr is a pointer to the XTft instance.
*
* @return	None.
*
* @note		None.
*
****************************************************************************/
void XTft_ClearScreen(XTft *InstancePtr)
{
	/*
	 * Assert validates the input arguments.
	 */
	Xil_AssertVoid(InstancePtr != NULL);
	Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);

	/*
	 * Fills the screen with the background color of Instance structure.
	 */
	XTft_FillScreen(InstancePtr, XTFT_DEF_COLVAL, XTFT_DEF_ROWVAL,
			(XTFT_DISPLAY_WIDTH - 1), (XTFT_DISPLAY_HEIGHT - 1),
			InstancePtr->BgColor);

	/*
	 * Initialize the column, row positions to (0, 0)origin.
	 */
	InstancePtr->ColVal = XTFT_DEF_COLVAL;
	InstancePtr->RowVal = XTFT_DEF_ROWVAL;

}
예제 #4
0
/**
*
* This function inserts a new blank line at the bottom of the screen, it
* deletes the first line and moves the remaining lines up by one line.
*
* @param	InstancePtr is a pointer to the XTft instance.
*
* @return	None.
*
* @note		None.
*
****************************************************************************/
void XTft_Scroll(XTft *InstancePtr)
{
	u32 PixelVal;
	u32 ColIndex;
	u32 RowIndex;

	/*
	 * Assert validates the input arguments.
	 */
	Xil_AssertVoid(InstancePtr != NULL);
	Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);

	/*
	 * Takes each pixel value from the second line and puts in the first
	 * line. This process is repeated till the second line
	 * from bottom.
	 */
	for (RowIndex = 0;
		RowIndex < (XTFT_DISPLAY_HEIGHT - 1) - XTFT_CHAR_HEIGHT;
		RowIndex++) {
		for (ColIndex = 0; ColIndex < (XTFT_DISPLAY_WIDTH - 1);
					ColIndex++) {
			XTft_GetPixel(InstancePtr, ColIndex,
				RowIndex + XTFT_CHAR_HEIGHT, &PixelVal);
			XTft_SetPixel(
				InstancePtr, ColIndex, RowIndex, PixelVal);
		}
	}

	/*
	 * Fills the last line with the background color.
	 */
	XTft_FillScreen(InstancePtr,
			 XTFT_DEF_COLVAL,
			 (XTFT_DISPLAY_HEIGHT - 1)-XTFT_CHAR_HEIGHT,
			 (XTFT_DISPLAY_WIDTH - 1), (XTFT_DISPLAY_HEIGHT - 1),
			 InstancePtr->BgColor);

}
예제 #5
0
XStatus XTft_Scroll(XTft *InstancePtr)
{
  Xuint32 col;
  Xuint32 x, y;

  XASSERT_NONVOID(InstancePtr != XNULL);
  XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);

  for (y = 0; y < XTFT_DISPLAY_HEIGHT-XTFT_CHAR_HEIGHT; y++)
  {
    for (x = 0; x < XTFT_DISPLAY_WIDTH; x++)
    {
      col = XTft_mGetPixel(*(Xuint32 *)InstancePtr->BaseAddress, x, y+XTFT_CHAR_HEIGHT);
      XTft_mSetPixel(*(Xuint32 *)InstancePtr->BaseAddress, x, y, col);
    }
  }
  XTft_FillScreen(*(Xuint32 *)InstancePtr->BaseAddress,
                  0, XTFT_DISPLAY_HEIGHT-XTFT_CHAR_HEIGHT,
                  XTFT_DISPLAY_WIDTH, XTFT_DISPLAY_HEIGHT-1,
                  InstancePtr->BgColor);

   return XST_SUCCESS;
 }