Ejemplo n.º 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;
}
Ejemplo n.º 2
0
/**
 * * Initialise xps_tft.
 */
void init_tft(void) {
	// recherche de la configuration
	g_tftconfig = XTft_LookupConfig(XPAR_XPS_TFT_0_DEVICE_ID);
	if (g_tftconfig == NULL) {
		//xil_printf("périphérique xps_tft introuvable...\n");
		for (;;);
	}

	// configuration initiale
	if (XTft_CfgInitialize(&g_tft, g_tftconfig, g_tftconfig->BaseAddress) != XST_SUCCESS) {
		//xil_printf("erreur d'initialisation de xps_tft...\n");
		for (;;);
	}

	// attente que xps_tft soit prêt
	while (XTft_GetVsyncStatus(&g_tft) != XTFT_IESR_VADDRLATCH_STATUS_MASK);

	// ajustement de l'adresse de la page vidéo
	XTft_SetFrameBaseAddr(&g_tft, TFT_FB_ADDR);
}
Ejemplo n.º 3
0
/**
*
* This is the example function which performs the following operations on
* the TFT device -
* - Set the color values of foreground and background
* - Write two characters (S) one after another
* - Write a string of characters
* - Draw a line and scroll the screen once
* - Disable the display (The screen goes blank)
* - Scroll the screen once and draw a line
* - Enable the TFT display
*
* @param	TftDeviceId is the unique Id of the device.
*
* @return
*		- XST_SUCCESS if successful.
*		- XST_FAILURE if unsuccessful.
*
* @note		None.
*
******************************************************************************/
int TftExample(u32 TftDeviceId)
{
	int Status;
	u8 VarChar;
	XTft_Config *TftConfigPtr;

	/*
	 * Get address of the XTft_Config structure for the given device id.
	 */
	TftConfigPtr = XTft_LookupConfig(TftDeviceId);
	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);

	/*
	 * Initialize the variable VarChar to the value to be displayed on the
	 * screen.
	 * Set the foreground and background colors.
	 */
	VarChar = 'S';
	XTft_SetColor(&TftInstance, FGCOLOR_VALUE, BGCOLOR_VALUE);

	/*
	 * Write the character two times starting from top left corner
	 * (i.e. origin) of screen.
	 */
	XTft_Write(&TftInstance, VarChar);
	XTft_Write(&TftInstance, VarChar);

	/*
	 * Write a string which is displayed next to the two characters
	 * written previously.
	 */
	Status = TftWriteString(&TftInstance, (u8*)"TFT CONTROLLER\n");
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Draw a line between the coordinates (X1,Y1) and (X2,Y2) which
	 * displays a vertical line in white color.
	 * Scroll the screen, so the two characters and string will be
	 * erased on screen.
	 */
	Status = TftDrawLine(&TftInstance, X1POS, Y1POS, X2POS, Y2POS,
				WHITECOLOR_VALUE);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	XTft_Scroll(&TftInstance);

	/*
	 * Disable the display, the screen will be turned off.
	 */
	XTft_DisableDisplay(&TftInstance);

	/*
	 * Even though the screen is turned off, we can still do operations on
	 * video memory.
	 * Scroll the screen.
	 * Draw a line between the coordinates (X1 + 10,Y1) and (X2,Y2) which
	 * is displayed at different position as X1 has some offset.
	 */
	XTft_Scroll(&TftInstance);
	Status = TftDrawLine(&TftInstance, X1POS + 10, Y1POS, X2POS + 10,
				 Y2POS, WHITECOLOR_VALUE);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Enable the display. Screen will display two lines in white color.
	 * The first line from the left of screen is slightly above the
	 * second one indicating the scroll was successful.
	 */
	XTft_EnableDisplay(&TftInstance);

	return XST_SUCCESS;
}
Ejemplo n.º 4
0
Xuint32 Decode_display_bitmap(XTft * InstancePtr, Xuint32 FRAME_ADDR)
{

Xuint16 Flash_Data;
Xuint8  Pixel_R;
Xuint8  Pixel_G;
Xuint8  Pixel_B;
Xuint32 Pixel_Data0, Pixel_Data1, Pixel_Data2;
Xuint32 temp;
Xuint32 Pixel_Data;
Xuint32 Bitmap_File_Size;
Xuint32 Bitmap_Data_Offset;
Xuint32 Bitmap_Width_Pixels;
Xuint32 Bitmap_Height_Pixels;
Xuint16 Bitmap_Bits_Per_Pixel;
Xuint32 Bitmap_Image_Size;
Xuint32 Bytes_Per_Row;
Xuint32 MEM_ADDR;
Xuint32 MEM_HIGHADDR;

Xuint32 i, j, k;


if (verbose) xil_printf ("\r\nDecoding bitmap");

//reset FLASH to read mode
XIo_Out16 (XPAR_FLASH_MEM0_BASEADDR, 0xFF);

Flash_Data = XIo_In16(XPAR_FLASH_MEM0_BASEADDR+FLASH_START_ADDR);
if (verbose) xil_printf("\r\nFile Type is 0x%X", Flash_Data);

//check if the bitmap is present in the FLASH memory by checking for the 'B' and 'M' characters
//at the beginnig of the file location
if (Flash_Data != 0x424d)
{
   if (verbose) xil_printf("\r\nBitmap was not found in the FLASH memory, data found in the FLASH memory is 0x%X", Flash_Data);	

return 1;
}

//determine bitmap parameters
Bitmap_File_Size = Read_Bitmap_Header_Bytes(FLASH_BASEADDR+FLASH_START_ADDR, BITMAP_FILE_SIZE_OFFSET);
//Bitmap_File_Size = XIo_In32(XPAR_FLASH_MEM0_BASEADDR+FLASH_START_ADDR+BITMAP_FILE_SIZE_OFFSET);
if (verbose) xil_printf("\r\nFile Size is 0x%X", Bitmap_File_Size);

Bitmap_Data_Offset = Read_Bitmap_Header_Bytes(FLASH_BASEADDR+FLASH_START_ADDR, BITMAP_DATA_OFFSET);
if (verbose) xil_printf("\r\nBitmap Data Offset is 0x%X", Bitmap_Data_Offset);

Bitmap_Width_Pixels = Read_Bitmap_Header_Bytes(FLASH_BASEADDR+FLASH_START_ADDR, BITMAP_WIDTH_OFFSET);
if (verbose) xil_printf("\r\nBitmap Width in pixels is %d", Bitmap_Width_Pixels);

Bitmap_Height_Pixels = Read_Bitmap_Header_Bytes(FLASH_BASEADDR+FLASH_START_ADDR, BITMAP_HEIGHT_OFFSET);
if (verbose) xil_printf("\r\nBitmap Height in pixels is %d", Bitmap_Height_Pixels);

Bitmap_Bits_Per_Pixel = XIo_In16(FLASH_BASEADDR + FLASH_START_ADDR + BITMAP_BITS_PER_PIXEL_OFFSET);
Bitmap_Bits_Per_Pixel = Bitmap_Bits_Per_Pixel >> 8;
if (verbose) xil_printf("\r\nBitmap Bits per pixel is %d", Bitmap_Bits_Per_Pixel);

Bitmap_Image_Size = Read_Bitmap_Header_Bytes(FLASH_BASEADDR+FLASH_START_ADDR, BITMAP_IMAGE_SIZE_OFFSET);
if (verbose) xil_printf("\r\nBitmap image size is %d", Bitmap_Image_Size);

Bytes_Per_Row = Bitmap_Image_Size / Bitmap_Height_Pixels;
if (verbose) xil_printf("\r\nBytes per row = %d", Bytes_Per_Row);

MEM_HIGHADDR = (MEM_ROW_WIDTH * MEM_DISPLAYED_HEIGHT) * 4;

//start loading the image in reverse order, because the bitmap data is stored in reverse order
//therefore set the current address to the beginning of the highest line in the frame and
//increment at each pixel in the line, then decrement with a line at the end of each line
MEM_ADDR = MEM_HIGHADDR - (MEM_ROW_WIDTH * 4);

if (verbose) xil_printf("\r\nImage Memory High address = 0x%X, Current Address = 0x%X", MEM_HIGHADDR, MEM_ADDR);

LCDSetLine(2);

for (i = 0;  i<(Bitmap_Height_Pixels * Bytes_Per_Row); i = i + Bytes_Per_Row)
{
	//read three bytes from the FLASH memory that represent B, G and R data for a pixel
	for (j = 0; j <Bytes_Per_Row; j = j + 3)
	{
		Pixel_B = XIo_In8(FLASH_BASEADDR + FLASH_START_ADDR + Bitmap_Data_Offset + i + j);
		Pixel_G = XIo_In8(FLASH_BASEADDR + FLASH_START_ADDR + Bitmap_Data_Offset + i + (j+1));
	    Pixel_R = XIo_In8(FLASH_BASEADDR + FLASH_START_ADDR + Bitmap_Data_Offset + i + (j+2));

		Pixel_Data = ((0x00000000 | Pixel_R) << 16) | ((0x00000000 | Pixel_G) << 8) | (0x00000000 | Pixel_B);
		
		XIo_Out32(FRAME_ADDR + MEM_ADDR, Pixel_Data);
		//increment one pixel
		MEM_ADDR = MEM_ADDR + 4;
	}
	//if (verbose) xil_printf("\r\nCurrent MEM_ADDR value is 0x%X", MEM_ADDR);
	//decrement with one line
	MEM_ADDR = MEM_ADDR - ((MEM_DISPLAYED_ROW_WIDTH + MEM_ROW_WIDTH) * 4);	
	//if (verbose) xil_printf("\r\nMEM_ADDR value is 0x%X", MEM_ADDR);
	
	if (!(i&0xFFF))
	{
		LCDPrintChar('*');
		xil_printf(".");
	}

}

//set the base address of the TFT device to the beginning of the bitmap image
XTft_SetFrameBaseAddr(InstancePtr, FRAME_ADDR);
//XIo_Out32 (XPAR_XPS_TFT_0_SPLB_BASEADDR, XPAR_DDR2_SDRAM_MPMC_BASEADDR + MEM_START_ADDR);

if (verbose) xil_printf("\r\nMEM_ADDR value is 0x%X", MEM_ADDR);


return 0;

}