CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

t6963c graphical lcd drivers
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
zhiling0229



Joined: 13 Sep 2006
Posts: 10

View user's profile Send private message

PostPosted: Tue Sep 19, 2006 8:06 pm     Reply with quote

Hi newguy,

I'm sorry I'm a noob for T6963C controller. I thought I require to modify the code to clear the LCD which is bigger in size.

I'm new in using CCS C compiler so i have a few queries:

Why is the address for PortD not define but only address for PortC is define in the original program? i.e

#byte LCD = 0xf82 //PortC address on 18F452

If I am using PortA as my control pins and PortB as my data bus is this the only changes I require to make?

#define set_tris_lcd(x) set_tris_b(x)
.
.
.
struct lcd_pin_def
{
BOOLEAN cd; //A0
BOOLEAN r_bar; //A1
BOOLEAN w_bar; //A2
BOOLEAN reset_bar; //A3
BOOLEAN unused1; //A4
BOOLEAN unused2; //A5
BOOLEAN unused3; //
BOOLEAN unused4; //Should I define this? Since portA have only
//6 bits
}

#byte LCD = 0x05 //portA address on 16F877A
.
.
.
.
void main(){

set_tris_a(0x00) //graphic lcd control lines all output
// Do I need to configure the ADCON register?
.
.
.
}

Thanks
newguy



Joined: 24 Jun 2004
Posts: 1899

View user's profile Send private message

PostPosted: Tue Sep 19, 2006 9:30 pm     Reply with quote

The reason you don't need to define port D is that the register for port D in the PIC's memory immediately follows port C's register. Defining the struct for the pins with 16 total output lines ensures that the upper 8 bits "spill" into the next register......which happens to be port D.

If you're using port A and B in the same manner, yes you need to define 8 bits for port A (4 control lines & 4 unused) because the port A register is 8 bits wide.

Beware that a lot of 16F PICs, and a few 18F PICs have pin A4 as open drain. I see you're not using it for this project, but that's one thing that has bitten me in the butt before.

You'll need to turn off the PIC's A/D converter. Check the manual, but off the top of my head you'll need something like setup_adc_ports(NO_ANALOG); AND setup_adc(ADC_OFF);

Again, check the manual and your PIC's .h file for the exact wording/constants.
mkr



Joined: 08 Aug 2006
Posts: 49

View user's profile Send private message

Help on T6963C controller
PostPosted: Thu Mar 29, 2007 7:10 am     Reply with quote

Hello All,
I asked a dum question earlier on sending a string "ABC" to T6963C based LCD.
I am using the driver now. I simply wanted to send "ABC" using the glcd_putc("ABC");, seems that the
argument of the function is a character type. How can I then send a string.
Are there bits and peices of the code not posted or si the whole code posted.

My MCU is dsPIC30F6014a and LCD is 240x128 pixel. I have selected 8x8 font size and CE is always tied to low.

Here is the code snippet.
Code:

int main(void)
{

    init_io();

   glcd_init();

   glcd_WriteByte(1, (LCDModeSet|LCDMode_XOR));
   glcd_WriteByte(1, (LCDDispMode|LCDDisp_TXT|LCDDisp_GRH));

   glcd_gotoxy(4,3,1);         // 1 = text area of memory; note that there are only
                        // 16 rows of text possible
   glcd_putc("ABC");




} //End of main()


Please help.
_________________
Thanks

mkr
mechatroniker



Joined: 30 Jun 2008
Posts: 2

View user's profile Send private message

t6963 touchscreen with 18f452 help!!
PostPosted: Mon Jun 30, 2008 3:31 pm     Reply with quote

Hi everybody,

i am new here. i have a 240x128 t6963 touchscreen glcd. but i can't use it! i used this codes but not working in proteus with lm3229!! can somebody help me!!

my english is very bad. i am so sorry about that!!

WR - - RC4
RD - - RC5
C/D- - C6
RST- - C7
DATA0-7 PORTD0-7
elwex



Joined: 21 Dec 2009
Posts: 1
Location: Prague, Czech Republic

View user's profile Send private message

PostPosted: Mon Dec 21, 2009 10:24 am     Reply with quote

