Çin malı telefon ekranları

Başlatan serdararikan, 05 Mart 2010, 22:39:33

bocek

#420
Yok hocam pin tanımlarında sorun yok eline sağlık. Sorun MCU'nun (atmega16A smd) DB0 hattına bağlı bacağının pad ile temasının kesilmesi imiş.
Şu anda lcd çalışıyor. Emeği geçenlere teşekkürler.

Toparlamak babında pin dizilimini tekrar vereyim:
// YT36F05CIA-FPC-B PINOUT
// Çin Malı Nokia N8 ekranı
// Kontrolcü : ILI9327 400x240 piksel
1   GND
2   X+
3   Y+
4   X-
5   Y-
6   GND
7   LED-A // arka aydınlatma Voltajı 5V veya 3.3V olabilir
8   LED-K1
9   LED-K2
10   LED-K3
11   LED-K4
12   LED-K5
13   LED-K6
14   /RST
15   D15
16   D14
17   D13
18   D12
19   D11
20   D10
21   D9
22   D8
23   D7
24   D6
25   D5
26   D4
27   D3
28   D2
29   D1
30   D0
31   IM0 (8bit/16Bit arayüz seçimi, 16-bit için GND, 8-bit için VCC)
32   /RD
33   /WR
34   D/C (RS)
35   /CS
36   FMARK // boşta kalabilir.
37   VCC // 3.3V
38   IOVCC // 3.3V
39   GND




Atmega16A için deneme kodu:

#include <avr/io.h>
#include <util/delay.h>

// ILI9327 400x240 TFT LCD Demo Code for Atmega16
// bocek 04.07.2013

#define  LCD_DataPortH PORTD     //¸ß8λÊı¾İ¿Ú,8λģʽÏÂֻʹÓøß8λ
#define  LCD_DataPortL PORTB     //µÍ8λÊı¾İ¿Ú	,8λģʽϵÍ8λ¿ÉÒÔ²»½ÓÏß,ÇëÈ·ÈÏP0¿ÚÒѾ­ÉÏÀ­10Kµç×è,²»ÒËÌ«Ğ¡£¬×îĞ¡4.7K,ÍƼö10K.
#define LCD_DDRL DDRB
#define LCD_PINL PINB
#define LCD_DDRH DDRD
#define LCD_PINH PIND

#define LCD_OUTPUT LCD_DDRL=0xff;LCD_DDRH=0xff
#define LCD_INPUT LCD_DDRL=0;LCD_DDRH=0

#define LCD_ControlPort PORTA
#define LCD_ControlDDR DDRA

#define LCD_RD_PIN 6  		 //Êı¾İ/ÃüÁîÇĞ»»
#define LCD_WR_PIN 5		  //Ğ´¿ØÖÆ
#define LCD_RS_PIN 4		     //¶Á¿ØÖÆ
#define LCD_CS_PIN 3		//Ƭѡ
#define LCD_RESET_PIN 7	      //¸´Î»

#define CS_0 LCD_ControlPort &= ~(1<<LCD_CS_PIN)
#define CS_1 LCD_ControlPort |=  (1<<LCD_CS_PIN)
#define RS_0 LCD_ControlPort &= ~(1<<LCD_RS_PIN)
#define RS_1 LCD_ControlPort |=  (1<<LCD_RS_PIN)
#define WR_0 LCD_ControlPort &= ~(1<<LCD_WR_PIN)
#define WR_1 LCD_ControlPort |=  (1<<LCD_WR_PIN)
#define RD_0 LCD_ControlPort &= ~(1<<LCD_RD_PIN)
#define RD_1 LCD_ControlPort |=  (1<<LCD_RD_PIN)
#define RESET_0 LCD_ControlPort &= ~(1<<LCD_RESET_PIN)
#define RESET_1 LCD_ControlPort |=  (1<<LCD_RESET_PIN)



typedef unsigned int u16;
typedef unsigned char u8;

u16 DeviceCode;
#define  LCD_SIZE_X        240
#define  LCD_SIZE_Y        400

//=================================º¯ÊıÉùÃû=====================================//
void  Address_set(unsigned int Xstart,unsigned int Ystart,unsigned int Xend,unsigned int Yend);
void ili9327_SetCursor(unsigned int Xstart,unsigned int Ystart);
void dis_pix1( unsigned int k)    ;
void wr_comm(unsigned int index);
void wr_dat(unsigned int dat);
void wr_com(unsigned int i,unsigned int j);
void lcd_init(void);
void dis_color1(void);
void dis_color2(unsigned int j);
void dis_color3(unsigned int i,unsigned int j);
void dis_color4(unsigned int a,unsigned int b,unsigned int c,unsigned int d,unsigned int e,unsigned int f,unsigned int g,unsigned int h);
void  Delay(unsigned int t);

void  Delay(unsigned int t)
{
	unsigned int n;
	for(n=0;n<t;n++)
		_delay_ms(1);
}

//================================================================================//
void wr_comm(unsigned int index)
{

	RS_0;
	CS_0;
	LCD_DataPortL = index;
	LCD_DataPortH = index>>8;
	WR_0;
	WR_1;
	CS_1;
}
//================================================================================//
void wr_dat(unsigned int dat)
{

	RS_1;
	CS_0;
	LCD_DataPortL = dat;
	LCD_DataPortH = dat>>8;
	Delay(1);
	WR_0;
	Delay(1);
	WR_1;
	Delay(1);
	CS_1;
}
//================================write command====================================//
void wr_com(unsigned int i,unsigned int j)
{
	wr_comm(i);
	wr_dat(j);
}
//================================================================================//

void lcd_init(void)
{
	//************* Reset LCD Driver ****************//

	RESET_1;
	Delay(10);; // Delay 1ms
	RESET_0;
	Delay(15);; // Delay 10ms // This delay time is necessary
	RESET_1;
	Delay(50);; // Delay 50 ms
	wr_comm(0xE9);
	wr_dat (0x20);
	wr_comm(0x11); //Exit Sleep
	Delay(100);
	wr_comm(0xD1);
	wr_dat (0x00);
	wr_dat (0x71);
	wr_dat (0x19);
	wr_comm(0xD0);
	wr_dat (0x07);
	wr_dat (0x01);
	wr_dat (0x08);
	wr_comm(0x36);
	wr_dat (0x48);
	wr_comm(0x3A);
	wr_dat (0x05);
	wr_comm(0xC1);
	wr_dat (0x10);
	wr_dat (0x10);
	wr_dat (0x02);
	wr_dat (0x02);
	wr_comm(0xC0); //Set Default Gamma
	wr_dat (0x00);
	wr_dat (0x35);
	wr_dat (0x00);
	wr_dat (0x00);
	wr_dat (0x01);
	wr_dat (0x02);
	wr_comm(0xC5); //Set frame rate
	wr_dat (0x04);
	wr_comm(0xD2); //power setting
	wr_dat (0x01);
	wr_dat (0x44);
	wr_comm(0xC8); //Set Gamma
	wr_dat (0x04);
	wr_dat (0x67);
	wr_dat (0x35);
	wr_dat (0x04);
	wr_dat (0x08);
	wr_dat (0x06);
	wr_dat (0x24);
	wr_dat (0x01);
	wr_dat (0x37);
	wr_dat (0x40);
	wr_dat (0x03);
	wr_dat (0x10);
	wr_dat (0x08);
	wr_dat (0x80);
	wr_dat (0x00);
	wr_comm(0x2A);
	wr_dat (0x00);
	wr_dat (0x00);
	wr_dat (0x00);
	wr_dat (0xeF);
	wr_comm(0x2B);
	wr_dat (0x00);
	wr_dat (0x00);
	wr_dat (0x01);
	wr_dat (0x8F);
	
   //wr_comm(0xB3);//Frame Memory Access and Interface Setting
   //wr_dat(0x02);
   //wr_dat(0x00);
   //wr_dat(0x00);
   //wr_dat(0x20);
   
	wr_comm(0x29); //display on
	wr_comm(0x2C); //write memory start
	
	Delay(100);
}

