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

Display driver for LM6063 GLCD

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
alan



Joined: 12 Nov 2012
Posts: 349
Location: South Africa

View user's profile Send private message

Display driver for LM6063 GLCD
PostPosted: Mon Dec 10, 2012 4:01 am     Reply with quote

Below is a driver based on Torello's driver also in this forum but for the LM6063 chip.

Uses the SPI bus instead of software SPI and include the necessary changes to work, otherwise it performs the same as the original driver.

Thanks Torello for the driver, made the work much less than to design from scratch.

I only included the PgSer.c file as the others are identical to Torello's files.

Code:

void glcd_WriteData(int8 data, char type) {
   //Wait while SPI still busy
   //while (SPI2_Busy) {}
   output_bit(CS,0);               //Chip Select = Active
   output_bit(A0,type);               //A0 = Data
   //SPI2_Busy = TRUE;
   spi_write2(data);
}

void glcd_Init() {
output_bit(CS,1);
output_bit(A0,0);
output_bit(CS,0);
output_bit(RES,0);
delay_ms(100);
output_bit(RES,1);
delay_ms(10);

glcd_WriteData(0xE2,0);                  //Reset display
glcd_WriteData(0xA2,0);                  //1/9 bias
glcd_WriteData(0xA1,0);                  //RAM->SEG output = normal
glcd_WriteData(0xC0,0);                  //COM scan direction = normal
glcd_WriteData(0x40,0);                  //Set Display start line
glcd_WriteData(0x2C,0);                  //power control set
glcd_WriteData(0x2E,0);                  //power control set
glcd_WriteData(0x2F,0);                  //power control set
glcd_WriteData(0x25,0);                  //set Rb/Ra voltage resistor ratio to 6 (Adafruit Value, no info from LM6063 Manual)
glcd_WriteData(0xA6,0);                  //Normal Display
glcd_WriteData(0x81,0);                  //Electronic volume command (set contrast)
//Electronic volume value (contrast value) Higher less contrast
glcd_WriteData(0x28,0);
glcd_WriteData(0xAF,0);                  //Display ON

//glcd_WriteData(0xA5,0);                  //Display all points ON
//delay_ms(1);
}

void glcd_DispClr() {
  unsigned int8 i,j;

  glcd_WriteData(0xE0,0);  //Col inc after write
  for(j=0;j<8;j++){
    glcd_SetRowCol(j,0);
    for(i=0; i<128; i++) {             // 16 bytes per line 64 lines
      glcd_WriteData(0,1);                // write empty byte
    }
  }     
  glcd_WriteData(0xE0,0);  //Reset Col inc after write
}

void glcd_SetRowCol(int8 row, int8 col) {   // Col=0..15, Row=0..63
  int8 cl;
  glcd_WriteData((row&0x0F)+0xB0,0);               // set the X adr=0 (0-15)
  cl=(col&0x0F)+ 0x0;                   // concat command to Ynibble low
  glcd_WriteData(cl,0);                     // set the Yadr low nibble  (0-63)
  cl=(swap(col)&0x0F)+0x10;              // concat command to Ynibble high
  glcd_WriteData(cl,0);                     // set the Yadr hi nibble   (0-63)
}

