⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 tft真彩屏的显示
💻 C
字号:
/****************************************Copyright (c)**************************************************
**                               Guangzou ZLG-MCU Development Co.,LTD.
**                                      graduate school
**                                 http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name:			main.c
** Last modified Date:  2004-09-16
** Last Version:		1.0
** Descriptions:		The main() function example template
**
**------------------------------------------------------------------------------------------------------
** Created by:			Chenmingji
** Created date:		2004-09-16
** Version:				1.0
** Descriptions:		The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#include "config.h"

int8 g_ixLength;
int8 g_ix1Length;
int8 g_ix2Length;
int8 g_ix3Length;

int8 g_iyLength;
int8 g_iy1Length;
int8 g_iy2Length;
int8 g_iy3Length;

uint16 g_testcnt;
uint8 g_oldx;
uint8 g_oldy;


static const uint8 g_testbuffer[ ] = {
0x00, 0x00, 0x03, 0x14, 0x60, 0x03, 0x55, 0x60, 0x03, 0x14, 0x60, 0x03, 0xAA, 0x16, 0x03, 0xAA,
0x16, 0x03, 0x54, 0x21, 0x03, 0x56, 0x21, 0x03, 0x2A, 0x16, 0x03, 0x2A, 0x16, 0x03, 0x96, 0x21,
0x03, 0x95, 0x20, 0x03, 0xA5, 0x90, 0x03, 0x25, 0x90, 0x03, 0xA6, 0x91, 0x03, 0x15, 0x22, 0x03,
0x16, 0x20, 0x03, 0x65, 0x91, 0x03, 0x25, 0x91, 0x03, 0x16, 0x20, 0x03, 0x14, 0x20, 0x03, 0x26,
0x91, 0x03, 0xA5, 0x90, 0x03, 0x25, 0x90, 0x03, 0x10, 0x21, 0x03, 0x12, 0x21, 0x03, 0x10, 0x21,
0x03, 0x26, 0x11, 0x03, 0x26, 0x11, 0x03, 0x26, 0x11, 0x03, 0x56, 0x22, 0x03, 0x56, 0x22, 0x03,
0x56, 0x22, 0x03, 0x26, 0x90, 0x03, 0x26, 0x90, 0x03, 0x65, 0x92, 0x03, 0x16, 0xA0, 0x03, 0x56,
0xA0, 0x03, 0x25, 0x92, 0x03, 0x66, 0x90, 0x03, 0x95, 0x62, 0x03, 0x15, 0x62, 0x03, 0x95, 0x62,
0x03, 0x24, 0x10, 0x03, 0xA4, 0x10, 0x03, 0xA6, 0x10, 0x03, 0x24, 0x10, 0x03, 0x56, 0xA2, 0x03,
0x51, 0xA1, 0x03, 0x91, 0x21, 0x03, 0x66, 0x10, 0x03, 0x66, 0x10, 0x03, 0x54, 0xA2, 0x03, 0x14,
0xA2, 0x03, 0x25, 0x91, 0x03, 0xA5, 0x91, 0x03, 0x25, 0x91, 0x03, 0x44, 0x62, 0x03, 0x45, 0x62,
0x03, 0x25, 0x90, 0x03, 0x25, 0x90, 0x03, 0x65, 0x90, 0x03, 0x6A, 0x92, 0x03, 0x68, 0x92, 0x03,
0x6A, 0x92, 0x03, 0xA4, 0x12, 0x03, 0x64, 0x92, 0x03, 0x64, 0x92, 0x03, 0x85, 0x08, 0x03, 0x85,
0x08, 0x03, 0x05, 0x08, 0x03, 0x05, 0x48, 0x03, 0x45, 0x48, 0x03, 0x66, 0x88, 0x03, 0x65, 0x8A,
0x03, 0x65, 0x8A, 0x03, 0x2A, 0x11, 0x03, 0x29, 0x10, 0x03, 0xA5, 0x09, 0x03, 0x24, 0x09, 0x03,
0x25, 0x09, 0x03, 0x2A, 0x12, 0x03, 0x2A, 0x12, 0x03, 0xA4, 0x88, 0x03, 0xA4, 0x88, 0x03, 0xA4,
0x88, 0x03, 0xAA, 0x90, 0x03, 0x5A, 0x40, 0x03, 0xAA, 0x90, 0x03, 0x55, 0x69, 0x03, 0x15, 0x69,
0x03, 0x5A, 0x62, 0x03, 0x65, 0x99, 0x03, 0xA5, 0x19, 0x03, 0x54, 0x69, 0x03, 0xA5, 0x89, 0x03,
0x54, 0x69, 0x03, 0x95, 0x49, 0x03, 0x15, 0x49, 0x03, 0x98, 0x20, 0x03, 0x58, 0xA0, 0x03, 0x2A,
0x50, 0x03, 0xAA, 0x50, 0x03, 0x56, 0x40, 0x03, 0x54, 0x40, 0x03, 0x58, 0x05, 0x03, 0x9A, 0x45,
0x03, 0x58, 0x05, 0x03, 0x68, 0x46, 0x03, 0x69, 0x46, 0x03, 0xA2, 0x11, 0x03, 0xA0, 0x11, 0x03,
0xA2, 0x11, 0x03, 0x69, 0x06, 0x03, 0xAA, 0x44, 0x03, 0x69, 0x06, 0x03, 0xA6, 0x52, 0x03, 0x2A,
0x44, 0x03, 0x2A, 0x44, 0x03, 0x2A, 0x44, 0x03, 0x65, 0x90, 0x03, 0x26, 0x91, 0x03, 0x2A, 0x04,
0x03, 0xAA, 0x04, 0x03, 0x2A, 0x04, 0x03, 0x24, 0x10, 0x03, 0x24, 0x10, 0x03, 0xA5, 0x01, 0x03,
0x6A, 0x86, 0x03, 0xAA, 0x06, 0x03, 0x68, 0x16, 0x03, 0xA8, 0x56, 0x03, 0x19, 0x26, 0x03, 0x18,
0x26, 0x03, 0xA5, 0x90, 0x03, 0x26, 0x91, 0x03, 0xA5, 0x90, 0x03, 0x95, 0xA0, 0x03, 0x15, 0xA0,
0x03, 0xA8, 0x94, 0x03, 0x28, 0x94, 0x03, 0xA8, 0x94, 0x03, 0x50, 0x21, 0x03, 0x51, 0x21, 0x03,
0x50, 0x21, 0x03, 0x16, 0x20, 0x03, 0x16, 0x20, 0x03, 0x15, 0x22, 0x03, 0x92, 0x20, 0x03, 0x92,
0x20, 0x03, 0x68, 0x85, 0x03, 0x28, 0x85, 0x03, 0x69, 0x85, 0x03, 0x25, 0x08, 0x03, 0x24, 0x08,
0x03, 0xA5, 0x08, 0x03, 0x5A, 0x65, 0x03, 0xAA, 0x85, 0x03, 0x59, 0x64, 0x03, 0x66, 0x0A, 0x03,
0x26, 0x0A, 0x03, 0x26, 0x0A, 0x03, 0x18, 0x62, 0x03, 0x19, 0x62, 0x03, 0x66, 0x4A, 0x03, 0x86,
0x8A, 0x03, 0x66, 0x4A, 0x03, 0x84, 0x8A, 0x03, 0x14, 0x68, 0x03, 0x14, 0x68, 0x03, 0x14, 0x68,
0x03, 0x54, 0x68, 0x03, 0xA5, 0x59, 0x03, 0x2A, 0x52, 0x03, 0xA5, 0x59, 0x03, 0x26, 0x89, 0x03,
0x25, 0x88, 0x03, 0x25, 0x88, 0x03, 0xA6, 0x89, 0x03, 0x25, 0x59, 0x03, 0x24, 0x59, 0x03, 0x64,
0x08, 0x03, 0x66, 0x08, 0x03, 0x64, 0x08, 0x03, 0xA6, 0x48, 0x03, 0x5A, 0x40, 0x03, 0xAA, 0x90,
0x03, 0xAA, 0x90, 0x03, 0x95, 0x69, 0x03, 0x15, 0x69, 0x03, 0x1A, 0x62, 0x03, 0xAA, 0x11, 0x03,
0xAA, 0x11, 0x03, 0xAA, 0x11, 0x03, 0x1A, 0x62, 0x03, 0x15, 0x69, 0x03, 0x5A, 0x62, 0x03, 0x15,
0x69, 0x03, 0x2A, 0x11, 0x03, 0x29, 0x10, 0x03, 0x29, 0x10, 0x03, 0x1A, 0x62, 0x03, 0x55, 0x69,
0x03, 0x15, 0x69, 0x03, 0x81, 0x90, 0x03, 0x81, 0x90, 0x03, 0x80, 0x90, 0x03, 0x01, 0x90, 0x03
};
extern uint8  gImage_pic1[];


extern void Line(unsigned int x1,unsigned char y1,unsigned int x2,unsigned char y2,uint8 color);
extern void  DelaymS(uint32 no);

/*******************************************************
* 名称: DispRGB
* 功能: 显示RGB红色。第种纯色,各占80行。
* 入口参数: 无
* 出口参数: 无
*******************************************************/
void  DispRGB(void)
{
	uint32  x,y;

	TftSetWindow(0,0, 239,319);
	TftSetWrite(0, 0);

	// 填充红色
	for(y=0; y<80; y++)
	{
		for(x=0; x<240; x++)
		{
			TftSendDat(0xF800);
		}
	}

	// 填充绿色
	for(y=0; y<80; y++)
	{
		for(x=0; x<240; x++)
		{
			TftSendDat(0x07E0);
		}
	}

	// 填充蓝色
	for(y=0; y<80; y++)
	{
		for(x=0; x<240; x++)
		{
			TftSendDat(0x001F);
		}
	}

	// 填充白色
	for(y=0; y<80; y++)
	{
		for(x=0; x<240; x++)
		{
			TftSendDat(0xFFFF);
		}
	}

	DelaymS(1*100);			// 延时5S
}