void  Address_set(unsigned int Xstart,unsigned int Ystart,unsigned int Xend,unsigned int Yend)
{
	CS_0;
	wr_com(0x2a,Xstart<<8);
	wr_com(0x2a,Xstart);    //ÉèÖÃAC³õʼֵ(GRAM=0000)
	wr_com(0x2b,Ystart<<8);
	wr_com(0x2b,Ystart);    //ÉèÖÃAC³õʼֵ(GRAM=0000)
	wr_com(0x2a,Xend<<8);
	wr_com(0x2a,Xend);
	wr_com(0x2b,Yend<<8);
	wr_com(0x2b,Yend);
	wr_comm(0x2c);
	CS_1;
}


void ili9327_SetPoint(unsigned int x,unsigned int y,unsigned int point)
{
	//if ( (x>320)||(y>240) ) return;
	ili9327_SetCursor(x,y);

	CS_0;
	wr_comm(0x002c);
	dis_pix1(point);
	CS_1;
}
void ili9327_SetCursor(unsigned int Xstart,unsigned int Ystart)
{	wr_com(0x2a,Xstart);    //ÉèÖÃAC³õʼֵ(GRAM=0000)
	wr_com(0x2b,Ystart);    //ÉèÖÃAC³õʼֵ(GRAM=0000)
}
void dis_pix1( unsigned int k)
{
	wr_comm(0x002c);
	RS_1;
	CS_0;

	LCD_DataPortL = k;
	LCD_DataPortH = k>>8;
	WR_0;
	WR_1;
	
	CS_1;
}
//=================================µ¥É«»­Ãæ======================================//
void dis_color2(unsigned int j)
{
	unsigned int i,m;

	wr_comm(0x002c);
	RS_1;
	CS_0;
	for(i=0;i<LCD_SIZE_Y;i++)
	{
		for(m=0;m<LCD_SIZE_X;m++)
		{

			LCD_DataPortL = j;
			LCD_DataPortH = j>>8;
			WR_0;
			WR_1;
		}
	}
	CS_1;
}



void dis_color5(unsigned int a)
{
	unsigned int i,m;
	wr_comm(0x002c);
	RS_1;
	CS_0;
	for(i=0;i<50;i++)
	for(m=0;m<LCD_SIZE_X;m++)
	{
		LCD_DataPortL = a;
		LCD_DataPortH = a>>8;
		WR_0;
		WR_1;
	}
	CS_1;
}
//=============================8É«²Ê¼ä¸ô»­Ãæ======================================//
void dis_color4(unsigned int a,unsigned int b,unsigned int c,unsigned int d,unsigned int e,unsigned int f,unsigned int g,unsigned int h)
{
	unsigned int i,m;
	wr_comm(0x002c);
	RS_1;
	CS_0;
	for(i=0;i<50;i++)
	for(m=0;m<LCD_SIZE_X;m++)
	{
		LCD_DataPortL = a;
		LCD_DataPortH = a>>8;
		WR_0;
		WR_1;
	}
	for(i=0;i<50;i++)
	for(m=0;m<LCD_SIZE_X;m++)
	{
		LCD_DataPortL = b;
		LCD_DataPortH = b>>8;
		WR_0;
		WR_1;
	}
	for(i=0;i<50;i++)
	for(m=0;m<LCD_SIZE_X;m++)
	{
		LCD_DataPortL = c;
		LCD_DataPortH = c>>8;
		WR_0;
		WR_1;
	}
	for(i=0;i<50;i++)
	for(m=0;m<LCD_SIZE_X;m++)
	{
		LCD_DataPortL = d;
		LCD_DataPortH = d>>8;
		WR_0;
		WR_1;
	}
	for(i=0;i<50;i++)
	for(m=0;m<LCD_SIZE_X;m++)
	{
		LCD_DataPortL = e;
		LCD_DataPortH = e>>8;
		WR_0;
		WR_1;
	}
	for(i=0;i<50;i++)
	for(m=0;m<LCD_SIZE_X;m++)
	{
		LCD_DataPortL = f;
		LCD_DataPortH = f>>8;
		WR_0;
		WR_1;
	}
	for(i=0;i<50;i++)
	for(m=0;m<LCD_SIZE_X;m++)
	{
		LCD_DataPortL = g;
		LCD_DataPortH = g>>8;
		WR_0;
		WR_1;
	}
	for(i=0;i<50;i++)
	for(m=0;m<LCD_SIZE_X;m++)
	{
		LCD_DataPortL = h;
		LCD_DataPortH = h>>8;
		WR_0;
		WR_1;
	}
	CS_1;
}
void write_uart(u16 number)
{

	uartPuts("\n\rLCD ID=");
	uartPutchar('0'+number/10000);
	uartPutchar('0'+number/1000%10);
	uartPutchar('0'+number/100%10);
	uartPutchar('0'+number/10%10);
	uartPutchar('0'+number%10);
}
u16 LCD_Just_Read(void)
{
	u16 t;
	LCD_DataPortH=0x00;
	LCD_DataPortL=0x00;
	LCD_INPUT;
	WR_1;
	RS_1;
	CS_0;
	RD_0;
	RD_1;
	t = LCD_PINH;
	t <<=8;
	t |= LCD_PINL;
	CS_1;
	LCD_OUTPUT;
	return t;
}
u16 read_id()
{
	wr_comm(0x01); //Software reset
	wr_comm(0xef);  //Device Code Read (0xef or 0xbf)
	LCD_Just_Read();              //1th dummy read
	LCD_Just_Read();              //2th MIPI Alliance Code (02h)
	LCD_Just_Read();              //3th MIPI Alliance Code (04h)
	DeviceCode=0x00;
	DeviceCode = LCD_Just_Read();              //4th Device Code (93h)
	DeviceCode <<=8;
	DeviceCode |= LCD_Just_Read();              //5th Device Code (27h)
	write_uart(DeviceCode);
	LCD_Just_Read();							//6th exit code ffh
}
void init_ports()
{
	LCD_ControlDDR |= (1<<LCD_CS_PIN) | (1<<LCD_RS_PIN) | (1<<LCD_WR_PIN) | (1<<LCD_RD_PIN) | (1<<LCD_RESET_PIN);
	LCD_OUTPUT;
}
init_system()
{
	Uart_Init();
	init_ports();

}
//================================================================================//
void main(void)
{
	init_system();
	read_id();
	
	lcd_init();
	 Address_set(0,0,LCD_SIZE_X-1,LCD_SIZE_Y-1);
 	 dis_color2(0xf800);
	  ili9327_SetPoint(100,100,0xf800);
	    dis_color2(0xf800);         //
	  Delay(1000);
		 dis_color2(0x07e0);         //
	  Delay(1000);
		 dis_color2(0x001f);         //
	   Delay(1000);
		 dis_color2(0x07ff);         //
	   Delay(1000);
		 dis_color2(0xf81f);         //
	   Delay(1000);
		 dis_color2(0xffe0);         //
	 Delay(1000);
		 dis_color2(0xff00);         //
	  Delay(1000);
	   dis_color4(0xf800,0x07e0,0x001f,0x07ff,0xf81f,0xffe0,0x0000,0xffff); //8É«¼ä¸ô»­Ãæ
	while(1)
	{
		//dis_color4(0xf800,0x07e0,0x001f,0x07ff,0xf81f,0xffe0,0x0000,0xffff); //8É«¼ä¸ô»­Ãæ
		Delay(500);
		wr_comm(0x28); //display off
		Delay(500);
		wr_comm(0x29); //display on
	}
}
1 ya da 0. işte 'bit'ün mesele..