Hello Smile (and sorry for my bad english)
Thank you very very much, new guy ;o)
Your code was very useful for me. I find it is something like "business confidentiality" - how we can use graphical LCDs :D Nearly no documentation for that...

I have modified your code for:

- ANY HARDWARE CONECTION PIC-LCD (because there is not any 8bit port on my dsPIC30F2010 and because of PCB layout)
(using output_high/low/input... instead of LCD.r_bar=1 etc.)
- 240x128 pix LCD, 20MHz HS, FS=1 (6x8px font)

It could be useful for somebody, maybe Smile)

Code:

#include <18F452.h>
#device *=16
#device adc=10
#use delay(clock=20000000,RESTART_WDT)
#fuses HS, BROWNOUT, BORV27, PUT, STVREN, NOLVP

// HARDWARE CONECTION OF PINS  (LCD-PIC):
#define  LCD_B0   PIN_D0
#define  LCD_B1   PIN_D1
#define  LCD_B2   PIN_D2
#define  LCD_B3   PIN_D3
#define  LCD_B4   PIN_D4
#define  LCD_B5   PIN_D5
#define  LCD_B6   PIN_D6
#define  LCD_B7   PIN_D7

#define  LCD_WR   PIN_C4
#define  LCD_RD   PIN_C5
#define  LCD_CD   PIN_C6
#define  LCD_RST  PIN_C7

const int16 TextHome = 0x0000;
const int8  TextArea = 0x0028; // how many bytes before a new line
const int16 GraphicsHome = 0x0C00;
const int8  GraphicsArea = 0x0028; // how many bytes before a new line

const int8 AutoModeWrite = 0xB0;
const int8 AutoModeRead  = 0xB1;
const int8 AutoModeReset = 0xB2;

const int8 LCDModeSet  = 0x80;   // send this OR'd with the following
const int8 LCDMode_OR  = 0b0000;
const int8 LCDMode_XOR = 0b0001;
const int8 LCDMode_AND = 0b0010;
const int8 LCDMode_TA  = 0b0100; // TEXT ATTRIBUTE mode.
const int8 LCDMode_RAM = 0b1000; // 1=CG RAM, 0=internal CG ROM

const int8 LCDSetCursorPtr  = 0x21;  // cursor address
const int8 LCDSetCursorSize = 0xA0;  // 1 line cursor

const int8 LCDDispMode = 0x90;   // send this OR'd with the following
const int8 LCDDisp_BLK = 0b0001;
const int8 LCDDisp_CUR = 0b0010;
const int8 LCDDisp_TXT = 0b0100;
const int8 LCDDisp_GRH = 0b1000;

// VARIABLES:
unsigned int n;

int   glcd_ReadByte(void);
void  glcd_WriteByte(int1 cd, int data);
void  glcd_WriteByteAuto(int data);
void  glcd_WriteCmd2(int16 data, int cmd);
void  glcd_WriteCmd1(int data, int cmd);
void  glcd_gotoxy(int x, int y, int1 text);

// read lcd port
lcd_port_read() {
   int lcd_read=0;
   if(input(LCD_B0))    { bit_set(lcd_read,0); }      //0
   if(input(LCD_B1))    { bit_set(lcd_read,1); }      //1
   if(input(LCD_B2))    { bit_set(lcd_read,2); }      //2
   if(input(LCD_B3))    { bit_set(lcd_read,3); }      //3
   if(input(LCD_B4))    { bit_set(lcd_read,4); }      //4
   if(input(LCD_B5))    { bit_set(lcd_read,5); }      //5
   if(input(LCD_B6))    { bit_set(lcd_read,6); }      //6
   if(input(LCD_B7))    { bit_set(lcd_read,7); }      //7
   return lcd_read;
}

