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 CCS Technical Support

display driver

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Eldert Besseling



Joined: 07 Oct 2003
Posts: 7

View user's profile Send private message

display driver
PostPosted: Mon Apr 26, 2004 4:37 am     Reply with quote

Hi All,

I am searching for drivers for the winstar WG12864F-YYH-V display
This is a LCD display with a character generator T6963C

Has somebody drivers written for it?

Regards

Eldert
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Mon Apr 26, 2004 10:20 am     Reply with quote

Yup, did this one too.
I wish we could have a file pile for code snipets and drivers.
Take it for what its worth. I'm not sure how complete it is.
I just mod a different graphics LCD driver.

Code:

/////////////////////////////////////////////////////////////////////////
//// c:\program files\PICC\drivers\LCD_T6963C.c                      ////
//// This file contains drivers for using a Tosiba T6963C controller ////
//// in parallel/8080(intel) mode.  The T6963C is 240 pixles across  ////
////  and 64 pixels down. The driver treats the upper left pixel 0,0 ////
////                                                                 ////
////  glcd_init(mode)                                                ////
////  glcd_pixel(x,y,color)                                          ////
////  glcd_line(x1,y1,x2,y2,color)                                   ////
////  glcd_rect(x1,y1,x2,y2,fill,color)                              ////
////  glcd_bar(x1,y1,x2,y2,width,color)                              ////
////  glcd_circle(x,y,radius,fill,color)                             ////
////  glcd_text57(x,y,textptr,size,color)                            ////
////  glcd_fillScreen(color)                                         ////
/////////////////////////////////////////////////////////////////////////
#ifndef GLCD_COL
#define GLCD_COL 240    // Used for text wrapping by glcd_text57 function and sanity check
#endif
#ifndef GLCD_ROW
#define GLCD_ROW 64    // Used for text wrapping by glcd_text57 function and sanity check
#endif
#define ON  1
#define OFF 0
#define YES 1
#define NO  0
#define set_tris_lcd(x) set_tris_a(0);set_tris_d(x)
//TRIS DataBus=x,  note:control bus (PORTA) always outputs

////////////////////[PICK ONE OF THESE TWO SECTIONS]//////////////////
//const int1  LCDFont = 0;//Font select 
//const int16 TextHome    =0x0780;
//const int8  AreaSet_T   =0x001E;//how many bytes before a new line
//const int16 GraphicsHome=0x0000;
//const int8  AreaSet_G   =0x001E;//how many bytes before a new line
//////////////////////////////////////////////////////////////////////
const int1  LCDFont = 1;//Font select 
const int16 TextHome    =0x0780;
const int8  AreaSet_T   =30;//how many bytes before a new line
const int16 GraphicsHome=0x0000;
const int8  AreaSet_G   =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 = 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;  //Number of lines in the cursor
const int8 LCDSetCursorSize=0xA0;  //Number of lines in the 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 LCDMaxBusyCount =20;//will try count-1 times before giving up

struct lcd_pin_def
{
  BOOLEAN w_bar;      // A0 Write bar active low
  BOOLEAN r_bar;      // A1 Read bar active low
  BOOLEAN ce_bar;     // A2 Chip Enable BAR active low
  BOOLEAN cd;         // A3 Command/Data BAR   1=command 0=data
  BOOLEAN reset_bar;  // A4 Reset active low
  BOOLEAN fs;         // A5 Font select
  BOOLEAN unused1;    // A6 Unused
  BOOLEAN unused2;    // A7 Unused
  int  unused4 :  8;  // PortB...  waisted some bits/bytes for clarity
  int  unused5 :  8;  // PortC...  waisted some bits/bytes for clarity
  int  data    :  8;  // PortD=Data bus
};                   
struct lcd_pin_def  LCD;

#if defined(__PCM__)
#byte LCD = 5    //(no semicolin) 5=A0 on a 16F877A
#elif defined(__PCH__)
#byte LCD = 3968    //(no semicolin)3968=A0 on a 18F452
#endif

void glcd_FontSelect(int1 fs);
BYTE glcd_ReadByte();
int1 glcd_WriteByte(int1 cd, BYTE data); //return, 1=success 0=failure
int1 glcd_WriteByteAuto(BYTE data); //return, 1=success 0=failure
int1 glcd_WriteCmd2(int16 data, BYTE cmd);
int1 glcd_WriteCmd1(BYTE data, BYTE cmd);
//BOOLEAN glcd_pixel(unsigned int x,unsigned int y, int1 color);
//void glcd_fillScreen(int1 color);