Burak B

Güzel. İşte budur. Tebrik ederim. Güzel çalışma olmuş. Başka LCD varsa elinde yardımcı olurum. Yeterki sonucunu göreyim. :)

ID CODE neymiş. ILI9327 doğru mu ?
"... a healthy dose of paranoia leads to better systems." Jack Ganssle

bocek

Sağol hocam sayende.
ID Code yanlış geliyor. Okuma yöntemine göre de değişiyor. Nedenini anlamadım ama boşverdim. Ama Bir ara 0x193, 0x2A okumuştum. 0x93,0x27'ye baya yaklaştım.
Başka lcd'ler de var ama şimdi uğraşamam. Seni de meşgul etmeyelim. Teşekkürler.
1 ya da 0. işte 'bit'ün mesele..

yldzelektronik

Selamlar

Elimde çin malı lcd var ve pin isimlerine ihtiyacım var.Bir de hangi kontrolcü kullanılmış,driveri gerekli.

   

 
Kişinin başına gelen hayır Allah'tandır. Kişinin başına gelen şer nefsindendir. Nefislerimizle kendimize zulüm ediyoruz.

bocek

kesin olmamakla beraber pin dizilimi bendeki ssd1299 kontrolcülü lcd'ye uyuyor
vphone, sci-phone, myphone vs isimlerle anılan çin işi çakma iphone türevi telefon ekranları bunlar.
3.2" 320x240 piksel
pinler:
// kontrolcü: ssd1299 (= ssd1298)
1	DB8
2	DB9
3	DB10
4	DB11
5	GND
6	IOVCC
7	CS
8	RS
9	WR
10	RD
11	X+
12	Y+
13	X-
14	Y-
15	LED-A
16	LED-K1
17	LED-K2
18	LED-K3
19	LED-K4
20	LED-K5
21	LED-K6
22	DB12
23	DB0
24	DB1
25	DB2
26	DB3
27	DB4
28	DB5
29	DB6
30	DB7
31	RESET
32	VDD
33	VDD
34	GND
35	DB13
36	DB14
37	DB15
1 ya da 0. işte 'bit'ün mesele..

yldzelektronik

Multimetre ile biraz baktım sanki uyuyo gibi pinler.Driver dosyasını paylaşır mısınız?Bir de elinizde yapılmış çalışan örnek var mı?
Kişinin başına gelen hayır Allah'tandır. Kişinin başına gelen şer nefsindendir. Nefislerimizle kendimize zulüm ediyoruz.

yldzelektronik

Alıntı yapılan: bocek - 12 Temmuz 2013, 00:59:21
kesin olmamakla beraber pin dizilimi bendeki ssd1299 kontrolcülü lcd'ye uyuyor
vphone, sci-phone, myphone vs isimlerle anılan çin işi çakma iphone türevi telefon ekranları bunlar.
3.2" 320x240 piksel
pinler:
// kontrolcü: ssd1299 (= ssd1298)
1	DB8
2	DB9
3	DB10
4	DB11
5	GND
6	IOVCC
7	CS
8	RS
9	WR
10	RD
11	X+
12	Y+
13	X-
14	Y-
15	LED-A
16	LED-K1
17	LED-K2
18	LED-K3
19	LED-K4
20	LED-K5
21	LED-K6
22	DB12
23	DB0
24	DB1
25	DB2
26	DB3
27	DB4
28	DB5
29	DB6
30	DB7
31	RESET
32	VDD
33	VDD
34	GND
35	DB13
36	DB14
37	DB15


Bir de lcdnin besleme gerilimi ne kadardır acaba?
Kişinin başına gelen hayır Allah'tandır. Kişinin başına gelen şer nefsindendir. Nefislerimizle kendimize zulüm ediyoruz.

bocek

#427
bende atmega16 için bir örnek var. işinize yarar mı bilmem.
sizdeki lcd'nin pinleri büyük ihtimalle doğrudur ama kontrolcü farklı olabilir (büyük ihtimalle o da aynı).

çalışan örnek için şuraya bakın:
http://www.circuitidea.com/dev-board/BL-TFT240320PLUS-V2.html

bunlar da atmega16 driver'ları (ssd1289 yazdığına bakmayın ben 1298/99'a uyarladım).

ssd1298.c
/***********************************************************************************************
*	  			  SSD1289 color Graphical LCD Display Driver
* File name		: SSD1289.c
* Programmer 	: jaruwit supa
* Web           : [url=http://www.circuitidea.com]www.circuitidea.com[/url]
* Note			: SSD1289 16 bit interface.for 8 bit use 74lv573 to latch HI byte
* Language		: avrGCC
* Hardware		: atmega16
* Date			: 01/05/2009
*************************************************************************************************
* DESCRIPTION
* ===========
* Display controller chip is ssd1289
* 16-bit data bus mode 8080
* 8-bit use 74LV573 latch Hi byte
*
* 28/11/2009     change hardware to v2.0. To support arduino I2C function. 
*
* config parameter in ssd1289.h
* #define LCD_8_BIT_MODE	  // 8 bit bus data using latch. *** Need jumpper for 8 bit *** 
* #define LCD_BL_HARDWARE	  // using black light internal jumper
* #define LCD_RESET_HARDWARE  // using hardware control reset pin to reset
* #define LCD_WRITE_ONLY	  // write only mode no read back
* #define LCD_V2			  // hardware v2 
* #define Horizontal		  // Horizontal or vertical
* #define Reverse			  // reverse direction
*
************************************************************************************************/

/* _____STANDARD INCLUDES____________________________________________________ */
#include <avr/io.h>    
#include <avr/pgmspace.h>    
//#include <util/delay.h>

#define SSD1298
//#define HX8347A
//#define HX8347D

/* _____PROJECT INCLUDES_____________________________________________________ */
#include "SSD1298.h"
#include "../color.h"


/* _____LOCAL VARIABLES______________________________________________________ */
uint16_t _color = GREEN;

/* _____PRIVATE FUNCTIONS____________________________________________________ */

/******************************************************************************************************** 
* Function    : void LCD_WaitMs(unsigned int ms)
* Description : waits (pauses) for ms milliseconds (assumes internal clock at 8MHz)
* Input       : ms is wait milliseconds
* Returns     : none 
* Notes		  : none
*********************************************************************************************************/ 
void LCD_WaitMs(unsigned int ms)
{
	int i;
	#if (F_CPU==16000000)
		#define RANGE (2*1638)
	#else // 8Mhz için..
		#define RANGE 1638
	#endif
		while (ms-- > 0)
		{
			/* 8192 (8k) clock cycles for 1ms; each time through loop
			is 5 cycles (for loop control + nop) */
			for (i = 0; i < RANGE; ++i)
					asm volatile ("nop");
		}		
}
                              
