Grafik LCD yardım

Başlatan gocebe, 27 Mart 2006, 17:13:50

gocebe

selam arkadaşlar

elimdeki sed 1335 controller li 320x240 dot grafik lcd mi pic16f877 ile programlamak istiyorum.

bana örnek olabilecek projelere ihtiyacım var çünkü pdf ler içinde kaybolmuş durumdayım.

yardımlarınız için şimdiden teşekkürler

Klein

Bu kodu renesas için yazmıştım. birkaç değişiklikle pic için de kullanabilirsin.

/******************************* display **************************************/
#include "num0.h"
#include "num1.h"
#include "num2.h"
#include "num3.h"
#include "num4.h"
#include "num5.h"
#include "num6.h"
#include "num7.h"
#include "num8.h"
#include "num9.h"
#include "comma.h"
#include "space.h"

/*************************  320x240 LCM definations *******************************/
#define  MAX_COL   320        //MAX COLUMN(SEGMENT)
#define  MAX_ROW   240     // MAX ROW(COMMON)
#define  CM   1
#define  DT   0
#define TXT_LAYER 0
#define GRP_LAYER 2400
#define FX   0x87
#define FY   0x7
#define CR_SD   39
#define TC_P   66
#define L_F   239
#define APL   40
#define SAD_2L   0x60
#define SAD_2H   0x09

#define run_led  p6_0
#define cr_str p8_1
#define cr_clk p8_2
#define cr_data p8_3
#define rt_str p8_4
#define rt_clk p8_6
#define rt_data p8_7
far const unsigned  int divtable[] = {1000,100,10,1}; //
far const unsigned  char segmap[] = {
//                             xabcdefg
                           0b10000001,
                           0b11001111,
                           0b10010010,
                           0b10000110,
                           0b11001100,
                           0b10100100,
                           0b10100000,
                           0b10001111,
                           0b10000000,
                           0b10000100}; //

unsigned char ledarray[8];
/***************************************************************/


void delayus(void){
   unsigned int I;
   I=2;
   while(I--);
}
void  code_w( unsigned char dataval){
   delayus();
   dispa0 = 1;
     disprd = 1;
   dispwr = 0;
   delayus();
   screenbus = dataval;   
   delayus();
   dispwr=1;
}

void data_w(unsigned char dataval){
   delayus();
   dispa0=0;
  disprd=1;
  dispwr=0;
   screenbus=dataval;   
   delayus();
   dispwr=1;
}

void disp_on(void){
   code_w(0x59);
   data_w(0x14);
}
void disp_off(void){
   code_w(0x58);
   data_w(0x14);
}

void gotoxy(unsigned char x , unsigned char y ,unsigned int layer){
unsigned int temp;
      temp=x+(y*40)+layer;
      code_w(0x46);
      data_w(temp);
      data_w(temp/256);
}


void _far showbitmap(unsigned char x ,
                unsigned char y,
                unsigned char far *bitmap)
{
unsigned char I;
unsigned char Z;
unsigned int K = 2;
      for(Z = 0; Z < bitmap[1] ; Z++){
            gotoxy(x,Z+y,GRP_LAYER);
            code_w(0x42);
         for (I=0; I < bitmap[0] ; I++){
            data_w(bitmap[K]);
            K++;
         }
      }
}

void _far shownum(unsigned char x ,
                unsigned char y,
                unsigned char *num)
{
unsigned char V;
unsigned char T;
unsigned char k=0;
unsigned char X;
unsigned char Y;
      X=x;
      Y=y;
      for(V = 0; num[V] !=0 ; V++){
            T=num[V];
            switch(T){
               case '0': showbitmap(V*2+X-k,Y,num0);break;
               case '1': showbitmap(V*2+X-k,Y,num1);break;
               case '2': showbitmap(V*2+X-k,Y,num2);break;
               case '3': showbitmap(V*2+X-k,Y,num3);break;
               case '4': showbitmap(V*2+X-k,Y,num4);break;
               case '5': showbitmap(V*2+X-k,Y,num5);break;
               case '6': showbitmap(V*2+X-k,Y,num6);break;
               case '7': showbitmap(V*2+X-k,Y,num7);break;
               case '8': showbitmap(V*2+X-k,Y,num8);break;
               case '9': showbitmap(V*2+X-k,Y,num9);break;
               case ',': showbitmap(V*2+X,Y+11,comma);k=1;break;
               case ' ': showbitmap(V*2+X-k,Y,spacechr);break;
            }      
      }
}

void fillgraph(unsigned char x ,
               unsigned char y,
               unsigned char width,
               unsigned char height,
               unsigned char pattern)
{

unsigned char I;
unsigned char Z;
      for(Z = 0; Z < height ; Z++){
            gotoxy(x,Z+y,GRP_LAYER);
            code_w(0x42);
         for (I=0; I < (width) ; I++){
            data_w(pattern);
         }
      }
}