//write to lcd port
void lcd_port(unsigned int8 lcd) {
   output_low(LCD_B0);
   output_low(LCD_B1);
   output_low(LCD_B2);
   output_low(LCD_B3);
   output_low(LCD_B4);
   output_low(LCD_B5);
   output_low(LCD_B6);
   output_low(LCD_B7);
                                 //      převod z desítkové na dvojkovou soustavu
   if(bit_test(lcd,0))    { output_high(LCD_B0); }      //0      HW připojení LCD
   if(bit_test(lcd,1))    { output_high(LCD_B1); }      //1
   if(bit_test(lcd,2))    { output_high(LCD_B2); }      //2
   if(bit_test(lcd,3))    { output_high(LCD_B3); }      //3
   if(bit_test(lcd,4))    { output_high(LCD_B4); }      //4
   if(bit_test(lcd,5))    { output_high(LCD_B5); }      //5
   if(bit_test(lcd,6))    { output_high(LCD_B6); }      //6
   if(bit_test(lcd,7))    { output_high(LCD_B7); }      //7      (krajní vývod LCD)
   
   delay_us(10);
}

void glcd_init(void) {
  int16 counter;
  output_high(LCD_WR);
  output_high(LCD_RD);
  output_high(LCD_CD);

  delay_ms(10);
  // perform a reset
  output_low(LCD_RST);
  delay_us(2);      // delay for a reset - IF THIS WAIT TIME IS TOO MACH (MORE THAN 10us) LCD NOT WORK (I do not know why..)
  output_high(LCD_RST);
  delay_ms(10);

  // Set up the graphics and text areas
  glcd_WriteCmd2(TextHome, 0x40);
  glcd_WriteCmd2(TextArea, 0x41);
  glcd_WriteCmd2(GraphicsHome, 0x42);
  glcd_WriteCmd2(GraphicsArea, 0x43);

  // set address to 0
  glcd_WriteCmd2(0x0000, 0x24);
  glcd_WriteCmd2(0x0000, 0x24);

  // Clear all RAM of LCD (8k)
  glcd_WriteByte(1, AutoModeWrite);
  for (counter = 0; counter < 0x1fff; counter++)
  {
    glcd_WriteByteAuto(0);    // fill everything with zeros
  }
  glcd_WriteByte(1, AutoModeReset);
}

void glcd_WriteByte(int1 cd, int data)
{
    int status = 0, temp = 0;
    output_high(LCD_WR);
    output_high(LCD_RD);
    output_high(LCD_CD);

    while (status != 0x03) {  // is LCD busy?
       output_low(LCD_RD);
       temp = lcd_port_read();     // read from lcd port
       output_high(LCD_RD);
       status = temp & 0x03;
    }

    if(bit_test(cd,0))  output_high(LCD_CD);
    else                output_low(LCD_CD);
    lcd_port(data);
    output_high(LCD_RD);
    output_low(LCD_WR);
    output_high(LCD_WR);
}

void glcd_WriteByteAuto(int data)
{
   int status = 0, temp = 0; // status bits ARE DIFFERENT BITS THAN NORMAL
   output_high(LCD_WR);
   output_high(LCD_RD);
   output_high(LCD_CD);

   while (status != 0x08) {  // is LCD busy?
     output_low(LCD_RD);
     temp = lcd_port_read();     // read from lcd port
     output_high(LCD_RD);
     status = temp & 0x08;
   }

   output_low(LCD_CD);
   lcd_port(data);
   output_low(LCD_WR);
   output_high(LCD_WR);
}

void glcd_WriteCmd1(int data, int cmd)
{
  glcd_WriteByte(0, data);
  glcd_WriteByte(1, cmd);
}

void glcd_WriteCmd2(int16 data, int cmd)
{
  glcd_WriteByte(0, data & 0xff);
  glcd_WriteByte(0, data>>8);
  glcd_WriteByte(1, cmd);
}

int glcd_ReadByte(void)
{
  int data = 0, status = 0, temp = 0;
  output_high(LCD_WR);
  output_high(LCD_RD);
  output_high(LCD_CD);

  #asm nop nop #endasm

  while (status != 0x03) {  // is LCD busy?
    output_low(LCD_RD);
    temp = lcd_port_read();     // read from lcd port
    output_high(LCD_RD);
    status = temp & 0x03;
  }

  output_low(LCD_CD);
  output_low(LCD_RD);
  /////////////////////////////////////////////////////////
  #asm nop nop #endasm    // THIS PAUSE IS VERY NESSESARY !!!//
  /////////////////////////////////////////////////////////
  data = lcd_port_read();     // read from lcd port
  output_high(LCD_RD);

  output_high(LCD_CD);
  return data;        // Return the read data
}