void glcd_init(int1 mode) //init is the only function changed
{
  int16 counter;
  fprintf(DEBUG,"LCD init\r");
  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.ce_bar=0;     //
  LCD.cd=1;         // data
  LCD.fs=LCDFont;   // FontSelect
 
  LCD.reset_bar=0;  // preform a reset
  delay_us(2);      // delay the prescribed time for a reset
  LCD.reset_bar=1;  // run

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

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

  fprintf(DEBUG,"LCD init DONE.\r");
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// Purpose:       Writes a byte of data from the current location
// Inputs:        cd  1=command 0=data     BYTE data
// Ouputs:        Int1 1=success 0=failure
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
int1 glcd_WriteByte(int1  cd, BYTE data)
{
  BYTE status=0,count=0;
    set_tris_lcd(0xFF);   
    LCD.w_bar=1;LCD.r_bar=1;LCD.cd=1;LCD.fs=LCDFont;//defaults

WriteByteLabel:
    // First section checks if LCD is busy
    LCD.r_bar=0;      // Read 
    status=LCD.data;  // Latch data
    LCD.r_bar=1;      // Release
    ++count;
    if (count>LCDMaxBusyCount)
    {
      fprintf(DEBUG,"-Error writing to LCD,.. Busy\r");
      return(0);
    }
  if (!bit_test(status,0) || !bit_test(status,1)) //loop if either is 0
      {
        goto WriteByteLabel;
      }

  //if(cd==0) {fprintf(DEBUG,"Data=   %lx\r",data);}
  //if(cd==1) {fprintf(DEBUG,"Command %lx\r",data);}
    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
    set_tris_lcd(0xFF); //Port D tristate ie: all inputs
    return (1);   //Return status
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// Purpose:       Writes continuous bytes of data from the current location
// Inputs:        BYTE data
// Ouputs:        Int1 1=success 0=failure
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
int1 glcd_WriteByteAuto(BYTE data)
{
  BYTE status=0,count=0;    //status bits ARE DIFFERENT BITS THAN NORMAL
    set_tris_lcd(0xFF);   //First section checks if LCD is busy
    LCD.w_bar=1;LCD.r_bar=1;LCD.cd=1;LCD.fs=1;//defaults
  do
  {
    LCD.r_bar=0;      // Read 
    status=LCD.data;  // Latch data
    LCD.r_bar=1;      // Release
    ++count;
    if (count>LCDMaxBusyCount)
    {
      fprintf(DEBUG,"0Error writing to LCD,.. Busy status=%x\r",status);
      return(0);
    }
  }while (!bit_test(status,3));//Check until bit3==1 (ready)
  set_tris_lcd(0x00); //All outputs
  LCD.cd=0;           //This is always data, cd=0
  LCD.data=data;      //Put data on data bus
  LCD.r_bar=1;        //not read
  LCD.w_bar=0;        //write
  LCD.w_bar=1;        //release
  set_tris_lcd(0xFF); //Port D tristate ie: all inputs
  return (1);   //Return status
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// Purpose:       Writes a one byte of data and a command
// Inputs:        BYTE data     BYTE cmd
// Ouputs:        Int1 1=success 0=failure
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
int1 glcd_WriteCmd1(BYTE data, BYTE cmd)
{
  if (!glcd_WriteByte(0,data)){
    fprintf(DEBUG,"2Error LCD is Busy\r");
    return (0);
  }
  if (!glcd_WriteByte(1,cmd)){
    fprintf(DEBUG,"3Error LCD is Busy\r");
    return (0);
  }
  return (1);
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// Purpose:       Writes a two data byte command
// Inputs:        int16 data     BYTE cmd
// Ouputs:        Int1 1=success 0=failure
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
int1 glcd_WriteCmd2(int16 data, BYTE cmd)
{
 
  if (!glcd_WriteByte(0,data & 0xFF)){
    fprintf(DEBUG,"1Error LCD is Busy\r");
    return (0);
  }
  if (!glcd_WriteByte(0,data>>8)){
    fprintf(DEBUG,"2Error LCD is Busy\r");return (0);
  }
  if (!glcd_WriteByte(1,cmd)){
    fprintf(DEBUG,"3Error LCD is Busy\r");
    return (0);
  }
  return (1);
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// Purpose:       Reads a byte of data from the current location
// Ouputs:        A byte of data read from the LCD
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
BYTE glcd_ReadByte()
{
  BYTE data,status,count=0;          // Stores the data read from the LCD
  set_tris_lcd(0xFF)  ;  //First section checks if LCD is busy
  LCD.w_bar=1;LCD.r_bar=1;LCD.cd=1;LCD.fs=LCDFont;//defaults
  LCD.cd=0;
 
ReadByteLabel:
  LCD.r_bar=0;      // Read
  status=LCD.data;  // Latch data
  LCD.r_bar=1;      // Release
  ++count;
  if (count>LCDMaxBusyCount)
  {
    fprintf(DEBUG,"-Error writing to LCD,.. Busy\r");
    return(0);
  }
  if (!bit_test(status,0) || !bit_test(status,1)) //loop if either is 0
  {
    //        fprintf(DEBUG,".");
    goto ReadByteLabel;
  }
  LCD.cd=0;          // Command/Data bar
  LCD.r_bar=0;        // read
  data=LCD.data;
  LCD.r_bar=1;
  return data;        //Return the read data
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// Purpose:       Sends data to LCD
// Ouputs:        A byte of data read from the LCD
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void glcd_putc( char c) {
  //fprintf(DEBUG,"->%x\r",c);
   switch (c) {
//     case '\f'   : lcd_send_byte(0,1);
//                   delay_ms(2);
//                                           break;
//     case '\n'   : lcd_gotoxy(1,2);        break;
//     case '\b'   : lcd_send_byte(0,0x10);  break;
     default     : glcd_WriteCmd1(c-0x20,0xc0);break;//Write to LCD autoinc
     
   }
}
xmen



Joined: 30 Jul 2004
Posts: 2

View user's profile Send private message

PostPosted: Fri Jul 30, 2004 9:23 pm     Reply with quote

Hello Treitmey:

In your source code, there are a lot of functions that are not in source code.

Concretely, are not:

glcd_pixel(x,y,color)
glcd_line(x1,y1,x2,y2,color)
glcd_rect(x1,y1,x2,y2,fill,color)
glcd_bar(x1,y1,x2,y2,width,color)
glcd_circle(x,y,radius,fill,color)
glcd_text57(x,y,textptr,size,color)
glcd_fillScreen(color)


May you provide full source code, please ?

Regards.
======
dyeatman



Joined: 06 Sep 2003
Posts: 1933
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Jul 31, 2004 12:40 pm     Reply with quote

Treitmey,
You can put it in the code library... For us thats the "file pile"

Laughing
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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