void glcd_printf(int8 row, int8 col, char *cstring, int8 mode) {
  int8 cl,c,i,j;                        // col counter     
  int8 si;                              // string index
  int8 bi;                              // font byte index 
  int8 fi;                              // font array index
  int8 BoxSm;                           // box State machine 0=no box
  int8 W2Sm;                            // width2 state machine
  int8 Lmax;                            // number of lines in casde of magnify       
 
  Lmax=1;                                 //H1 line
  if ( dBT(h2) ) Lmax=2;                  //H2 line
  if ( dBT(h4) ) Lmax=4;                  //H4 line
    row=row>>3;
  for(i=0; i<Lmax; i++) {                 // line loop
    cl=col;                            // load current col with start colum
    si=0;                                 // clear string index
    bi=0;                                 // clear font byte line index       
    fi=0;                                 // clear from 255;
    W2Sm=0;                               // clear width state machine
    BoxSm=0; if dBT(box) BoxSm=1;         // arm box statemachine   
    if dBT(inv) BoxSm=1;                  // invert mode add 1 vertical black line (more readable)
   
   
    do {
      if dBT(w2) W2Sm=2;                  // arm width2 statemachine
      if (!bi) {
        if (BoxSm==1) {
          BoxSm=2;                        // advance state machine "print chars"
          if dBT(inv) BoxSm=3;            // invert mode add 1 vertical black line then stop BoxSM.
          si--;                           // need to correct the bi==5 increment.
          bi=5;                           // force next line to be a space line
          c=0xFF;                         // load the vertical line
          goto pf_next_bx;                // skip font[]{bi] reading stuff
        } else { 
          fi = cstring[si];               // get string character
          if (fi==0) {                    // string end read. But:
            if (BoxSm==2) {
              BoxSm=3;                    // advance state machine
              c=0xFF;                     // load the vertical line
              goto pf_next_bx;            // skip font[]{bi] reading stuff
            } else { 
              fi=255;                     // load sting end value need to exit while
              goto pf_next2;              // ri==0 thus we are done for this line
            } 
          }
          fi-=32;                         // substract font array offset
        }
      }
     
      if (bi<5) {                         // still reading font
        c = Font5x7[fi][bi];              // read font data
        bi++;
        if (c==0x99) {                    // T: font end marker detected
          c=0;                            // replace with empty
          if dBT(var) {                   // var font requested..
            bi=0; si++;                   // so 0x99 ends character
          }   
        } 
      } else {                           
        c=0;                              // bi=5 always a space line       
        bi=0; si++;                       // clear byte line index and increase character index.
      }

      pf_next_bx:

      if dBT(h2) {                        // T: double magnefy character
        if (i) swap(c);                   // line2; need upper nible as magnefy index
        c&=0x0F;                          // get rid of unwanted nibble
        c = Mgnfy2[c];                    // get the magnefied font byte
      } 

      if dBT(h4) {                        // T: quadruplle magnefy character
        if (i&0x2) swap(c);               // line2 or 3; need upper nible as magnefy index
        if (i&0x1) c>>=2;                 // need b3&2 on spot b1&0
        c&=0x03;                          // get rid of unwanted bits       
        c = Mgnfy4[c];                    // get the magnefied font byte
      } 
     
      //===== linestuf
      //Toplines:
      if (i==0) {
        if dBT(box) c|=0x01;                                                    // add boxing topline
        if dBT(tl) c|=0x01;                                                     // add just topline
        if (!dBT(h2) && !dBT(h4) ) {                                            // T: Height -SINGLE-
          if dBT(box) c|=0x80;                                                  // add boxing botline 
          if dBT(bl) c|=0x80;                                                   // add touching botline
        }
      }
      if ((i==1) && dBT(h2)) {                                                  // last line Height -DOUBLE-
        if dBT(box) c|=0x80;                                                    // add boxing botline (free botline)
        if dBT(bl) c|=0x80;                                                     // add free botline
      }
     
      if ((i==3) && dBT(h4)) {                                                  // last line Height -QUADRO-
        if (c==0xFF) c=0x3F;                                                    // correct left right vertical boxing line for i==3
        if dBT(box) c|=0x20;                                                    // add boxing botline 
        if dBT(bl) c|=0x20;                                                     // add free botline
        if dBT(inv) c|=0xC0;                                                    // correct inversion to come
      }
     
      pf_next3:
      if dBT(inv) c=~c;                                                         // T: invert font.
     
      do {
     
        pf_next1:     
        glcd_SetRowCol(row,cl++);                                               //set printing adress and increase cl.
        glcd_WriteData(c,1);                                             
      if (W2Sm) W2Sm--;                                                         //countdown w2 state machine
      } while (W2Sm>0);
     
    } while( (cl<128) && (fi!=255));                                             // until colum 16 is written or end sign set
   
    pf_next2:
    row=row+1;                                                                     // next line
  }
}
octopuss83



Joined: 06 Nov 2011
Posts: 13

View user's profile Send private message

Config SPI
PostPosted: Sun Jan 26, 2014 4:41 am     Reply with quote

Can you tell me how is set your Spi ?

#USE SPI(???) (MASTER , Speed ? etc...)

and

setup_spi2 (???)

Thanks for your driver ...
_________________
______________________

-- Octopuss ---
pieter



Joined: 16 Jan 2011
Posts: 27

View user's profile Send private message

PostPosted: Tue May 06, 2014 3:39 pm     Reply with quote

Hi Alan,
can you post the complete library with all files please?
Thanks!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library 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