void glcd_putc(char c) {
   glcd_WriteCmd1(c - 0x20, 0xc0);
}

void glcd_gotoxy(int x, int y, int1 text) { // sets memory location to screen location x, y
   // location 1,1 is upper left corner;  text = 1 (text area), text = 0 (graphics area)
   int16 location, home;
   int line;

   if (!text) {
      home = GraphicsHome;
      line = GraphicsArea;
   }
   else {
      home = TextHome;
      line = TextArea;
   }

   location = home + (((int16)y - 1) * line) + x - 1;
   glcd_WriteCmd2(location, 0x24);
}

#use fast_io(D)

void main() {

   setup_adc_ports(ALL_ANALOG);
   setup_adc(ADC_CLOCK_DIV_8);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_wdt(WDT_ON);
   setup_timer_0(RTCC_DIV_256|RTCC_8_bit);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   enable_interrupts(INT_RTCC);
   enable_interrupts(INT_AD);
   enable_interrupts(INT_RB);
   enable_interrupts(global);

   glcd_init();
   glcd_WriteByte(1, (LCDModeSet|LCDMode_XOR));
   glcd_WriteByte(1, (LCDDispMode|LCDDisp_TXT|LCDDisp_GRH));
   
while(1) {
   glcd_gotoxy(1,1,1);
   glcd_putc("It works :o))");
   
   glcd_gotoxy(1,3,1);
   glcd_putc("LCD with T6963 controller");
   
   glcd_gotoxy(1,6,1);
   glcd_putc("Modified for 240x128px, 20MHzHS, FS=1");
   
   glcd_gotoxy(1,7,1);
   glcd_putc("Hardware conection of LCD to any pins");
   
   glcd_gotoxy(1,12,1);
   glcd_putc("http://www.elweb.cz/ (Czech Republic)");


 
   for (n = 0; n< 16; n++) {
      glcd_gotoxy(2,100+n,0);  // small black rectangle
      glcd_WriteCmd1(0xff,0xc0);
   }
   
   delay_ms(3000);
}
}
sdonmez



Joined: 25 Jun 2008
Posts: 3

View user's profile Send private message

PostPosted: Mon Dec 28, 2009 11:51 am     Reply with quote

I'm trying to use 240x128 Glcd with T6963 controller. I'm using this driver for glcd.
Code:

#define set_tris_lcd(x) set_tris_d(x)
#define LCDColorBlack 0b1
#define LCDColorWhite 0b0

//TRIS DataBus=x,  note:control bus (PORTC) always outputs
unsigned int16 TextHome = 0x0F00;//0x0780;
const int8  TextArea = 0x001E; // how many bytes before a new line
const int16 GraphicsHome = 0x0000;
const int8  GraphicsArea = 0x001E; // how many bytes before a new line

const int8 AutoModeWrite = 0xB0;
const int8 AutoModeRead  = 0xB1;
const int8 AutoModeReset = 0xB2;

const int8 LCDModeSet  = 0x80;   // send this OR'd with the following
const int8 LCDMode_OR  = 0b0000;
const int8 LCDMode_XOR = 0b0001;
const int8 LCDMode_AND = 0b0011;
const int8 LCDMode_TA  = 0b0100; // TEXT ATTRIBUTE mode.
const int8 LCDMode_RAM = 0b1000; // 1=CG RAM, 0=internal CG ROM

const int8 LCDSetCursorPtr  = 0x21;  // cursor address
const int8 LCDSetCursorSize = 0xA0;  // 1 line cursor
               
const int8 LCDDispMode = 0x90;   // send this OR'd with the following
const int8 LCDDisp_BLK = 0b0001;
const int8 LCDDisp_CUR = 0b0010;
const int8 LCDDisp_TXT = 0b0100;
const int8 LCDDisp_GRH = 0b1000;

const int8 LCDBitSet   = 0xF8;
const int8 LCDBitReset = 0xF0;
const int8 LCDBit0 = 0b000;
const int8 LCDBit1 = 0b001;
const int8 LCDBit2 = 0b010;
const int8 LCDBit3 = 0b011;
const int8 LCDBit4 = 0b100;
const int8 LCDBit5 = 0b101;
const int8 LCDBit6 = 0b110;
const int8 LCDBit7 = 0b111;

