Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

glcd data - need some help with the code

Status
Not open for further replies.

ilker_32

Member level 3
Joined
Jun 22, 2009
Messages
56
Helped
10
Reputation
20
Reaction score
10
Trophy points
1,288
Location
Turkey
Activity points
1,464
glcd data

hello everyone!
sorry, my english is bad.

**broken link removed** **broken link removed**

Code:
#include <89c51rd2.H>
#include <stdio.h>
#include "Tablo.h"
#include  "G_LCD.h"

main()
{
  int  x=0,y=0,Data_X=0,i=0,j=0;
  bit  renk=0;

    GLCD_Ekran(0); //dolgu var
    x=0;
    y=0;
      Gecikme(10000);
      GLCD_Ekran(0);
	  Gecikme(10000);
      GLCD_Ekran(0);
      Dispbye();
      DispBAYRAK();
	  DispGS();
      Gecikme(10000);
}

Dispbye()
{
  int x,y,i,j;
  for(i=0;	i<2;	i++)
  {
    j=0;
    Gecikme (10000);
    for(y=0;	y<8;	y++)	
    {
      for(x=0; x<=127; x++)		// sütunlar arasında döngü
      {
        if(i==0)
          GLCD_int_8Bit (x, y, TableBYE[j++]);
        else	
          GLCD_int_8Bit (x, y, (0xff-TableBYE[j++]));
      }
    }
    Gecikme (10000);
  }
}

DispBAYRAK()
{
  int x,y,i,j;
  for(i=0;	i<2;	i++)
  {
    j=0;
    for(y=0;	y<8;	y++)
    {
      for(x=0; x<=127; x++)
      {
        if(i==0)	
          GLCD_int_8Bit (x, y, TableBAYRAK[j++]);
        else
          GLCD_int_8Bit (x, y, (0xff-TableBAYRAK[j++]));
      }
    }
    Gecikme (10000);
  }
}

DispGS()
{
  int x,y,i,j;
  for(i=0;	i<2;	i++)
  {
    j=0;
    for(y=0;	y<8;	y++)
    {
      for(x=0; x<=127; x++)
      {
        if(i==0)	
          GLCD_int_8Bit (x, y, TableGS[j++]);
        else
          GLCD_int_8Bit (x, y, (0xff-TableGS[j++]));
      }
    }
    Gecikme (10000);
  }
}

Code:
#define	Acik	1
#define	Kapali	0



/* Uç Tanimlamalari */
#define GLCD_CS1	P1_0  	// LCD'nin Sol kısmını seçme ucu '0' aktif
#define GLCD_CS2	P1_1  	// LCD'nin Sag kısmını seçme ucu '0' aktif
#define GLCD_DI		P1_2  	// Register Select ucu (komut mu veri mi)
#define GLCD_RW		P1_3  	// Oku/Yaz ucu
#define GLCD_E		P1_4  	// Yetki ucu
#define GLCD_RST	P1_5  	// Reset ucu


/* Gecikme (Delay) Fonksiyonu */
void Gecikme (long int sure)
{
	int i;
	for (i=0;i<sure;i++) ;
}


/* Grafik LCD'ye int Deger Yazdirma Fonksiyonu */
// GLCD'nin seçilen kismina (64 piksellik) Veri bilgisini aktar //
GLCD_int_Yaz (bit sec, int Veri)
{
	if (sec != 0)	// GLCD'nin kullanilacak kismini sec
		GLCD_CS1=1;		
	else
		GLCD_CS2=1;

	GLCD_RW=0;		// GLCD yaz modunda
	GLCD_E=1;		// islemin yetkilendirilmesi için düsen kenar ayari
	P2=Veri;		// GLCD data girislerine veri bilgisini aktar
	Gecikme(2);
	GLCD_E=0;		// yetki için düsen kenar saglandi
	GLCD_CS1=0;		// GLCD'nin seçili çizgilerini resetle
	GLCD_CS2=0;	
}

