
// 기본 헤더
#define	__STDIO_FDEVOPEN_COMPAT_12


#include <stdint.h>
#include <stdio.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

#include "tftlcd.h"
#include "init.h"
#include "image.h"
#include "touch.h"

//#include "sample1.h"						// 이미지 파일 8bit  200*120

void uartdisplay(void)
{

    printf("%s","****  signaltech ver 0.1  2009/10/14 **\n");
	printf("%s","*  TFT LCD Test Main UART0 38400bps   *\n");
	printf("%s","*  1  =>  red_set              \n");
	printf("%s","*  2  =>  Dot test             \n");
	printf("%s","*  3  =>  8 DEMO 		  	    \n");
	printf("%s","*  4  =>  16 DEMO      		\n");
	printf("%s","*  C,c =>  Clear  	 	    	\n");
	printf("%s","*  L,l =>  Dot test		    \n");
	printf("%s","*  R,r =>  Rectangle  		 	\n");
	printf("%s","***************************************\n");
	printf("test number or  character input :\n");

 }
 


int main(void)
{
 // unsigned char RXD;  
unsigned char bird_frame;

  init();
 
 
 
  TSC2003_Setup();
  printf("%s","****  signaltech ver 0.1  2011/04/10 **\n");
	printf("%s","*  TFT LCD Test Main UART0 38400bps   *\n");
		
		stdout = &device1;   
  uartdisplay();
 TFT_SET();
 LCD_ON();
 lcd_cmd(0x0202);
  	LCD_Clear(); 	
Demo_display_8_color(); 
	delay_ms(500);
	delay_ms(500);
	delay_ms(500);
	delay_ms(500);
	LCD_Clear(); 	
	//Image_Disp_8bit(_SCREEN_COLUMN_SET,60,60,200,120,image_temp8_1);// 작은 이미지 데이터 표시 32000Byte 이내(sample2_8.txt)
//	Image_Disp_8bit(ScreenSet,60,60,200,120,image_temp8_1);// 작은 이미지 데이터 표시 32000Byte 이내(sample2_8.txt)

// sample3_16.txt
//	Image_Screen_Disp_16bit(ScreenSet,60,45,200,150,image_temp16_1,image_temp16_2,image_temp16_1,image_temp16_1,image_temp16_1);// 이미지 데이터 표시 32000Byte 이상
 //bird_frame=0;
//	draw_bird0(); draw_bird1(0);	// draw bird image on to the LCD screen.
unsigned int i, cut, x, y, color;

	while(1)
	{ 

      TFT_string( 0,1,WHITE,  Transparent,"    test  ");
      TFT_string( 10,5,RED,    Transparent," 빨강  Red ");
      TFT_string(15,10,GREEN,  Transparent," 녹색 Gre ");
      TFT_string(19,15,BLUE,   Transparent,"  Blu ");
      TFT_string(20,20,YELLOW, Transparent,"  Yel ");     
	 // TFT_string(60,32,CYAN,   Transparent," 녹청 Cya ");
    //  TFT_string(80,32,MAGENTA,Transparent," 자홍 Mag ");

//for(cut = 0; cut <= 6; cut++)		// 머리를 숙이는 동작
     
  
  /*    delay_ms(500);

      for(cut = 7; cut > 0; cut--)		// 다시 되돌아 오는 동작
        { i = 0;
	  for(y = 0; y < 57; y++)
            for(x = 0; x < 32; x++)
              { color = pgm_read_word(&girl[cut-1][i++]);
                tftlcdSetPixel(x+104,y+150, color);
              }
          delay_ms(100);
        }
      delay_ms(2000);
   

	LCD_Clear(); 
*/



/*	
if(com1_rx_flg){					// COM1 수신 검사
	  		putchar(com1_rx_data);
		//	com1_rx_flg = 0;

//	RXD = RX0_char_scan();
    switch(com1_rx_data)
  {
	case '1':
		{
	//	Putchxy(100,100,'1');
	//	tftlcdImageWrite(90, 100, 60, 75, mainImage);
		delay_ms(500);
	//	tftlcdImageWrite(90, 100, 60, 75, mainImage);
		delay_ms(500);delay_ms(500);delay_ms(500);
	//	red_set(); 	
		printf(" 1"); }
		break;
	case '2':  
		{   LCD_gotoxy(120,125);  LCD_Dot(0xffe0);
		LCD_gotoxy(120,130); LCD_Dot(0xffff); 
        LCD_gotoxy(120,135);  LCD_Dot(0xffe0); 
	  	printf(" 2 ");
	    }
		break;
	case '3':
		{Demo_display_8_color();  	printf(" 3"); }
		break;
	case '4':
		{Demo_display_16_gray(); 		printf(" 4"); }
		break;
	case '5':
		{
		LCD_Clear(); 	
		tftlcdWriteChar(1,1,"B",0x001f);//1
		tftlcdPutStr(240,1,"ABDEFH",0x001f);
		printf(" 3"); }
		break;
	case '6':
		{
		//	tftlcdPutStr(7,3,"ABCDEFGHIJKLMNOPQRSTUVWXYZ",0xf800 );
		//tftlcdPutStr(5,5,"AA",0x07e0);
		tftlcdPutStr(25,5,"BBB",0x08e0);
		tftlcdPutStr(40,5,"iii",0x19e0);
		tftlcdPutStr(60,5,"QQQ",0x3ae0);
		tftlcdPutStr(80,5,"WWW",0x9be0);
		tftlcdPutStr(100,5,"RRR",0xace0);
		tftlcdPutStr(160,5,"YYY",0xbde0);

		tftlcdPutStr(200,5,"(**Y",0xf800);
		tftlcdPutStr(240,5,"(..)",0x001f);
		tftlcdPutStr(280,5,"Y^^Y",0xffff);

		tftlcdPutStr(350,5,"HHHH",0xdee0);
		tftlcdPutStr(390,5,"B",0xefe0);
		tftlcdPutStr(395,5,"7",0xf7e0);
		printf(" 3"); }
		break;

	case '7':
		{
	tftlcdPutStr(5,5,"ABC",0x10e0);
	tftlcdPutStr(5,15,"DEF",0x21e0);
	tftlcdPutStr(5,25,"GHI",0x32e0);
	tftlcdPutStr(5,40,"JKL",0x43e0);
	tftlcdPutStr(5,85,"MNO",0x54e0);
	tftlcdPutStr(5,100,"PQR",0x65e0);
	tftlcdPutStr(5,145,"STU",0x76e0);


	tftlcdPutStr(5,230,"$$$$$$$$$$$",0x80e0);


			
tftlcdPutStr(15,200,"@@@@@@@@@",0x97e0);



}
	break;


	case 'c':
	case 'C':
		{	LCD_Clear();   printf(" C");     }
	break;

	case 'l':
	case 'L':
	{	Line(0,0,399,239,GREEN);  	printf(" L");   }

     	break;


	case 'r':
	case 'R':
	{Rectangle(20,70,100,200,RED); 		printf(" R");  }
		break;

	case 't':
	case 'T':
		{Rectangle(20,70,100,200,RED); 		printf(" T");  }

	case '0':
		{ uartdisplay();		printf(" 0"); }
			break;


	default://  LCD_Clear();	
		{
	
		com1_rx_flg = 0;
	
		}
		
		}
		com1_rx_flg = 0;
	
	//{ 	delay_ms(500); 	deLCD_Clear();lay_ms(500);	delay_ms(500);	     LCD_Clear();
 	// 	}
	//red_set();
		//delay_ms(500);	delay_ms(500);
		//Demo_display_16_gray();
 		//delay_ms(500);	delay_ms(500);
  	
	
		
	
	  }  //switch
	if(Touch_Data(30)){					// 터치 데이터 검사 300ms마다
			printf("touch > (x)%d : (y)%d\r\n",Touch_X,Touch_Y);
						}
	
*/
	
	
	}  //while
}  //main