const int8 LCDSetPtr = 0xE0;



struct lcd_pin_def                                                       
{
   BOOLEAN unused1;       // C0
   BOOLEAN unused2;       // C1
   BOOLEAN unused3;     // C2
   BOOLEAN unused4;     // C3
   BOOLEAN w_bar;        // C4 Write bar active low
   BOOLEAN r_bar;        // C5 Read bar active low
   BOOLEAN cd;            // C6 Command/Data BAR   1=command 0=data
   BOOLEAN reset_bar;     // C7 Reset active low
   int  data    :  8;     // PortD=Data bus
};
struct lcd_pin_def  LCD;

  #byte LCD = 0xf82    // portC address on 18F452
                                               
int   glcd_ReadByte(void);
void  glcd_WriteByte(int1 cd, int data);
void  glcd_WriteByteAuto(int data);
void  glcd_WriteCmd2(int16 data, int cmd);
void  glcd_WriteCmd1(int data, int cmd);
void  glcd_gotoxy(int x, int y, int1 text);
                                                   
#inline
void glcd_init(unsigned int16 res_x, unsigned int16 res_y) {
   
  int16 counter;
 
  TextHome = (res_x/8)*res_y; //0x0F00;//0x0780;
 
  set_tris_c(0x00);  // graphic lcd control lines all output
  set_tris_lcd(0xff);   //TRIS DATA bus,note:control bus always outputs

  LCD.w_bar = 1;      // INITIAL STATES OF CONTROL PINS
  LCD.r_bar = 1;      //
  LCD.cd = 1;         // command   

  LCD.reset_bar = 0;  // perform a reset
  delay_us(20);         // delay for a reset
  LCD.reset_bar = 1;  // run       

  // Set up the graphics and text areas
  glcd_WriteCmd2(TextHome, 0x40);
  glcd_WriteCmd2(TextArea, 0x41);
  glcd_WriteCmd2(GraphicsHome, 0x42);
  glcd_WriteCmd2(GraphicsArea, 0x43);

  // set address to 0
  glcd_WriteCmd2(0x0000, 0x24);
  glcd_WriteCmd2(0x0000, 0x24);

  // Clear all RAM of LCD (8k)
  glcd_WriteByte(1, AutoModeWrite);
  for (counter = 0; counter < 0x1fff; counter++)
  {
    glcd_WriteByteAuto(0);    // fill everything with zeros
  }
  glcd_WriteByte(1, AutoModeReset);
}

void glcd_WriteByte(int1 cd, int data)
{
    int status = 0, temp = 0;
    set_tris_lcd(0xff);
    LCD.w_bar = 1;
    LCD.r_bar= 1;
    LCD.cd = 1;//defaults

    while (status != 0x03) {  // is LCD busy?           
       LCD.r_bar= 0;
       temp = LCD.data;                 
       LCD.r_bar = 1;
       status = temp & 0x03;
    }

    set_tris_lcd(0x00);    // All outputs
    LCD.cd = cd;           // Command/Data bar
    LCD.data = data;                 
    LCD.r_bar = 1;         // not read
    LCD.w_bar = 0;         // write 
    LCD.w_bar = 1;         // release
}


void glcd_WriteByteAuto(int data)
{
   int status = 0, temp = 0; // status bits ARE DIFFERENT BITS THAN NORMAL
   set_tris_lcd(0xff);
   LCD.w_bar = 1;
   LCD.r_bar = 1;
   LCD.cd = 1; // defaults
                                       
   while (status != 0x08) {  // is LCD busy?
     LCD.r_bar = 0;
     temp = LCD.data;
     LCD.r_bar = 1;
     status = temp & 0x08;
   }

   set_tris_lcd(0x00);     // All outputs
   LCD.cd = 0;             // This is always data, cd=0
   LCD.data = data;        // Put data on data bus
   LCD.w_bar = 0;          // write
   LCD.w_bar = 1;          // release
}

void glcd_WriteCmd1(int data, int cmd)
{
  glcd_WriteByte(0, data);
  glcd_WriteByte(1, cmd);
}

void glcd_WriteCmd2(int16 data, int cmd)
{
  glcd_WriteByte(0, data & 0xff);
  glcd_WriteByte(0, data>>8);
  glcd_WriteByte(1, cmd);
}