/* Grafik LCD'den int Deger Okuma Fonksiyonu */
// GLCD'nin seçilen kismindan (64 piksellik) okuma yapilir  
// ve okunan deger oku degiskeni ile fonksiyona döndürülür
int GLCD_int_Oku (bit sec)
{
	int oku;			// GLCD'den okunan degerin tutulacagi degisken
	if (sec !=0)		// GLCD'nin kullanilacak kismini sec
		GLCD_CS1=1;		
	else
		GLCD_CS2=1;

	P2=0xFF;			// P2 portunu giris moduna kur
	GLCD_RW=1;		// GLCD oku modunda
	GLCD_E=1;		// islemin yetkilendirilmesi için düsen kenar ayari
	Gecikme(12);
	GLCD_E=0;		// yetki için düsen kenar saglandi
	GLCD_E=1;		// islemin yetkilendirilmesi için düsen kenar ayari
	Gecikme(12);
	GLCD_E=0;		// yetki için düsen kenar saglandi
	oku=P2;			// GLCD data girislerindeki veriyi oku degiskenine aktar
	GLCD_CS1=0;		// GLCD'nin seçili çizgilerini resetle
	GLCD_CS2=0;	

	return oku;		// GLCD uçlarindan okunan degeri geri dondur
}


/* Grafik LCD'de koordinatlari (x, y) verilen bir noktaya int Deger Yazdirma Fonksiyonu */

void GLCD_int_8Bit (int x, int y, int Veri_Bayt)
{

	bit sec=0;	 // GLCD'nin kullanilacak kismini sec
	if (x >= 64) // GLCD'nin sag mi yoksa sol kismimi seçili	
		{
		if (x>127)
			x=0;
		else
			{
			x-=64;
			sec=1;
			}
		}
	GLCD_DI=0;
	x&=0x7f;
	x|=0x40;
	GLCD_int_Yaz (sec, x);
	GLCD_int_Yaz (sec, (y & 0xBF) | 0xB8);
	GLCD_DI=1;		// veri modu
// komut moduna geç ve koordinati belirli noktayi isaretle
	GLCD_DI=0;		// komut modu
	GLCD_int_Yaz (sec, x);	// yatay adresi kur
// Yatay (x) adresi belirlenen noktaya fonksiyondan gonderilen degeri yaz
	GLCD_DI=1;		// veri modu
	GLCD_int_Yaz (sec, Veri_Bayt);  // Veri_Bayt degerini piksele yaz
	
}




/* GLCD Ekranini Doldurmak ve Temizleme Islemi */
void GLCD_Ekran (bit renk)
{
	int i, j, dolgu;
  	#define Acik_Bayt	0xFF
	#define	Kapali_Bayt	0x00

	// dikey sayfalar vasitasiyla dongu
	for (i=0;i<8;i++)
	{
		GLCD_DI=0;		//komut modu
		GLCD_int_Yaz (0, 0x40); // 0100 000 B	yatay (sütun) adresi 0'a kur
		GLCD_int_Yaz (1, 0x40); // 0100 000 B	
		GLCD_int_Yaz (0, i | 0xB8); // 1011 1000 B	sayfa (satir) adresini kur
		GLCD_int_Yaz (1, i | 0xB8); // 1011 1000 B	
		GLCD_DI=1;		//veri modu

		// Yatay kisimlar vasitasiyla döngü
		if	(renk)
			dolgu=Acik_Bayt;
		else	
			dolgu=Kapali_Bayt;

		for(j = 0; j < 64; j++)
		{
			GLCD_int_Yaz (0, dolgu); // sütunlari doldur ya da temizle	
			GLCD_int_Yaz (1, dolgu); 	
		}
	}
}




/* GLCD'yi baslangic ayarlarina kurma */
void GLCD_Baslat (bit mod)
{
	/* GLCD pinlerinin baslangic ayari*/
//	GLCD_RST=0;
	GLCD_E=0;
	GLCD_CS1=0;
	GLCD_CS2=0;

	GLCD_DI=0;	// komut modu
	GLCD_int_Yaz (GLCD_CS1, 0xC0);
	GLCD_int_Yaz (GLCD_CS2, 0xC0);
	GLCD_int_Yaz (GLCD_CS1, 0x40);	// sütun adresini 0'a kur
	GLCD_int_Yaz (GLCD_CS2, 0x40);
	GLCD_int_Yaz (GLCD_CS1, 0xB8);	// sayfa adresini 0'a kur
	GLCD_int_Yaz (GLCD_CS2, 0xB8);

	if(!mod)
		{	
		GLCD_int_Yaz (GLCD_CS1, 0x3F);	// Ekran acik
		GLCD_int_Yaz (GLCD_CS2, 0x3F);
		}
		else
		{
		GLCD_int_Yaz (GLCD_CS1, 0x3E);	// Ekran kapali
		GLCD_int_Yaz (GLCD_CS2, 0x3E);
		}

	GLCD_Ekran (Kapali);	// GLCD'yi temizle
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top