/******************************************************************************************************** 
* Function    : void LCD_WrCmd(unsigned char cmd) 
* Description : This function performs low level command write to LCD 
* Input       : cmd - is the command written to the LCD module 
* Returns     : none 
* Notes		  : Hardware specific. 
*********************************************************************************************************/ 
void LCD_WrCmd(unsigned char cmd) 
{ 
	LCD_OUTPUT();
	LCD_SET_DBL(cmd);
	LCD_SET_DBH(cmd >> 8);
    LCD_CLR_CS();	// clear CS pin to ENABLE LCD
    LCD_CLR_RS();
	LCD_CLR_WR();
	LCD_SET_WR();

 //   LCD_SET_CS();	// set CS pin to DISABLE LCD
	LCD_SET_RS();	// set default data mode
} 

/******************************************************************************************************** 
* Function    : void LCD_WrDat(unsigned int val) 
* Description : This function performs low level display data write to LCD 
* Arguments   : val - is the data written to the LCD module 
* Returns     : none 
* Notes		  : Hardware specific. 
********************************************************************************************************/ 
void LCD_WrDat(unsigned int val) 
{ 
//    LCD_CLR_CS();				// clear CS pin to ENABLE LCD 

//	LCD_SET_RS();				// use default setting
	LCD_SET_DBL(val);
	LCD_SET_DBH(val>>8);
	LCD_CLR_WR();
	LCD_SET_WR();

    LCD_SET_CS();	// set CS pin to DISABLE LCD 
	LCD_INPUT();
} 
/*********************************************************************************************************
* Function:  void LCD_SetReg(unsigned char index, unsigned int val)
* Input       : index - register number
*             : val   - value to be set
* Returns     : none
* Notes		  : Hardware specific. 
**********************************************************************************************************/
void LCD_SetReg(unsigned char index, unsigned int val)
{
	LCD_WrCmd(index);
	LCD_WrDat(val);
}

/*********************************************************************************************************
* Function    : unsigned int LCD_GetReg(unsigned char index)
* Description : This function performs low level read data register from LCD 
* Input:      : index - register number
* Return      : register data
* Notes		  : none
**********************************************************************************************************/
#ifndef LCD_8_BIT
unsigned int LCD_GetReg(unsigned char index)
{
	unsigned int ret;

    LCD_CLR_CS();	// clear  CS pin to ENABLE LCD 

	LCD_CLR_RS();
	LCD_SET_DBH(index >> 8);
	LCD_SET_DBL(index);
	LCD_CLR_WR();
	LCD_SET_WR();

	LCD_INPUT();				// input mode
	LCD_CLR_RD();
	asm volatile ("nop");
	ret = LCD_GET_DBH();
	ret <<= 8;
	ret |= LCD_GET_DBL();
	LCD_SET_RD();
    LCD_SET_CS();	// set CS pin to DISABLE LCD 

	LCD_OUTPUT();				// output data
	return ret;	
}
#endif
/*********************************************************************************************************
* Function    : void LCD_InitPort(void)
* Description : This function init lcd io
* Input       : none
* Returns     : none
* Notes		  : none
**********************************************************************************************************/
void LCD_InitPort(void)
{
	LCD_MODE();		// virtual init for 8/16 bit mode. make sure set jumper for 8/16 bit mode

	// set default
	LCD_SET_CS();
	LCD_SET_RS();
	LCD_SET_WR();
	LCD_SET_RD();
	LCD_SET_RST();

	// init direction
	LCD_DIR_CS(1);
	LCD_DIR_RS(1);
	LCD_DIR_WR(1);
	LCD_DIR_RD(1);
	LCD_DIR_RST(1);

//	LCD_SET_DBH(0xFF);
//	LCD_SET_DBL(0xFF);
	LCD_OUTPUT();
	
	LCD_CLR_CS();
	LCD_CLR_RST();
	// reset module
	LCD_WaitMs(10);
	LCD_SET_RST();
	LCD_WaitMs(120);
}

/* _____PUBLIC FUNCTIONS_____________________________________________________ */