int glcd_ReadByte(void)
{
  int data = 0, status = 0, temp = 0;
  set_tris_lcd(0xff);
  LCD.w_bar = 1;
  LCD.r_bar = 1;
  LCD.cd = 1;  // defaults

  #asm nop #endasm   
 
 
  while (status != 0x03) {  // is LCD busy?
    LCD.r_bar = 0;
    temp = LCD.data;
    LCD.r_bar = 1;
    status = temp & 0x03;
  }

  LCD.cd = 0;          // Command/Data bar
  LCD.r_bar = 0;        // read
  /////////////////////////////////////////////////////////
  #asm nop #endasm    // THIS PAUSE IS VERY NESSESARY !!!//
  /////////////////////////////////////////////////////////
  data = LCD.data;       
  LCD.r_bar = 1;
  LCD.cd = 1;
  return data;        // Return the read data
}

void glcd_putc(char c) {
   glcd_WriteCmd1(c - 0x20, 0xc0);
}                                     

void glcd_gotoxy(int x, int y, int1 text) { // sets memory location to screen location x, y
   // location 1,1 is upper left corner;  text = 1 (text area), text = 0 (graphics area)
   int16 location, home;
   int line;
                                 
   if (!text) {
      home = GraphicsHome;   
      line = GraphicsArea;
   } else {
      home = TextHome;
      line = TextArea;
   }
                                                       
   location = home + (((int16)y-1) * line) + x-1;
   //location = home + (((int16)y) * line) + x;
   glcd_WriteCmd2(location, 0x24);     
}                                   

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// Purpose:       Clears LCD RAM
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void glcd_clr(int16 location,int16 size)
{
  ////fprintf(DEBUG,"loc=%lu  size=%lu\n\r",location,size);
  // look very simular to the init,... doesn't it. : )
  glcd_WriteCmd2(location,LCDSetPtr);
  glcd_WriteCmd1(1,AutoModeWrite);
  for (;size;size--)
  {
    glcd_WriteByteAuto(0x00);//clear ram         
  }
  glcd_WriteCmd1(1,AutoModeReset);
}

/////////////////////////////////////////
// Graphics Controller by endSly (c)2007
//    endSly@gmail.com
//       Not for comercial use
/////////////////////////////////////////
                                                               
unsigned int8 i;  //General Purpouse variable

// glcd_pixel(x,y,c) sets pixel x,y with c color
void glcd_pixel(unsigned int8 x, unsigned int8 y, int1 c){
   unsigned int8 x_H;
   unsigned int8 x_L=0;
   x_H = (x / 8);
   x_L = 7 - (x - 8*x_H); 
   glcd_gotoxy(x_H+1,y,0);    //Bug fixed, thanks to etiedon
   if(c){                                       
      glcd_WriteCmd1(1,(LCDBitSet|x_L));
   } else {               
      glcd_WriteCmd1(1,(LCDBitReset|x_L));
   }                                         
}
 
// glcd_pixel8(x,y,px8) sets 8 pixels in line.
void glcd_pixel8(unsigned int8 x, unsigned int8 y, int8 pixel8){
   unsigned int8 x_H;     
   x_H = (x / 8);
   glcd_gotoxy(x_H+1,y,0);   
   //glcd_gotoxy(x_H+1,y,0);
   // data write and increment ADP
   glcd_WriteCmd1(pixel8,0xc0);                         
}               
                                                                                                       
//glcd_image8 (*Pic, x, y, size_x, size_y)
void glcd_image8(int8 *pic_px, unsigned int16 x, unsigned int16 y,
                 unsigned int16 size_x, unsigned int16 size_y){
   
   unsigned int16 px_y;                   
   unsigned int16 px_x;                     
   unsigned int16 px=0;         
                                       
   for(px_y=y; px_y<(y+size_y); px_y++){
      for(px_x=x; px_x<(x+size_x); px_x+=8){
         glcd_pixel8(px_x, px_y, *(pic_px+px));   
         px+=1;
      }                 
   }               
}