void filltext(unsigned char x ,
              unsigned char y,
              unsigned char width ,
              unsigned char height,
              unsigned char pattern)
{

unsigned char I;
unsigned char Z;
      for(Z = 0; Z < height ; Z++){
            gotoxy(x,Z+y,TXT_LAYER);
            code_w(0x42);
         for (I=0; I < (width) ; I++){
            data_w(pattern);
         }
      }
}

void _far writeln(unsigned char x , unsigned char y , unsigned char far *msg){
unsigned char I;
      gotoxy (x,y,TXT_LAYER);
      code_w(0x42);
      for(I = 0; msg[I] != 0; I++){
         data_w(msg[I]);
      }
}

void writedecimal(unsigned char x , unsigned char y ,unsigned char length, unsigned char dataval){
unsigned char I;
      gotoxy (x,y,TXT_LAYER);
      code_w(0x42);
      for(I = 3-length; I < 3; I++){
         data_w(((dataval % divtable[I]) / divtable[I+1])+48);
      }
}

void systemset(void){
      code_w(0x40);
      data_w(0x30);  // internal cgrom , no d6 correction , 8 pixel char , single panel , inverse display
      data_w(FX);    // 87H  8bit per char , 2 ac frame
      data_w(FY);    // 07H 8bit per char
      data_w(CR_SD); // 39D  40Col
      data_w(TC_P);  // 66
      data_w(L_F);   // 239D 240 Line
      data_w(APL);  // 40
      data_w(0);    // end
}
void scroll(void){
      code_w(0x44);
      data_w(0);
      data_w(0);
      data_w(L_F);
      data_w(SAD_2L);
      data_w(SAD_2H);
      data_w(L_F);
      data_w(0);
      data_w(0);
      data_w(0);
      data_w(0);
}

void hdot_scr(void){
      code_w(0x5A);
      data_w(0x00);
}

void overlay(void){
      code_w(0x5B);
      data_w(0x01);
}

void csr_form(void){
      code_w(0x5D);
      data_w(0x07);
      data_w(0x87);
}

void csr_dir(unsigned char dir){
      code_w(0x4C+dir);
}

void cursor_on(void){
   code_w(0x59);
   data_w(0x17);
}
void cursor_off(void){
   code_w(0x59);
   data_w(0x14);
}

void clrscr(void){
      fillgraph(0,0,40,240,0);
      filltext(0,0,40,30,0);
}

void lcdinit(void){
      systemset();
      scroll();
      hdot_scr();
      overlay();
      csr_form();
      csr_dir(0);
}

/***********************************************************************************************

                     Led gösterge

***********************************************************************************************/

void send_rt(unsigned char *data){
unsigned char digitdata=0;
unsigned char I;
unsigned char Z;
unsigned char c;

   rt_str=0;
   for(Z=0;Z<6;Z++){
      c=data[5-Z]-'0';
      digitdata=segmap[c];      
      for(I=0;I<8;I++){
         rt_clk=0;
         rt_data= digitdata  & 0x01;
         delayus();
         rt_clk=1;
         digitdata >>=1;
      }

   }
      rt_str=1;
}

void send_cr(unsigned char *data){
unsigned char digitdata=0;
unsigned char I;
unsigned char Z;
unsigned char c;

   cr_str=0;
   for(Z=0;Z<6;Z++){
      c=data[5-Z]-'0';
      digitdata=segmap[c];      
      for(I=0;I<8;I++){
         cr_clk=0;
         cr_data= digitdata  & 0x01;
         delayus();
         cr_clk=1;
         digitdata >>=1;
      }

   }
      cr_str=1;
}


/******************     main **********************

lcdinit();
disp_off()
showbitmap(35,0, errortable);
drawmainmenu(3);
writeln(5,25,"Merhaba dünya");
disp_on();
/****************************************************/

/********************  Error Table ********************/
far const unsigned char errortable[] = {
      2,16,
      0b11111111,0b11111111,
      0b11111110,0b01111111,
      0b11111100,0b00111111,
      0b11111100,0b00111111,
      0b11111100,0b00111111,
      0b11111100,0b00111111,
      0b11111100,0b00111111,
      0b11111100,0b00111111,
      0b11111100,0b00111111,
      0b11111100,0b00111111,
      0b11111110,0b01111111,
      0b11111111,0b11111111,
      0b11111110,0b01111111,
      0b11111100,0b00111111,
      0b11111110,0b01111111,
      0b11111111,0b11111111
};

Kolay gelsin....

gocebe

çok teşekkür ederim dostum.

bi sorum daha olacak. elimde iki adet t6963c controllerli lcd ekran var. acaba240x64 ekran için yazılmış bi program 240x128 lik bi ekranda görüntü verir mi?

Klein

Soruyu tam anlayamadım. Ama tahminlerim üzerine bi açıklama yapayım.

sorun iki adet 240x64 ekranı 240x128 tek bir ekran gibi kullanmak ise : iki ekranı da aynı hatta bağlayıp CS uclarını kullanarak bunu yapabilirsin.  Eğer soru bu değil de 240x64 için yazılmış bir kodu 240x128 LCD'de  kullanabilirmiyim ise : Kodda çok küçük birkaç oynama  (adress , page vs.. ayarlar) yaparak kullanabilirsin.