/*********************************************************************************************************
* Function    : void LCD_Reset(void)
* Description : This function reset lcd module
* Input:      : none
* Returns      : none
* Notes		  : none
**********************************************************************************************************/
#ifdef SSD1298
void LCD_Reset(void)
{
	LCD_InitPort();
	LCD_WrCmd(0x0028);LCD_WrDat(0x0006);
	LCD_WrCmd(0x0000);LCD_WrDat(0x0001); //Start Oscillation OSCEN=1
//	LCD_WaitMs(15);

	LCD_WrCmd(0x0003);LCD_WrDat(0xAEA4); //Power Control (1) Line frequency and VHG,VGL voltage
	LCD_WrCmd(0x000C);LCD_WrDat(0x0004); //Power Control (2) VCIX2 output voltage
	LCD_WrCmd(0x000D);LCD_WrDat(0x000C); //Power Control (3) Vlcd63 voltage
	LCD_WrCmd(0x000E);LCD_WrDat(0x2800); //Power Control (4) VCOMA voltage VCOML=VCOMH*0.9475-VCOMA
	LCD_WrCmd(0x001E);LCD_WrDat(0x00B5); //Power Control (5) VCOMH voltage

//	LCD_WaitMs(15);
#ifdef Reverse
	LCD_WrCmd(0x0001);LCD_WrDat(0x393F); //Driver Output Control RL=0, REV=1, BGR=1, TB=0
#else
	LCD_WrCmd(0x0001);LCD_WrDat(0x3B3F); //Driver Output Control RL=0, REV=1, BGR=1, TB=1 
#endif
	LCD_WrCmd(0x0002);LCD_WrDat(0x0600); //LCD Driver AC control
	// Restore VSYNC mode from low power state 
	LCD_WrCmd(0x0010);LCD_WrDat(0x0000); //Sleep mode cancel
	LCD_WrCmd(0x0011);LCD_WrDat(0x6830); //Entry Mode
										// DFM   0x4000 = 262L color
										// DFM   0x6000 = 65K color
										// AM    0x0000 = horizontal display
										// AM    0x0008 = Vertical display
										// ID[0] 0x0000 = horizontal decrement
										// ID[0] 0x0010 = horizontal increment
										// ID[1] 0x0000 = Vertical decrement
										// ID[1] 0x0020 = Vertical increment

//	LCD_WaitMs(30);
	LCD_WrCmd(0x0005);LCD_WrDat(0x0000); // Compare register
	LCD_WrCmd(0x0006);LCD_WrDat(0x0000); // Compare register
	// Horizontal and Vertical porch are for DOTCLK mode operation
	LCD_WrCmd(0x0016);LCD_WrDat(0xEF1C); // Horizontal Porch 
//	LCD_WrCmd(0x0017);LCD_WrDat(0x0003); // Vertical Porch
	// Display Control
	LCD_WrCmd(0x0007);LCD_WrDat(0x0033); // Display Control
										 // D1 0x0000 = display off
										 // D1 0x0002 = display on
										 // D0 0x0000 = internal display halt
										 // D0 0x0001 = internal display operate

	LCD_WrCmd(0x000B);LCD_WrDat(0x0000); // Frame cycle control
	LCD_WrCmd(0x000F);LCD_WrDat(0x0000); // Gate Scan Position 
//	LCD_WaitMs(20);
	// Vertical Scroll Control
	LCD_WrCmd(0x0041);LCD_WrDat(0x0000); // Vertical Scroll Control
	LCD_WrCmd(0x0042);LCD_WrDat(0x0000); // Vertical Scroll Control

	// 1st Screen driving position
	LCD_WrCmd(0x0048);LCD_WrDat(0x0000); // Start position. 0 (First window start)
	LCD_WrCmd(0x0049);LCD_WrDat(0x013F); // End position.   319 (First window end)
		// 2nd Screen driving position
	LCD_WrCmd(0x004a);LCD_WrDat(0x0000); //  Second window start (Start position. 0)
	LCD_WrCmd(0x004b);LCD_WrDat(0x0000); //  Second window end (End position.   0)

	// Source RAM address
	LCD_WrCmd(0x0044);LCD_WrDat(0xEF00); //Horizontal RAM address position start/end setup 
										 //0xEF=dec 239 
										 //dec 0, i.e. horizontal ranges from 0 -> 239 
										 //POR value is 0xEF00 anyway. This address must be set before RAM write 

	LCD_WrCmd(0x0045);LCD_WrDat(0x0000); //Vertical RAM address start position setting 
										 //0x0000 = dec 0
	LCD_WrCmd(0x0046);LCD_WrDat(0x013F); //Vertical RAM address end position setting (0x013F = dec 319)
	LCD_WrCmd(0x004E);LCD_WrDat(0x0000); //  GDDRAM X
	LCD_WrCmd(0x004F);LCD_WrDat(0x0000); //  GDDRAM y

//	LCD_WaitMs(20); 
	//gamma control 
	LCD_WrCmd(0x0030);LCD_WrDat(0x0707);
	LCD_WrCmd(0x0031);LCD_WrDat(0x0202);
	LCD_WrCmd(0x0032);LCD_WrDat(0x0204);
	LCD_WrCmd(0x0033);LCD_WrDat(0x0502);
	LCD_WrCmd(0x0034);LCD_WrDat(0x0507);
	LCD_WrCmd(0x0035);LCD_WrDat(0x0204);
	LCD_WrCmd(0x0036);LCD_WrDat(0x0204);
	LCD_WrCmd(0x0037);LCD_WrDat(0x0502);
	LCD_WrCmd(0x003A);LCD_WrDat(0x0302);
	LCD_WrCmd(0x003B);LCD_WrDat(0x0302);

	LCD_WrCmd(0x0023);LCD_WrDat(0x0000);
	LCD_WrCmd(0x0024);LCD_WrDat(0x0000);


	LCD_WrCmd(0x0025);LCD_WrDat(0x8000);
	LCD_WrCmd(0x0026);LCD_WrDat(0x7000);
	LCD_WrCmd(0x0020);LCD_WrDat(0xB0EB);
	LCD_WrCmd(0x0027);LCD_WrDat(0x007C);
	//
//#if ID_AM==011
	//LCD_WrCmd(0x0020);LCD_WrDat(0x0000);
	//LCD_WrCmd(0x0021);LCD_WrDat(0x013f);
//#elif ID_AM==110
	//LCD_WrCmd(0x0020);LCD_WrDat(0x0000);
	//LCD_WrCmd(0x0021);LCD_WrDat(0x0000);
//#endif

//	LCD_WaitMs(50);
}    
#endif

#ifdef HX8347A
#define delay_ms(x) LCD_WaitMs(x)
void LCD_Reset(void)
{
	LCD_InitPort();
	        LCD_WriteReg(0x0042,0x0008);
	        /* Gamma setting */
	        LCD_WriteReg(0x0046,0x00B4);
	        LCD_WriteReg(0x0047,0x0043);
	        LCD_WriteReg(0x0048,0x0013);
	        LCD_WriteReg(0x0049,0x0047);
	        LCD_WriteReg(0x004A,0x0014);
	        LCD_WriteReg(0x004B,0x0036);
	        LCD_WriteReg(0x004C,0x0003);
	        LCD_WriteReg(0x004D,0x0046);
	        LCD_WriteReg(0x004E,0x0005);
	        LCD_WriteReg(0x004F,0x0010);
	        LCD_WriteReg(0x0050,0x0008);
	        LCD_WriteReg(0x0051,0x000a);
	        /* Window Setting */
	        LCD_WriteReg(0x0002,0x0000);
	        LCD_WriteReg(0x0003,0x0000);
	        LCD_WriteReg(0x0004,0x0000);
	        LCD_WriteReg(0x0005,0x00EF);
	        LCD_WriteReg(0x0006,0x0000);
	        LCD_WriteReg(0x0007,0x0000);
	        LCD_WriteReg(0x0008,0x0001);
	        LCD_WriteReg(0x0009,0x003F);
	        delay_ms(10);
	        LCD_WriteReg(0x0001,0x0006);
	        LCD_WriteReg(0x0016,0x00C8);
	        LCD_WriteReg(0x0023,0x0095);
	        LCD_WriteReg(0x0024,0x0095);
	        LCD_WriteReg(0x0025,0x00FF);
	        LCD_WriteReg(0x0027,0x0002);
	        LCD_WriteReg(0x0028,0x0002);
	        LCD_WriteReg(0x0029,0x0002);
	        LCD_WriteReg(0x002A,0x0002);
	        LCD_WriteReg(0x002C,0x0002);
	        LCD_WriteReg(0x002D,0x0002);
	        LCD_WriteReg(0x003A,0x0001);
	        LCD_WriteReg(0x003B,0x0001);
	        LCD_WriteReg(0x003C,0x00F0);
	        LCD_WriteReg(0x003D,0x0000);
	        delay_ms(20);
	        LCD_WriteReg(0x0035,0x0038);
	        LCD_WriteReg(0x0036,0x0078);
	        LCD_WriteReg(0x003E,0x0038);
	        LCD_WriteReg(0x0040,0x000F);
	        LCD_WriteReg(0x0041,0x00F0);
	        LCD_WriteReg(0x0038,0x0000);
	        /* Power Setting */
	        LCD_WriteReg(0x0019,0x0049);
	        LCD_WriteReg(0x0093,0x000A);
	        delay_ms(10);
	        LCD_WriteReg(0x0020,0x0020);
	        LCD_WriteReg(0x001D,0x0003);
	        LCD_WriteReg(0x001E,0x0000);
	        LCD_WriteReg(0x001F,0x0009);
	        LCD_WriteReg(0x0044,0x0053);
	        LCD_WriteReg(0x0045,0x0010);
	        delay_ms(10);
	        LCD_WriteReg(0x001C,0x0004);
	        delay_ms(20);
	        LCD_WriteReg(0x0043,0x0080);
	        delay_ms(5);
	        LCD_WriteReg(0x001B,0x000a);
	        delay_ms(40);
	        LCD_WriteReg(0x001B,0x0012);
	        delay_ms(40);
	        /* Display On Setting */
	        LCD_WriteReg(0x0090,0x007F);
	        LCD_WriteReg(0x0026,0x0004);
	        delay_ms(40);
	        LCD_WriteReg(0x0026,0x0024);
	        LCD_WriteReg(0x0026,0x002C);
	        delay_ms(40);
	        LCD_WriteReg(0x0070,0x0008);
	        LCD_WriteReg(0x0026,0x003C);
	        LCD_WriteReg(0x0057,0x0002);
	        LCD_WriteReg(0x0055,0x0000);
	        LCD_WriteReg(0x0057,0x0000);
    delay_ms(50);   /* delay 50 ms */	
}
#endif //HX8347A
/*********************************************************************
* Function    : void LCD_SetCursor(unsigned int x, unsigned int y)
* Description : set start address of lcd ram
* Input       : x,y - pixel coordinates
* Return      : none
* Note        : set start address change
********************************************************************/
void LCD_SetCursor(unsigned int x, unsigned int y)
{
	#ifdef HX8347A
		      LCD_WriteReg(0x02, x>>8 );
		      LCD_WriteReg(0x03, x );

		      LCD_WriteReg(0x06, y>>8 );
		      LCD_WriteReg(0x07, y );
	#else
#ifdef Horizontal
	LCD_SetReg(0x4E,x); // initial settings for the GDDRAM X address in the address counter (AC).
	LCD_SetReg(0x4F,y); // initial settings for the GDDRAM Y address in the address counter (AC).
#else
	LCD_SetReg(0x4E,/*GetMaxY()-*/y); // initial settings for the GDDRAM X address in the address counter (AC).
	LCD_SetReg(0x4F,/*GetMaxX()-*/x); // initial settings for the GDDRAM Y address in the address counter (AC).
#endif
#endif
    LCD_WrCmd(0x22); 
	
}