// glcd_line(x0,y0, x1,y1, c) puts line from (x0, y0) to (x1, y1) with c color 
void glcd_line(signed int16 x0, signed int16 y0,
               signed int16 x1, signed int16 y1 , int1 c){
   int16 x;
   int16 y;
   unsigned int16 n;
   int1 m_case;
   
   x=abs(x1-x0);
   y=abs(y1-y0);
   
   if (y > x){
      n=(y1-y0);
      m_case=1;
   } else {
      n=(x1-x0);
      m_case=0;
   }
   for(i=0 ; i<=n ; i++){
      if (m_case){
         y=i + y0;
         x=(y*(x1-x0))/(y1-y0) + x0;
      } else {
         x=i + x0;
         y=(x*(y1-y0))/(x1-x0) + y0;
      }
      glcd_pixel(x, y,c);
   }
                         
}

// glcd_square(x0,y0,x1,y1, c) sets square
void glcd_square( unsigned int8 x0, unsigned int8 y0,
                  unsigned int8 x1, unsigned int8 y1 , int1 c){
   glcd_line(x0,y0, x1,y0, c);
   glcd_line(x1,y0, x1,y1, c);
   glcd_line(x0,y1, x1,y1, c);
   glcd_line(x0,y0, x0,y1, c);
}

// glcd_box(x0,y0,x1,y1, c)
void glcd_box( unsigned int8 x0, unsigned int8 y0,
               unsigned int8 x1, unsigned int8 y1 , int1 c){
   unsigned int8 x;
   unsigned int8 y;
   for(y=y0; y<=y1;y++){         
      for(x=x0; x<=x1;x++){
         if((!(x%8)) && ((x1-x)>8)){
            glcd_pixel8(x,y,0xFF*c);  //Same time to write 8 pixel
            x +=7 ;
         } else {
            glcd_pixel(x,y,c);
         }
      }
   }
}


I have created 10*19 pixel fonts to display numbers on the screen.
When i try to show a number with the command
Code:

glcd_image8(&Font8x16[address], Pos_x, Pos_y, 10, 19);

It only places the "font image" on Pos_x where Pos_x is the multiples of 8.

I want to place my "font images" on pixels where i want.
Is not it possible?

Sadan
noyz



Joined: 31 Jan 2009
Posts: 59

View user's profile Send private message

PostPosted: Sun Feb 06, 2011 6:49 pm     Reply with quote

Elvex I'm trying to use your code for a display 240x128.

My connection is
PIC18F8527
I have a board already connected this way, and display with touch screen.
I can't simulate in Proteus, and write a damn thing.
If I use the board's example hex, it works in Proteus.
Code:

#define  LCD_B0   PIN_H0
#define  LCD_B1   PIN_H1
#define  LCD_B2   PIN_H2
#define  LCD_B3   PIN_H3
#define  LCD_B4   PIN_H4
#define  LCD_B5   PIN_H5
#define  LCD_B6   PIN_H6
#define  LCD_B7   PIN_H7

#define  LCD_WR   PIN_J2
#define  LCD_RD   PIN_J1
#define  LCD_CD   PIN_J0
#define  LCD_RST  PIN_J4
noyz



Joined: 31 Jan 2009
Posts: 59

View user's profile Send private message

PostPosted: Mon Feb 07, 2011 5:27 pm     Reply with quote

I manage to get lcd work.
But 2 strange things:
The text starts from 20 pixels away from 1
and in Proteus it doesn't work at all.
I was wondering also can I put a 25 mhz xt clock ?
What else do I have to modify beside use delay 25 000 000 and the real clock soldering?

I think there must be something that has to do with lcd speed.
Lcd clock can be also changed to some faster clock ?
I want a best responsive lcd.
Beenabout



Joined: 19 Jan 2010
Posts: 7

View user's profile Send private message

T6963C 128x64 pixels - setup / initialisation help required
PostPosted: Tue Feb 15, 2011 3:57 am     Reply with quote

Hi all,
I have compiled the code given above and all is OK except that I get not response from my T6963C 128x64 pixel LCD.

Please advise if this code OK to use with my LCD as is or if it needs any further modification.

I am using a 16F877A, running at 4MHz with a crystal and logic probes indicate that all signals lines are being driven by the software. The LCD is wired to the PIC as per the pinout included in the driver above.

Thanks,
Tony
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group