/************************** Copyright (c) **********************************
|
** FUZHOU FUGUANG ELECTRONICS Co.,LTD.
|
** ¸£Öݸ£¹âµç×ÓÓÐÏÞ¹«Ë¾
|
** http://www.fuguang.com
|
**
|
**-------------- File Info -------------------------------------------------
|
** File name: TFT_Driver.c
|
** Last modified Date: 2008-11-16
|
** Last Version: 1.0
|
** Descriptions: TFT Drivers lib
|
**
|
**--------------------------------------------------------------------------
|
** Created by: mxpopstar
|
** Created date: 2008-11-16
|
** Version: 1.0
|
** Descriptions: The original version
|
**
|
**--------------------------------------------------------------------------
|
** Modified by: mxpopstar
|
** Modified date: 2008-11-20
|
** Version:
|
** Descriptions: TFT Drivers lib
|
**
|
**--------------------------------------------------------------------------
|
** Modified by: mxpopstar
|
** Modified date: 2010-10-21
|
** Version:
|
** Descriptions: ÐÞ¸ÄÁËд²Ù×÷µÄʱÐò,д²Ù×÷µÄʱÐòΪµÍµçƽÓÐЧ
|
**
|
***************************************************************************/
|
//
|
|
#include "TFT_Driver.h"
|
|
void InitIO_TFT(void)
|
{
|
DDRC |= 0xFF;
|
DDRG |= 0x03;
|
DDRD |= 0xC0;
|
_delay_ms(1);
|
}
|
//
|
|
void Config_TFT(void)
|
{
|
// TFT_CS;
|
TFT_read_1;
|
//--- ÉèÖÃÒº¾§ÆÁΪËļ¶ÁÁ¶È ----
|
Write_CMD(0x06);
|
Write_TFT_Data(0x04);
|
}
|
//
|
|
void Write_CMD(const unsigned char CMD)
|
{
|
PORTG &= 0xFC;
|
PORTG |= 0x02;
|
|
TFT_write_1;
|
TFT_bus = CMD;
|
TFT_write_0;
|
TFT_write_1;
|
}
|
//
|
|
void Local_TFT_XY(const unsigned int X, const unsigned int Y)
|
{
|
PORTG &= 0xFC;
|
|
TFT_bus = (unsigned char)X;
|
TFT_write_0;
|
TFT_write_1;
|
|
TFT_bus = (unsigned char)(X>>8);
|
TFT_write_0;
|
TFT_write_1;
|
|
PORTG &= 0xFC;
|
PORTG |= 0x01;
|
|
TFT_bus = (unsigned char)Y;
|
TFT_write_0;
|
TFT_write_1;
|
|
TFT_bus = (unsigned char)(Y>>8);
|
TFT_write_0;
|
TFT_write_1;
|
}
|
//
|
|
void Write_TFT_Data(const unsigned char data)
|
{
|
PORTG |= 0x03;
|
TFT_bus = data;
|
TFT_write_0;
|
TFT_write_1;
|
}
|
//
|
|
void BackColorCH(void)
|
{
|
Write_CMD(0x04);//ÉèÖñ³¾°É«
|
Write_TFT_Data(blue);
|
Write_CMD(0x08);//ÇåÆÁÖ¸Áî
|
_delay_ms(50); //ÑÓʱ24ºÁÃ룬ÈÃÇåÆÁ²Ù×÷Íê±Ï
|
Write_CMD(0x01);//Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ
|
}
|
//
|
|
void SetBLFLIncdirection(unsigned char Bcolor, unsigned char Fcolor, unsigned char direction)
|
{
|
Write_CMD(0x04);//ÉèÖñ³¾°É«
|
Write_TFT_Data(Bcolor);
|
Write_CMD(0x02);//ÉèÖÃǰ¾°É«
|
Write_TFT_Data(Fcolor);
|
Write_CMD(direction);//Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ
|
}
|
//
|
|
void DSP8x11(unsigned int px, unsigned int py, const unsigned char* data)
|
{
|
unsigned char y;
|
for(y=0;y<11;y++)
|
{
|
Local_TFT_XY(px, py++);
|
//----------------Ìî³äÊý¾Ý---------------------
|
Write_TFT_Data(pgm_read_byte(&data[y]));
|
}
|
}
|
//
|
|
void DSP24x24(unsigned int px, unsigned int py, const unsigned char* data)
|
{
|
unsigned char x,y;
|
for(y=0; y<24; y++)
|
{
|
Local_TFT_XY(px, py++);
|
|
//----------------Ìî³äÊý¾Ý---------------------
|
for(x=0; x<3; x++)
|
{
|
Write_TFT_Data(pgm_read_byte(&data[y*3 + x]));
|
}
|
}
|
}
|
|
//
|
void DSP24x24Space(unsigned char count, unsigned int px, unsigned int py, unsigned char Bcolor, unsigned char Fcolor)
|
{
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, 0x01);
|
|
while(count--)
|
{
|
#if(SoftLanguage == CN)
|
DSP24x24(px, py, _24_24[101]);
|
px += 24;
|
#else
|
DSP24x24(px, py, _24_24[0]);
|
px += 24;
|
#endif
|
}
|
}
|
//
|
|
void DSP24x24Graph(const unsigned char *graph, unsigned char count, const unsigned char interval, unsigned int px, unsigned int py, unsigned char Bcolor, unsigned char Fcolor)
|
{
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, 0x01);
|
while(count--)
|
{
|
DSP24x24(px, py, _24_24[pgm_read_byte(graph++)]);
|
px += interval;
|
}
|
}
|
//
|
|
void DSP16x24(unsigned int px, unsigned int py, const unsigned char* data)
|
{
|
unsigned char x,y;
|
for(y=0; y<24; y++)
|
{
|
Local_TFT_XY(px, py++);
|
|
//----------------Ìî³äÊý¾Ý---------------------
|
for(x=0; x<2; x++)
|
{
|
Write_TFT_Data(pgm_read_byte(&data[y*2 + x]));
|
}
|
}
|
}
|
//
|
//%%%%%%%%%%%%%%%%%%%%%%%%12x16%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
void DSP12x16(unsigned int px, unsigned int py, const unsigned char* data)
|
{
|
unsigned char x,y;
|
for(x=0; x<12; x++)
|
{
|
Local_TFT_XY(px++, py);
|
|
//----------------Ìî³äÊý¾Ý---------------------
|
for(y=0; y<2; y++)
|
{
|
Write_TFT_Data(pgm_read_byte(&data[x*2 + y]));
|
}
|
}
|
}
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
void DSP32x32(unsigned int px, unsigned int py, const unsigned char* data)
|
{
|
unsigned char x,y;
|
for(y=0; y<32; y++)
|
{
|
Local_TFT_XY(px, py++);
|
//----------------Ìî³äÊý¾Ý---------------------
|
for(x=0; x<4; x++)
|
{
|
Write_TFT_Data(pgm_read_byte(&data[y*4 + x]));
|
}
|
}
|
}
|
//
|
|
|
void DSP24x36(unsigned int px, unsigned int py, const unsigned char* data)
|
{
|
unsigned char x,y;
|
for(y=0; y<36; y++)
|
{
|
Local_TFT_XY(px, py++);
|
//----------------Ìî³äÊý¾Ý---------------------
|
for(x=0; x<3; x++)
|
{
|
Write_TFT_Data(pgm_read_byte(&data[y*3 + x]));
|
}
|
}
|
}
|
//
|
|
void DSP24x36Str(const unsigned char *item, unsigned char count, unsigned char interval,
|
unsigned int px, unsigned int py, unsigned char Bcolor, unsigned char Fcolor)
|
{
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, 0x01);
|
while(count--)
|
{
|
DSP24x36(px, py, _24_36[pgm_read_byte(item++)]);
|
px += interval;
|
}
|
}
|
//
|
|
void DSP32x32Str(const unsigned char *item, unsigned char count, unsigned char interval,
|
unsigned int px, unsigned int py, unsigned char Bcolor, unsigned char Fcolor)
|
{
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, 0x01);
|
while(count--)
|
{
|
DSP32x32(px, py, _32_32[pgm_read_byte(item++)]);
|
px += interval;
|
}
|
}
|
//
|
|
|
void DSP24x24Str(const unsigned char *item, unsigned char count, unsigned char interval,
|
unsigned int px, unsigned int py, unsigned char Bcolor, unsigned char Fcolor)
|
{
|
unsigned int tmp = 0;
|
unsigned char tmpinterval = interval;
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, 0x01);
|
|
#if(SoftLanguage == CN)
|
while(count--)
|
{
|
tmp = pgm_read_byte(item++);
|
DSP24x24(px, py, _24_24[tmp]);
|
if(tmp < 36){interval = 12;}
|
else {interval = tmpinterval;}
|
px += interval;
|
}
|
#else
|
while(1)
|
{
|
tmpinterval = interval;
|
tmp = pgm_read_byte(item++);
|
|
if(tmp == 0)
|
{
|
return;
|
}
|
|
DSP16x24(px, py, _16_24[tmp-0x20]);//0x20
|
if(tmp <= 0x5a)
|
px += 16;
|
else px += 12;
|
}
|
#endif
|
}
|
//
|
void DSP24x24StrS(const unsigned char *item, unsigned char count, unsigned char interval,
|
unsigned int px, unsigned int py, unsigned char Bcolor, unsigned char Fcolor)
|
{
|
unsigned int tmp = 0;
|
unsigned char tmpinterval = interval;
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, 0x11);
|
|
#if(SoftLanguage == CN)
|
while(count--)
|
{
|
tmp = pgm_read_byte(item++);
|
DSP24x24(px, py, _24_24[tmp]);
|
if(tmp < 36){interval = 12;}
|
else {interval = tmpinterval;}
|
px += interval;
|
}
|
#else
|
while(1)
|
{
|
tmpinterval = interval;
|
tmp = pgm_read_byte(item++);
|
|
if(tmp == 0)
|
{
|
return;
|
}
|
|
DSP12x16(px, py, _12_16[tmp-0x20]);//0x20
|
if(tmp <= 0x5a)
|
px += 12;
|
else px += 8;
|
}
|
#endif
|
}
|
|
//
|
|
void DSP16x24Str(const unsigned char *item, unsigned char count, unsigned char interval,
|
unsigned int px, unsigned int py, unsigned char Bcolor, unsigned char Fcolor)
|
{
|
unsigned char tmp = 0;
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, 0x01);
|
|
while(count--)
|
{
|
tmp = pgm_read_byte(item++);
|
DSP16x24(px, py, _16_24[tmp]);
|
px += interval;
|
}
|
}
|
//
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%12x16%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
void DSP12x16Str(const unsigned char *item, unsigned char count, unsigned char interval,
|
unsigned int px, unsigned int py, unsigned char Bcolor, unsigned char Fcolor)
|
{
|
unsigned char tmp = 0;
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, 0x11);
|
|
while(count--)
|
{
|
tmp = pgm_read_byte(item++);
|
DSP12x16(px, py,_12_16[tmp]);
|
px += interval;
|
}
|
}
|
//
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
void DSPSpace48x48(unsigned int px, unsigned int py,
|
unsigned char Bcolor, unsigned char Fcolor)
|
{
|
unsigned char x,y;
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, 0x01);
|
|
for(y=0; y<48; y++)
|
{
|
Local_TFT_XY(px, py++);
|
|
//--------- Ìî³äÊý¾Ý ----------
|
for(x=0; x<6; x++)
|
{
|
Write_TFT_Data(0xFF);
|
}
|
}
|
}
|
//
|
|
void DrawButtonH48(const unsigned char btnlong, const unsigned char *caption, const unsigned char count, const unsigned char interval,
|
const unsigned char startpos, const unsigned int px, const unsigned int py, const unsigned char Bcolor, const unsigned char Fcolor)
|
{
|
unsigned char n;
|
for(n=0; n<btnlong; n++)
|
{
|
DSPSpace48x48(px+48*n, py, Bcolor, Bcolor);
|
}
|
|
for(n=0; n<4; n++)
|
{
|
DrawLine(px+48*btnlong+n, py+n+1, 6, 1, gray2, gray2, linebold, 1);
|
}
|
for(n=0; n<4; n++)
|
{
|
DrawLine(px+n+1, py+48+n, 6*btnlong, 0, gray2, gray2, linebold, 1);
|
}
|
|
//#if(SoftLanguage == CN)
|
DSP16x24Str(caption, count, interval, px+startpos, py+12, Bcolor, Fcolor);
|
/*#else
|
n = 0;
|
if(btnlong == 2)
|
{
|
unsigned char str;
|
const unsigned char *item = caption;
|
do
|
{
|
str = pgm_read_byte(item++);
|
if((str>0) && (str<=0x5a))
|
n += 16;
|
else if(str > 0x5a)
|
n += 12;
|
}
|
while(str);
|
}
|
if(n > 96)
|
n = 0;
|
else n = (96-n)/2;
|
|
DSP16x24Str(caption, count, interval, px+n, py+12, Bcolor, Fcolor);
|
#endif*/
|
|
|
}
|
//
|
void DrawButtonH481(const unsigned char btnlong, const unsigned char *caption, const unsigned char count, const unsigned char interval,
|
const unsigned char startpos, const unsigned int px, const unsigned int py, const unsigned char Bcolor, const unsigned char Fcolor)
|
{
|
unsigned char n;
|
for(n=0; n<btnlong; n++)
|
{
|
DSPSpace48x48(px+48*n, py, Bcolor, Bcolor);
|
}
|
|
for(n=0; n<4; n++)
|
{
|
DrawLine(px+48*btnlong+n, py+n+1, 6, 1, gray2, gray2, linebold, 1);
|
}
|
for(n=0; n<4; n++)
|
{
|
DrawLine(px+n+1, py+48+n, 6*btnlong, 0, gray2, gray2, linebold, 1);
|
}
|
DSP12x16Str(caption, count, interval, px+startpos, py+16, Bcolor, Fcolor);
|
}
|
|
void FormatValue(unsigned char *pformat, const unsigned int value,
|
const char *type, const unsigned char pointcount)
|
{
|
switch(pointcount)
|
{
|
case 0: *pformat++ = value/10000 + 0x30;
|
*pformat++ = (value%10000)/1000 + 0x30;
|
*pformat++ = (value%1000)/100 + 0x30;
|
*pformat++ = (value%100)/10 + 0x30;
|
*pformat++ = value%10 + 0x30;
|
break;
|
case 1: *pformat++ = value/10000 + 0x30;
|
*pformat++ = (value%10000)/1000 + 0x30;
|
*pformat++ = (value%1000)/100 + 0x30;
|
*pformat++ = (value%100)/10 + 0x30;
|
*pformat++ = '.';
|
*pformat++ = value%10 + 0x30;
|
break;
|
case 2: *pformat++ = value/10000 + 0x30;
|
*pformat++ = (value%10000)/1000 + 0x30;
|
*pformat++ = (value%1000)/100 + 0x30;
|
*pformat++ = '.';
|
*pformat++ = (value%100)/10 + 0x30;
|
*pformat++ = value%10 + 0x30;
|
break;
|
case 3: *pformat++ = value/10000 + 0x30;
|
*pformat++ = (value%10000)/1000 + 0x30;
|
*pformat++ = '.';
|
*pformat++ = (value%1000)/100 + 0x30;
|
*pformat++ = (value%100)/10 + 0x30;
|
*pformat++ = value%10 + 0x30;
|
break;
|
}
|
|
while(*type)
|
{
|
*pformat++ = *type++;
|
}
|
}
|
//
|
|
void PrintValue1(unsigned char startindex, unsigned char pointcount, const unsigned int value, const char *type,
|
unsigned char interval, unsigned int px, unsigned int py, unsigned char Bcolor, unsigned char Fcolor)
|
{
|
unsigned char format[15] = {0};
|
unsigned char index = 0;
|
FormatValue(format, value, type, pointcount);
|
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, 0x11);
|
|
index = startindex;
|
while(format[index] != 0)
|
{
|
DSP12x16(px, py, _12_16[format[index++]-0x20]);
|
px += interval;
|
}
|
}
|
void PrintValue(unsigned char startindex, unsigned char pointcount, const unsigned int value, const char *type,
|
unsigned char interval, unsigned int px, unsigned int py, unsigned char Bcolor, unsigned char Fcolor)
|
{
|
unsigned char format[15] = {0};
|
unsigned char index = 0;
|
FormatValue(format, value, type, pointcount);
|
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, 0x01);
|
|
index = startindex;
|
while(format[index] != 0)
|
{
|
DSP16x24(px, py, _16_24[format[index++]-0x20]);
|
px += interval;
|
}
|
}
|
//
|
|
void PrintValueEx(unsigned char startindex, unsigned char pointcount, const unsigned int value, unsigned char interval,
|
unsigned int px, unsigned int py, unsigned char Bcolor, unsigned char Fcolor)
|
{
|
unsigned char format[15] = {0};
|
unsigned char index = 0;
|
FormatValue(format, value, "", pointcount);
|
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, 0x01);
|
|
index = startindex;
|
while(format[index] != 0)
|
{
|
DSP24x24(px, py, _24_24[format[index]-0x30]);
|
index++;
|
px += interval;
|
}
|
}
|
//
|
|
void DSP8x11Str(const unsigned char *item, unsigned char count, unsigned char interval,
|
unsigned int px, unsigned int py, unsigned char Bcolor, unsigned char Fcolor)
|
{
|
unsigned char tmp = 0;
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, 0x01);
|
|
while(count--)
|
{
|
tmp = pgm_read_byte(item++);
|
DSP8x11(px, py, _8_11[tmp]);
|
px += interval;
|
}
|
}
|
//
|
|
void DSP8x11Value(unsigned char startindex, unsigned char pointcount, const unsigned int value, const char *type, unsigned char interval,
|
unsigned int px, unsigned int py, unsigned char Bcolor, unsigned char Fcolor)
|
{
|
unsigned char format[15] = {0};
|
unsigned char index = 0;
|
FormatValue(format, value, type, pointcount);
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, 0x01);
|
index = startindex;
|
while(format[index] != 0)
|
{
|
DSP8x11(px, py, _8_11[format[index++]-0x20]);
|
px += interval;
|
}
|
}
|
//
|
|
void PrintTime(const void *time, unsigned char interchar, unsigned char time_type,
|
unsigned int px, unsigned int py, unsigned char Bcolor, unsigned char Fcolor)
|
{
|
|
unsigned char format[20] = {0};
|
unsigned char index = 0;
|
if(time_type == YYMDHMS)
|
{
|
format[0] = ((Date_Time*)time)->day / 10 + 0x30;
|
format[1] = ((Date_Time*)time)->day % 10 + 0x30;
|
format[2] = '-';
|
format[3] = ((Date_Time*)time)->month / 10 + 0x30;
|
format[4] = ((Date_Time*)time)->month % 10 + 0x30;
|
format[5] = '-';
|
format[6] = '2';
|
format[7] = '0';
|
format[8] = ((Date_Time*)time)->year / 10 + 0x30;
|
format[9] = ((Date_Time*)time)->year % 10 + 0x30;
|
format[10] = ' ';
|
format[11] = ((Date_Time*)time)->hour / 10 + 0x30;
|
format[12] = ((Date_Time*)time)->hour % 10 + 0x30;
|
format[13] = ':';
|
format[14] = ((Date_Time*)time)->minute / 10 + 0x30;
|
format[15] = ((Date_Time*)time)->minute % 10 + 0x30;
|
format[16] = ':';
|
format[17] = ((Date_Time*)time)->second / 10 + 0x30;
|
format[18] = ((Date_Time*)time)->second % 10 + 0x30;
|
}
|
else if(time_type == YMDHM)
|
{
|
format[0] = ((Date_Time*)time)->day / 10 + 0x30;
|
format[1] = ((Date_Time*)time)->day % 10 + 0x30;
|
format[2] = '-';
|
format[3] = ((Date_Time*)time)->month / 10 + 0x30;
|
format[4] = ((Date_Time*)time)->month % 10 + 0x30;
|
format[5] = '-';
|
format[6] = ((Date_Time*)time)->year / 10 + 0x30;
|
format[7] = ((Date_Time*)time)->year % 10 + 0x30;
|
format[8] = ' ';
|
format[9] = ((Date_Time*)time)->hour / 10 + 0x30;
|
format[10] = ((Date_Time*)time)->hour % 10 + 0x30;
|
format[11] = ':';
|
format[12] = ((Date_Time*)time)->minute / 10 + 0x30;
|
format[13] = ((Date_Time*)time)->minute % 10 + 0x30;
|
}
|
else if(time_type == YYMD)
|
{
|
format[0] = ((Date_Time*)time)->day / 10 + 0x30;
|
format[1] = ((Date_Time*)time)->day % 10 + 0x30;
|
format[2] = '-';
|
format[3] = ((Date_Time*)time)->month / 10 + 0x30;
|
format[4] = ((Date_Time*)time)->month % 10 + 0x30;
|
format[5] = '-';
|
format[6] = '2';
|
format[7] = '0';
|
format[8] = ((Date_Time*)time)->year / 10 + 0x30;
|
format[9] = ((Date_Time*)time)->year % 10 + 0x30;
|
}
|
else if(time_type == YMD_HMS)
|
{
|
format[0] = ((Date_Time*)time)->hour / 10 + 0x30;
|
format[1] = ((Date_Time*)time)->hour % 10 + 0x30;
|
format[2] = ':';
|
format[3] = ((Date_Time*)time)->minute / 10 + 0x30;
|
format[4] = ((Date_Time*)time)->minute % 10 + 0x30;
|
format[5] = ':';
|
format[6] = ((Date_Time*)time)->second / 10 + 0x30;
|
format[7] = ((Date_Time*)time)->second % 10 + 0x30;
|
}
|
else if(time_type == HMS)
|
{
|
format[0] = ((Test_Time*)time)->hour / 10 + 0x30;
|
format[1] = ((Test_Time*)time)->hour % 10 + 0x30;
|
format[2] = ':';
|
format[3] = ((Test_Time*)time)->minute / 10 + 0x30;
|
format[4] = ((Test_Time*)time)->minute % 10 + 0x30;
|
format[5] = ':';
|
format[6] = ((Test_Time*)time)->second / 10 + 0x30;
|
format[7] = ((Test_Time*)time)->second % 10 + 0x30;
|
}
|
else if(time_type == HM)
|
{
|
format[0] = ((Test_Time*)time)->hour / 10 + 0x30;
|
format[1] = ((Test_Time*)time)->hour % 10 + 0x30;
|
format[2] = 'H';
|
format[3] = ((Test_Time*)time)->minute / 10 + 0x30;
|
format[4] = ((Test_Time*)time)->minute % 10 + 0x30;
|
format[5] = 'M';
|
}
|
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, 0x01);
|
|
index = 0;
|
while(format[index] != 0)
|
{
|
DSP16x24(px, py, _16_24[format[index++]-0x20]);
|
px += 16;
|
}
|
}
|
//
|
void PrintTime1(const void *time, unsigned char interchar, unsigned char time_type,
|
unsigned int px, unsigned int py, unsigned char Bcolor, unsigned char Fcolor)
|
{
|
|
unsigned char format[20] = {0};
|
unsigned char index = 0;
|
if(time_type == YYMDHMS)
|
{
|
format[0] = '2';
|
format[1] = '0';
|
format[2] = ((Date_Time*)time)->year / 10 + 0x30;
|
format[3] = ((Date_Time*)time)->year % 10 + 0x30;
|
format[4] = '-';
|
format[5] = ((Date_Time*)time)->month / 10 + 0x30;
|
format[6] = ((Date_Time*)time)->month % 10 + 0x30;
|
format[7] = '-';
|
format[8] = ((Date_Time*)time)->day / 10 + 0x30;
|
format[9] = ((Date_Time*)time)->day % 10 + 0x30;
|
format[10] = ' ';
|
format[11] = ((Date_Time*)time)->hour / 10 + 0x30;
|
format[12] = ((Date_Time*)time)->hour % 10 + 0x30;
|
format[13] = ':';
|
format[14] = ((Date_Time*)time)->minute / 10 + 0x30;
|
format[15] = ((Date_Time*)time)->minute % 10 + 0x30;
|
format[16] = ':';
|
format[17] = ((Date_Time*)time)->second / 10 + 0x30;
|
format[18] = ((Date_Time*)time)->second % 10 + 0x30;
|
}
|
else if(time_type == YMDHM)
|
{
|
format[0] = ((Date_Time*)time)->year / 10 + 0x30;
|
format[1] = ((Date_Time*)time)->year % 10 + 0x30;
|
format[2] = '-';
|
format[3] = ((Date_Time*)time)->month / 10 + 0x30;
|
format[4] = ((Date_Time*)time)->month % 10 + 0x30;
|
format[5] = '-';
|
format[6] = ((Date_Time*)time)->day / 10 + 0x30;
|
format[7] = ((Date_Time*)time)->day % 10 + 0x30;
|
format[8] = ' ';
|
format[9] = ((Date_Time*)time)->hour / 10 + 0x30;
|
format[10] = ((Date_Time*)time)->hour % 10 + 0x30;
|
format[11] = ':';
|
format[12] = ((Date_Time*)time)->minute / 10 + 0x30;
|
format[13] = ((Date_Time*)time)->minute % 10 + 0x30;
|
}
|
else if(time_type == YYMD)
|
{
|
format[0] = '2';
|
format[1] = '0';
|
format[2] = ((Date_Time*)time)->year / 10 + 0x30;
|
format[3] = ((Date_Time*)time)->year % 10 + 0x30;
|
format[4] = '-';
|
format[5] = ((Date_Time*)time)->month / 10 + 0x30;
|
format[6] = ((Date_Time*)time)->month % 10 + 0x30;
|
format[7] = '-';
|
format[8] = ((Date_Time*)time)->day / 10 + 0x30;
|
format[9] = ((Date_Time*)time)->day % 10 + 0x30;
|
}
|
else if(time_type == YMD_HMS)
|
{
|
format[0] = ((Date_Time*)time)->hour / 10 + 0x30;
|
format[1] = ((Date_Time*)time)->hour % 10 + 0x30;
|
format[2] = ':';
|
format[3] = ((Date_Time*)time)->minute / 10 + 0x30;
|
format[4] = ((Date_Time*)time)->minute % 10 + 0x30;
|
format[5] = ':';
|
format[6] = ((Date_Time*)time)->second / 10 + 0x30;
|
format[7] = ((Date_Time*)time)->second % 10 + 0x30;
|
}
|
else if(time_type == HMS)
|
{
|
format[0] = ((Test_Time*)time)->hour / 10 + 0x30;
|
format[1] = ((Test_Time*)time)->hour % 10 + 0x30;
|
format[2] = ':';
|
format[3] = ((Test_Time*)time)->minute / 10 + 0x30;
|
format[4] = ((Test_Time*)time)->minute % 10 + 0x30;
|
format[5] = ':';
|
format[6] = ((Test_Time*)time)->second / 10 + 0x30;
|
format[7] = ((Test_Time*)time)->second % 10 + 0x30;
|
}
|
else if(time_type == HM)
|
{
|
format[0] = ((Test_Time*)time)->hour / 10 + 0x30;
|
format[1] = ((Test_Time*)time)->hour % 10 + 0x30;
|
format[2] = 'H';
|
format[3] = ((Test_Time*)time)->minute / 10 + 0x30;
|
format[4] = ((Test_Time*)time)->minute % 10 + 0x30;
|
format[5] = 'M';
|
}
|
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, 0x11);
|
|
index = 0;
|
while(format[index] != 0)
|
{
|
DSP12x16(px, py, _12_16[format[index++]-0x20]);
|
px += 12;
|
}
|
}
|
|
void DrawARect(unsigned int px, unsigned int py, unsigned int len,
|
unsigned char Bcolor, unsigned char Fcolor)
|
{
|
unsigned int count = len;
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, 0x01);
|
|
while(count--)
|
{
|
Local_TFT_XY(px, py--);
|
//----- Ìî³äÊý¾Ý -----
|
Write_TFT_Data(0xff);
|
Write_TFT_Data(0xff);
|
}
|
}
|
//
|
|
void DrawLine(unsigned int px, unsigned int py, unsigned char len, unsigned char direction,
|
unsigned char Bcolor, unsigned char Fcolor, const unsigned char style, unsigned char width)
|
{
|
unsigned char incdiretion;
|
unsigned char linelen;
|
if(direction == 0)
|
incdiretion = 0x01; //Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ
|
else incdiretion = 0x11; //Ö¸ÕëÑØyÖá·½ÏòÒÆ¶¯,8µãдģʽ
|
//---- ÉèÖñ³¾°É«,ǰ¾°É«,Ö¸ÕëÑØxÖá·½ÏòÒÆ¶¯,8µãдģʽ -----
|
SetBLFLIncdirection(Bcolor, Fcolor, incdiretion);
|
while(width--)
|
{
|
Local_TFT_XY(px, py);
|
//---- Ìî³äÊý¾Ý -------
|
linelen = len;
|
while(linelen--)
|
{
|
Write_TFT_Data(style);
|
}
|
|
if(direction == 0)
|
{
|
py++;
|
}
|
else
|
{
|
px++;
|
}
|
}
|
}
|
//
|
|