/*********************************************************************
* Function    : void LCD_SetArea(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2)
* Description : set paint area
* Input       : x1,y1,x2,y2 - pixel coordinates
* Return      : none
* Note        : Side Effects: paint area change
********************************************************************/
void LCD_SetArea(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2)
{
#ifdef Horizontal
    LCD_WrCmd(0x44); LCD_WrDat((x2 << 8) | x1);    // Source RAM address window 
    LCD_WrCmd(0x45); LCD_WrDat(y1);    // Gate RAM address window 
    LCD_WrCmd(0x46); LCD_WrDat(y2);    // Gate RAM address window 
#else
    LCD_WrCmd(0x44); LCD_WrDat((y2 << 8) | y1);    // Source RAM address window 
    LCD_WrCmd(0x45); LCD_WrDat(x1);    // Gate RAM address window 
    LCD_WrCmd(0x46); LCD_WrDat(x2);    // Gate RAM address window 
#endif
	LCD_WaitMs(1);
	LCD_SetCursor(x1, y1);
}

/*********************************************************************
* Function    : void LCD_PutPixel(unsigned int x, unsigned int y)
* Description : puts pixel
* Input       : x,y - pixel coordinates
* Output      : none
* Note        : none
********************************************************************/
void LCD_PutPixel(unsigned int x, unsigned int y)
{
    LCD_SetCursor(x,y);
	LCD_WrDat(_color);
}

/*********************************************************************
* Function    : void LCD_Bar(unsigned int left, unsigned int top, unsigned int right, unsigned int bottom)
* Description : draws rectangle filled with current color
* Input       : left,top - top left corner coordinates,
*             : right,bottom - bottom right corner coordinates
* Output      : none
* Note        :
*  CGRAM map
*  00000...000EF line0
*  00100...001EF line1
*  00200...002EF line2 
*	....
*  13F00...13FEF line320
*  yyyxx...yyyxx
*  address x = x
*  address y = y << 8
*  new line y = y + 0x100
********************************************************************/
void LCD_Rect(unsigned int left, unsigned int top, unsigned int right, unsigned int bottom, unsigned int color)
{
	register unsigned int x,y;

	LCD_SetArea(left, top, right, bottom);
	LCD_OPEN_WRITE();
    for(y=top; y<=bottom; y++)
	{
        for(x=left; x<=right; x++)
		{
//			LCD_WrDat(color);
			LCD_FAST_WRITE(color);
        }
    }
	LCD_CLOSE();
	LCD_SetArea(0, 0, GetMaxX(), GetMaxY());
}

/*********************************************************************
* Function    : void LCD_Clear(unsigned int color)
* Description : fill display with color
* Input       : color - paint color
* Output      : none
* Note        : none
********************************************************************/
void LCD_Clear(unsigned int color)
{
	#ifdef HX8347A
	LCD_WriteReg(0x02,0x00);
	LCD_WriteReg(0x03,0x00);
	
	LCD_WriteReg(0x04,0x00);
	LCD_WriteReg(0x05,0xEF);
	
	LCD_WriteReg(0x06,0x00);
	LCD_WriteReg(0x07,0x00);
	
	LCD_WriteReg(0x08,0x01);
	LCD_WriteReg(0x09,0x3F);
	#endif
//	LCD_WrCmd(0x0007);LCD_WrDat(0x0221); // Display Control: display off
	LCD_Rect(0, 0, GetMaxX(), GetMaxY(), color);
//	LCD_WrCmd(0x0007);LCD_WrDat(0x0233); // Display Control: display on
}

/*********************************************************************
* Function    : void DrawSymbol(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char t, unsigned char *pImage)
* Description : display image array to lcd
* Input       : x,y    - pixel coordinates
*             : w      - width 
*             : h      - height
*             : t      - compress type(0 = none(RGB565), 1 = compress(RGB5<compress bit>55)
*			  : pImage - FLASH array of image
* Output      : none
* Note        : none
********************************************************************/
void LCD_DrawSymbol(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char t, const unsigned char *pImage)
{
	unsigned char colorMsb;
	unsigned char colorLsb;
	unsigned char colorDup = 0;
	unsigned int color=0;
	unsigned int x1,y1;

	// set draw area
	LCD_SetArea(x,y,x+w-1,y+h-1);
	for (y1 = 0; y1<h ; y1++)
	{
		for (x1 = 0; x1<w ; x1++)
		{
			if (!colorDup)
			{
				colorMsb = pgm_read_byte(pImage++);
				colorLsb = pgm_read_byte(pImage++);
				if (t == 0x01)
				{
					colorDup = colorLsb & 0x20;			// get duplicate flag
					colorLsb = colorLsb | 0x20;			// remove duplicate flag and add more white
				}
				if (colorDup)
					colorDup = pgm_read_byte(pImage++);	// get duplicate no
				color = ((uint16_t)colorMsb << 8) | colorLsb;		// merge color
			}
			else
			{
				colorDup--;
			}
			LCD_WrDat(color);
		}
	}
	LCD_SetArea(0, 0, GetMaxX(), GetMaxY());
}

/*********************************************************************
* Function    : void DrawImage(unsigned int x, unsigned int y, unsigned char *pImage)
* Description : display image array to lcd
* Input       : x,y    - pixel coordinates
*			  : pImage - FLASH array of image
* Output      : none
* Note        : ** modify image format here **
*   image format
*   <type 1 byte><width 2 byte><height 2 btye><image array n byte>
********************************************************************/
void LCD_DrawImage(unsigned int x, unsigned int y, const unsigned char *pImage)
{
	unsigned char t;
	unsigned int w, h;

	// get image information
	t = pgm_read_byte(pImage++);			// image type
	w = pgm_read_byte(pImage++);			// width
	w = (w << 8) | pgm_read_byte(pImage++);
	h = pgm_read_byte(pImage++);			// Height
	h = (h << 8) | pgm_read_byte(pImage++);

	LCD_DrawSymbol(x, y, w, h, t, pImage);
}


ssd1298.h
/**************************************************************************************************
*	  			  SSD1289 color Graphical LCD Display Driver
* File name		: SSD1289.h
* Programmer 	: jaruwit supa
* Web           : [url=http://www.circuitidea.com]www.circuitidea.com[/url]
* Note			: SSD1289 16 bit interface.for 8 bit use 74lv573 to latch HI byte
* Language		: avrGCC
* Hardware		: atmega16
* Date			: 01/05/2009
************************************************************************************************/
// ssd1298'e uyarlayan avrbocek
// 06 Mart 2013

#ifndef __SSD1298X_H__
#define __SSD1298X_H__

/* _____CONFIG DEFINES_____________________________________________________ */
//#define LCD_8_BIT_MODE	  // 8 bit bus data using latch. *** Need jumpper for 8 bit *** 
#define LCD_BL_HARDWARE	  // using black light internal jumper
//#define LCD_RESET_HARDWARE  // using hardware control reset pin to reset
#define LCD_WRITE_ONLY	  // write only mode no read back
//#define LCD_V2			  // hardware v2 
//#define Horizontal		  // Horizontal or vertical
#define Reverse			  // reverse direction

/* _____HARDWARE DEFINES_____________________________________________________ */
#define LCD_LO_DDR  DDRB
#define LCD_LO_PORT PORTB
#define LCD_LO_PIN  PINB

	#define LCD_HI_DDR  DDRD
	#define LCD_HI_PORT PORTD
	#define LCD_HI_PIN  PIND

    #define LCD_CS_DDR  DDRA
    #define LCD_CS_PORT PORTA
    #define LCD_CS_PIN  PINA
    #define LCD_CS_BIT  3
    
    #define LCD_RS_DDR  DDRA
    #define LCD_RS_PORT PORTA
    #define LCD_RS_PIN  PINA
    #define LCD_RS_BIT  2
    
    #define LCD_WR_DDR  DDRA
    #define LCD_WR_PORT PORTA
    #define LCD_WR_PIN  PINA
    #define LCD_WR_BIT  1
    
#ifdef LCD_WRITE_ONLY
	#define LCD_RD_DDR  DDRA
    #define LCD_RD_PORT PORTA
    #define LCD_RD_PIN  PINA
    #define LCD_RD_BIT  0
#endif

    #define LCD_RST_DDR  DDRC
    #define LCD_RST_PORT PORTC
    #define LCD_RST_PIN  PINC
    #define LCD_RST_BIT  7
    
#ifndef LCD_BL_HARDWARE
	#define LCD_BL_DDR  DDRA
	#define LCD_BL_PORT PORTA
	#define LCD_BL_PIN  PINA
	#define LCD_BL_BIT  5
#endif


#define LCD_SET_CS()  LCD_CS_PORT  |=  (1<<LCD_CS_BIT)
#define LCD_CLR_CS()  LCD_CS_PORT  &= ~(1<<LCD_CS_BIT)
#define LCD_DIR_CS(x) LCD_CS_DDR   |=  (1<<LCD_CS_BIT)

#define LCD_SET_RS()  LCD_RS_PORT  |=  (1<<LCD_RS_BIT)
#define LCD_CLR_RS()  LCD_RS_PORT  &= ~(1<<LCD_RS_BIT)
#define LCD_DIR_RS(x) LCD_RS_DDR   |=  (1<<LCD_RS_BIT)

#define LCD_SET_WR()  LCD_WR_PORT  |=  (1<<LCD_WR_BIT)
#define LCD_CLR_WR()  LCD_WR_PORT  &= ~(1<<LCD_WR_BIT)
#define LCD_DIR_WR(x) LCD_WR_DDR   |=  (1<<LCD_WR_BIT)

#define LCD_SET_RD()  LCD_RD_PORT  |=  (1<<LCD_RD_BIT)
#define LCD_CLR_RD()  LCD_RD_PORT  &= ~(1<<LCD_RD_BIT)
#define LCD_DIR_RD(x) LCD_RD_DDR   |=  (1<<LCD_RD_BIT)

#ifndef LCD_RESET_HARDWARE
	#define LCD_SET_RST()  LCD_RST_PORT |= (1<<LCD_RST_BIT)
	#define LCD_CLR_RST()  LCD_RST_PORT &= ~(1<<LCD_RST_BIT)
	#define LCD_DIR_RST(x) LCD_RST_DDR  |= (1<<LCD_RST_BIT)
#else
	#define LCD_SET_RST()
	#define LCD_CLR_RST()
	#define LCD_DIR_RST(x)
#endif

#define LCD_SET_LATCH()  LCD_LATCH_PORT |=  (1<<LCD_LATCH_BIT)
#define LCD_CLR_LATCH()  LCD_LATCH_PORT &= ~(1<<LCD_LATCH_BIT)
#define LCD_DIR_LATCH(x) LCD_LATCH_DDR  |=  (1<<LCD_LATCH_BIT)

#ifndef LCD_BL_HARDWARE
	#define LCD_BL_OFF()	LCD_BL_DDR  |=  (1<<LCD_BL_BIT); \
							LCD_BL_PORT &= ~(1<<LCD_BL_BIT)
	#define LCD_BL_ON()		LCD_BL_DDR  |=  (1<<LCD_BL_BIT); \
							LCD_BL_PORT |=  (1<<LCD_BL_BIT)
#else
	#define LCD_BL_OFF()
	#define LCD_BL_ON()
#endif

#ifdef LCD_8_BIT_MODE
	#define LCD_INPUT()		LCD_LO_DDR = 0x00
	#define LCD_OUTPUT()	LCD_LO_DDR = 0xFF //; DDRA = 0xFF; PORTA = 0xFF

	#define LCD_MODE()		LCD_LO_DDR = 0xFF;\
							LCD_SET_LATCH(); \
							LCD_DIR_LATCH(1);

	#define LCD_SET_DBH(x)	LCD_HI_PORT = x; \
							LCD_SET_LATCH(); \
							LCD_CLR_LATCH();
//							asm volatile ("nop");


	#define LCD_SET_DBL(x)	LCD_LO_PORT = x

	// read back not support in 8 bit bus
	#define LCD_GET_DBH()	LCD_HI_PIN
	#define LCD_GET_DBL()	LCD_LO_PIN
#else
	#define LCD_INPUT()		LCD_LO_DDR = 0x00; \
							LCD_HI_DDR = 0x00
	#define LCD_OUTPUT()	LCD_LO_DDR = 0xFF; \
							LCD_HI_DDR = 0xFF
	#define LCD_MODE()

	#define LCD_SET_DBH(x)	LCD_HI_PORT = x
	#define LCD_SET_DBL(x)	LCD_LO_PORT = x

	#define LCD_GET_DBH()	LCD_HI_PIN
	#define LCD_GET_DBL()	LCD_LO_PIN
#endif

/* _____PUBLIC DEFINE_____________________________________________________ */
#ifdef Horizontal
	// Horizontal and vertical screen size
	#define SCREEN_HOR_SIZE    240UL
	#define SCREEN_VER_SIZE    320UL
#else
	// Horizontal and vertical screen size
	#define SCREEN_HOR_SIZE    320UL
	#define SCREEN_VER_SIZE    240UL
#endif

/* _____PUBLIC VARIABLE_____________________________________________________ */
extern unsigned int _color;

/* _____PUBLIC FUNCTIONS_____________________________________________________ */
extern void LCD_Reset(void);
extern void LCD_SetCursor(unsigned int x, unsigned int y);
extern void LCD_SetArea(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2);
extern void LCD_PutPixel(unsigned int x, unsigned int y);
extern void LCD_Rect(unsigned int left, unsigned int top, unsigned int right, unsigned int bottom, unsigned int color);
extern void LCD_Clear(unsigned int color);
extern void LCD_DrawSymbol(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char t, const unsigned char *pImage);
extern void LCD_DrawImage(unsigned int x, unsigned int y, const unsigned char *pImage);

// low level
void LCD_WrCmd(unsigned char cmd);
void LCD_WrDat(unsigned int val);

#define LCD_WriteReg(a,b) LCD_WrCmd(a);LCD_WrDat(b)
/* _____DEFINE MACRO_________________________________________________________ */
// fast write is macro define. prevent call routine
#define LCD_OPEN_WRITE()		LCD_CLR_CS();\
								LCD_SET_RS();

#define LCD_FAST_WRITE(val)		LCD_SET_DBH((val)>>8); \
								LCD_SET_DBL(val); \
								LCD_CLR_WR(); \
								LCD_SET_WR();

#define LCD_FAST_WRITE_CS(val)	LCD_CLR_CS();\
								LCD_SET_DBH((val)>>8); \
								LCD_SET_DBL(val); \
								LCD_CLR_WR(); \
								LCD_SET_WR(); \
								LCD_SET_CS()

#define LCD_FAST_WRITE2(H,L)	LCD_SET_DBH(H); \
								LCD_SET_DBL(L); \
								LCD_CLR_WR(); \
								LCD_SET_WR();

#define LCD_FAST_WRITE2_CS(H,L)	LCD_CLR_CS();\
								LCD_SET_DBH(H); \
								LCD_SET_DBL(L); \
								LCD_CLR_WR(); \
								LCD_SET_WR(); \
								LCD_SET_CS()

#define LCD_CLOSE() 			LCD_SET_CS()


#define GetMaxX() 		((unsigned int)SCREEN_HOR_SIZE-1)
#define GetMaxY() 		((unsigned int)SCREEN_VER_SIZE-1)

#define SetColor(color) _color = color
#define GetColor()      _color

#endif


color.h
#ifndef __COLOR_H__
#define __COLOR_H__

#define RGB(red, green, blue)	((unsigned int)( (( red >> 3 ) << 11 ) | \
(( green >> 2 ) << 5  ) | \
( blue  >> 3 )))

// color
#define BLACK                       RGB(0x00, 0x00, 0x00)
#define WHITE                       RGB(0xFF, 0xFF, 0xFF)
#define RED                         RGB(0xFF, 0x00, 0x00)
#define GREEN                       RGB(0x00, 0xFF, 0x00)
#define BLUE                        RGB(0x00, 0x00, 0xFF)
#define YELLOW                      RGB(0xFF, 0xFF, 0x00)
#define MAGENTA                     RGB(0xFF, 0x00, 0xFF)
#define CYAN                        RGB(0x00, 0xFF, 0xFF)
#define GRAY                        RGB(0x80, 0x80, 0x40)
#define SILVER                      RGB(0xA0, 0xA0, 0x80)
#define GOLD                        RGB(0xA0, 0xA0, 0x40)

// VGA color palette
#define MAROON		0x8000
#define OLIVE		0x8400
#define LIME		0x07E0
#define AQUA		0x07FF
#define TEAL		0x0410
#define NAVY		0x0010
#define FUCHSIA		0xF81F
#define PURPLE		0x8010

#define BROWN              0XBC40 // RGB(188,64,0)
#define BRRED              0XFC07 // RGB(252,0,7)
#define DARKBLUE           0X01CF // RGB()
#define LIGHTBLUE          0X7D7C // RGB()
#define GRAYBLUE           0X5458 // RGB()
#define LIGHTGREEN         0X841F // RGB()
#define LIGHTGRAY          0XEF5B // RGB()
#define LGRAY              0XC618 // RGB()
#define LGRAYBLUE          0XA651 // RGB()
#define LBBLUE             0X2B12 // RGB()

#define COLOR_HEADERBG RGB(153,0,51)
#define COLOR_HEADERFG RGB(255,255,255)
#define COLOR_PANELHEADERBG RGB(213,0,0)
#define COLOR_TEXT RGB(204,0,102)

#define COLOR_CAFG BLUE				// Clock area foreground color
#define COLOR_CABG RGB(214,214,214) // Clock area background color
#define COLOR_CASEC RGB(0,153,153)	// Clock area second color
#define COLOR_DABG COLOR_CAFG		// Date area foreground color
#define COLOR_DAFG COLOR_CABG		// Date area background color
#define COLOR_TAFG COLOR_TEXT		// Temperature area foreground color	
#define COLOR_TABG RGB(255,255,102)	// Temperature area background color
#define COLOR_HAFG COLOR_TEXT		// Humidity area foreground color
#define COLOR_HABG RGB(204,153,102)	// Humidity area background color
#define COLOR_PAFG COLOR_TEXT		// Pressure area foreground color
#define COLOR_PABG RGB(204,102,255)	// Pressure area background color

#endif
1 ya da 0. işte 'bit'ün mesele..

yldzelektronik

Peki lcdnin  besleme gerilimi nedir?Kaç volt ile beslemem gerekli lcdyi?
Kişinin başına gelen hayır Allah'tandır. Kişinin başına gelen şer nefsindendir. Nefislerimizle kendimize zulüm ediyoruz.

Burak B

TFT' lerin hemen hepsi 3.3v ile çalışır. Sorun olmaz.
"... a healthy dose of paranoia leads to better systems." Jack Ganssle

eml581

#430
Arkadaşlar elimde iphone 3 serisinin çim malı iphone buldum biraz parçaladım içinde güzel bi ekranı var pic konusna giriş yapıodum bnde acaba bunu nasıl değerlendirebilirim diye size soruyum dedim








Burak B

#431
Konuyu bu başlığa aç;
https://www.picproje.org/index.php/topic,27569.420.html

LCD' yi PCB' den sök. Varsa flex v.s. üstündeki tüm bantları sök. Kahverengi(turuncu) flex pcb kısmının alt ve üst taramalarını koy.
LCD nin boyutlarını ölç. LCD camı ve flexin birleştiği yerde siyah bant var onu çıkar ve lcd paneli tara ve resmi yukardaki başlığa açtığın konuya diğer bahsettiğim tarama resimleri ile ekle. Düzgün çekebilirsen fotoğrafta olur. Çözünürlük yüksek olsun.
"... a healthy dose of paranoia leads to better systems." Jack Ganssle

eml581

taramalrdan kastınız yazıcıdaki tarama dimi

Burak B

"... a healthy dose of paranoia leads to better systems." Jack Ganssle

eml581

#434
anakart ile ekran arsında bi flax var üzerinde 50 taneye yakın küçük lehim noktası var sökmesi zor gibi gözüküyor


mesaj birleştirme:: 20 Ağustos 2013, 19:43:25

  Flax ile lcd arasında siyah bantı buldum kaldırdım ama bişey yok