/*******************************************************
* 名称: DispPic
* 功能: 显示图形演示。
* 入口参数: 无
* 出口参数: 无
*******************************************************/
void  DispPic(void)
{
	uint32  x, y;
	uint32  no;
	uint16  dat;

	// 第1幅图
	TftSetWindow(0,0, 239, 319);
	TftSetWrite(0,0);
	no = 0;
	for(y=0; y<320; y++)
	{
		for(x=0; x<240; x++)
		{
			dat = (gImage_pic1[no+1]<<8) | gImage_pic1[no];
			TftSendDat(dat);
			no++;
			no++;
		}
	}
	DelaymS(1*100);
}

void stich_explain(uint8 a, uint8 b, uint8 c)
{
	g_iy1Length = ((a >> 7) & 0x01) - ((a >> 6) & 0x01) + ((a >> 5) & 0x01) * 9 - ((a >> 4) & 0x01) * 9;
	g_iy2Length = ((b >> 7) & 0x01) * 3 - ((b >> 6) & 0x01) * 3 + ((b >> 5) & 0x01) * 27 - ((b >> 4) & 0x01) * 27;
	g_iy3Length = ((c >> 5) & 0x01) * 81 - ((c >> 4) & 0x01) * 81;
	g_iyLength = (g_iy1Length + g_iy2Length + g_iy3Length) / 4;

	g_ix1Length = (a & 0x01) - ((a >> 1) & 0x01) + ((a >> 2) & 0x01) * 9 - ((a >> 3) & 0x01) * 9;
	g_ix2Length = (b & 0x01) * 3 - ((b >> 1) & 0x01) * 3 + ((b >> 2) & 0x01) * 27 - ((b >> 3) & 0x01) * 27;
	g_ix3Length = ((c >> 2) & 0x01) * 81 - ((c >> 3) & 0x01) * 81;
	g_ixLength = (g_ix1Length + g_ix2Length + g_ix3Length) / 4;
}

int main (void)
{  // add user source code
	uint16 color;
	uint16 x;
	uint16 y;
	//PINSEL0 = 0x00000000;
	//PINSEL1 = 0x00000000;
	g_oldx = 120;
	g_oldy = 160;

	GUI_Initialize();
	color = 0xF81F;

	for(y=0; y<320; y++)
	{
		for(x=0; x<240; x++)
		{
			TftSendDat(0x7BE0);
		}
	}
	while(1)
	{
		stich_explain(g_testbuffer[g_testcnt], g_testbuffer[g_testcnt + 1], g_testbuffer[g_testcnt + 2]);
		g_testcnt += 3;

		Line(g_oldx,g_oldy,(g_oldx + g_ixLength), (g_oldy + g_iyLength), color);

		g_oldx = g_oldx + g_ixLength;
		g_oldy = g_oldy + g_iyLength;
	}

	return 0;
}
/*********************************************************************************************************
**                            End Of File
********************************************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -