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

thick display fonts for K0108 based LCD

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







thick display fonts for K0108 based LCD
PostPosted: Mon Mar 08, 2010 4:56 am     Reply with quote

Can anyone please help me on the below code, its the same CCS example code with some modification for rendering bitmap fonts.
Can anyone please identify why the LCD is not showing any letter?
I'm using the additional functions - glcd_text() & glcd_glyph()
Code:

#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)

#include "HDM64GS12.c"

void main() {
   char str[10];
   strcpy(str,"W");

   glcd_init(ON);
   glcd_Text(10,10,str);
   glcd_updateA();
}

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

#include <stdint.h>
#include <stdlib.h>
#ifndef HDM64GS12
#define HDM64GS12

#ifndef GLCD_WIDTH
#define GLCD_WIDTH   128
#endif

#ifndef GLCD_CS1
#define GLCD_CS1     PIN_B1   // Chip Selection 1
#endif

#ifndef GLCD_CS2
#define GLCD_CS2     PIN_B0   // Chip Selection 2
#endif

#ifndef GLCD_DI
#define GLCD_DI      PIN_B2   // Data or Instruction input
#endif

#ifndef GLCD_RW
#define GLCD_RW      PIN_B3   // Read/Write
#endif

#ifndef GLCD_E
#define GLCD_E       PIN_B4   // Enable
#endif

#ifndef GLCD_RST
#define GLCD_RST     PIN_B5   // Reset
#endif

#define GLCD_LEFT    0
#define GLCD_RIGHT   1

#ifndef ON
#define ON           1
#endif

#ifndef OFF
#define OFF          0
#endif
/* LCD screen and bitmap image array consants */
#define X_BYTES          127
#define Y_BYTES          8
#define SCRN_LEFT        0
#define SCRN_TOP         0
#define SCRN_RIGHT       127
#define SCRN_BOTTOM      63

/* display definition */
#define GLCD_NUMCONTROLLER   2
#define GLCD_NUMCONTROLLERX  2
#define GLCD_NUMCONTROLLERY  1

#define GLCD_MAXPAGE        8
#define GLCD_MAXADDRESS     64

#define GLCD_LEFTA         0
#define GLCD_TOP         0
#define GLCD_RIGHTA         (GLCD_NUMCONTROLLERX*GLCD_MAXADDRESS-1)
#define GLCD_BOTTOM         (GLCD_NUMCONTROLLERY*GLCD_MAXPAGE*8-1)

#define GLCD_MODE_NORMAL   0
#define GLCD_MODE_INVERTED  1

#define GLCD_MODE_CLEAR     0
#define GLCD_MODE_SET       1
#define GLCD_MODE_XOR       2

#define GLCD_CLEAR_BUFFER   0
#define GLCD_CLEAR_ALL      1

#define GLCD_ON            0x3F
#define GLCD_DISP_START0   0xC0
#define GLCD_SET_PAGE       0xB8
#define GLCD_SET_ADDRESS   0x40

#define GLCD_X_BYTES (GLCD_NUMCONTROLLERX*GLCD_MAXADDRESS)
#define GLCD_Y_BYTES (GLCD_NUMCONTROLLERY*GLCD_MAXPAGE)

#define GLCD_SELECTNONE      99
/* define number labels for the font selections */

const uint8_t  five_dot_glyph_table[] = {
      /* ' ' charwidth: 2 */
      0x00,    /*  [  ]  */
      0x00,    /*  [  ]  */
      0x00,    /*  [  ]  */
      0x00,    /*  [  ]  */
      0x00,    /*  [  ]  */
      0x00,    /*  [  ]  */
      0x00,    /*  [  ]  */
     
      /* '!' charwidth: 2 */
      0x00,    /*  [  ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x00,    /*  [  ]  */
      0x80,    /*  [* ]  */
      0x00,    /*  [  ]  */
     
      /* '"' charwidth: 4 */
      0x00,    /*  [    ]  */
      0xA0,    /*  [* * ]  */
      0xA0,    /*  [* * ]  */
      0x00,    /*  [    ]  */
      0x00,    /*  [    ]  */
      0x00,    /*  [    ]  */
      0x00,    /*  [    ]  */
     
      /* '#' charwidth: 8 */
      0x00,    /*  [        ]  */
      0x14,    /*  [   * *  ]  */
      0x7E,    /*  [ ****** ]  */
      0x28,    /*  [  * *   ]  */
      0xFC,    /*  [******  ]  */
      0x50,    /*  [ * *    ]  */
      0x00,    /*  [        ]  */
     
      /* '$' charwidth: 4 */
      0x40,    /*  [ *  ]  */
      0x60,    /*  [ ** ]  */
      0x80,    /*  [*   ]  */
      0x40,    /*  [ *  ]  */
      0x20,    /*  [  * ]  */
      0xC0,    /*  [**  ]  */
      0x40,    /*  [ *  ]  */
     
      /* '%' charwidth: 8 */
      0x00,    /*  [        ]  */
      0x64,    /*  [ **  *  ]  */
      0xA8,    /*  [* * *   ]  */
      0xD6,    /*  [** * ** ]  */
      0x2A,    /*  [  * * * ]  */
      0x4C,    /*  [ *  **  ]  */
      0x00,    /*  [        ]  */
     
      /* '&' charwidth: 6 */
      0x00,    /*  [      ]  */
      0x60,    /*  [ **   ]  */
      0x90,    /*  [*  *  ]  */
      0x40,    /*  [ *    ]  */
      0x98,    /*  [*  ** ]  */
      0x60,    /*  [ **   ]  */
      0x00,    /*  [      ]  */
     
      /* ''' charwidth: 2 */
      0x00,    /*  [  ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x00,    /*  [  ]  */
      0x00,    /*  [  ]  */
      0x00,    /*  [  ]  */
      0x00,    /*  [  ]  */
     
      /* '(' charwidth: 3 */
      0x40,    /*  [ * ]  */
      0x80,    /*  [*  ]  */
      0x80,    /*  [*  ]  */
      0x80,    /*  [*  ]  */
      0x80,    /*  [*  ]  */
      0x80,    /*  [*  ]  */
      0x40,    /*  [ * ]  */
     
      /* ')' charwidth: 3 */
      0x80,    /*  [*  ]  */
      0x40,    /*  [ * ]  */
      0x40,    /*  [ * ]  */
      0x40,    /*  [ * ]  */
      0x40,    /*  [ * ]  */
      0x40,    /*  [ * ]  */
      0x80,    /*  [*  ]  */
     
      /* '*' charwidth: 6 */
      0x00,    /*  [      ]  */
      0x50,    /*  [ * *  ]  */
      0x20,    /*  [  *   ]  */
      0xF8,    /*  [***** ]  */
      0x20,    /*  [  *   ]  */
      0x50,    /*  [ * *  ]  */
      0x00,    /*  [      ]  */
     
      /* '+' charwidth: 6 */
      0x00,    /*  [      ]  */
      0x20,    /*  [  *   ]  */
      0x20,    /*  [  *   ]  */
      0xF8,    /*  [***** ]  */
      0x20,    /*  [  *   ]  */
      0x20,    /*  [  *   ]  */
      0x00,    /*  [      ]  */
     
      /* ',' charwidth: 3 */
      0x00,    /*  [   ]  */
      0x00,    /*  [   ]  */
      0x00,    /*  [   ]  */
      0x00,    /*  [   ]  */
      0x40,    /*  [ * ]  */
      0x40,    /*  [ * ]  */
      0x80,    /*  [*  ]  */
     
      /* '-' charwidth: 4 */
      0x00,    /*  [    ]  */
      0x00,    /*  [    ]  */
      0x00,    /*  [    ]  */
      0xE0,    /*  [*** ]  */
      0x00,    /*  [    ]  */
      0x00,    /*  [    ]  */
      0x00,    /*  [    ]  */
     
      /* '.' charwidth: 2 */
      0x00,    /*  [  ]  */
      0x00,    /*  [  ]  */
      0x00,    /*  [  ]  */
      0x00,    /*  [  ]  */
      0x00,    /*  [  ]  */
      0x80,    /*  [* ]  */
      0x00,    /*  [  ]  */
     
      /* '/' charwidth: 4 */
      0x20,    /*  [  * ]  */
      0x20,    /*  [  * ]  */
      0x40,    /*  [ *  ]  */
      0x40,    /*  [ *  ]  */
      0x80,    /*  [*   ]  */
      0x80,    /*  [*   ]  */
      0x00,    /*  [    ]  */
     
      /* '0' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x60,    /*  [ **  ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x60,    /*  [ **  ]  */
      0x00,    /*  [     ]  */
     
      /* '1' charwidth: 3 */
      0x00,    /*  [   ]  */
      0x40,    /*  [ * ]  */
      0xC0,    /*  [** ]  */
      0x40,    /*  [ * ]  */
      0x40,    /*  [ * ]  */
      0x40,    /*  [ * ]  */
      0x00,    /*  [   ]  */
     
      /* '2' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x60,    /*  [ **  ]  */
      0x90,    /*  [*  * ]  */
      0x20,    /*  [  *  ]  */
      0x40,    /*  [ *   ]  */
      0xF0,    /*  [**** ]  */
      0x00,    /*  [     ]  */
     
      /* '3' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x60,    /*  [ **  ]  */
      0x90,    /*  [*  * ]  */
      0x20,    /*  [  *  ]  */
      0x90,    /*  [*  * ]  */
      0x60,    /*  [ **  ]  */
      0x00,    /*  [     ]  */
     
      /* '4' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x20,    /*  [  *  ]  */
      0x60,    /*  [ **  ]  */
      0xA0,    /*  [* *  ]  */
      0xF0,    /*  [**** ]  */
      0x20,    /*  [  *  ]  */
      0x00,    /*  [     ]  */
     
      /* '5' charwidth: 4 */
      0x00,    /*  [    ]  */
      0xE0,    /*  [*** ]  */
      0x80,    /*  [*   ]  */
      0xE0,    /*  [*** ]  */
      0x20,    /*  [  * ]  */
      0xC0,    /*  [**  ]  */
      0x00,    /*  [    ]  */
     
      /* '6' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x20,    /*  [  *  ]  */
      0x40,    /*  [ *   ]  */
      0xE0,    /*  [***  ]  */
      0x90,    /*  [*  * ]  */
      0x60,    /*  [ **  ]  */
      0x00,    /*  [     ]  */
     
      /* '7' charwidth: 4 */
      0x00,    /*  [    ]  */
      0xE0,    /*  [*** ]  */
      0x20,    /*  [  * ]  */
      0x40,    /*  [ *  ]  */
      0x40,    /*  [ *  ]  */
      0x40,    /*  [ *  ]  */
      0x00,    /*  [    ]  */
     
      /* '8' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x60,    /*  [ **  ]  */
      0x90,    /*  [*  * ]  */
      0x60,    /*  [ **  ]  */
      0x90,    /*  [*  * ]  */
      0x60,    /*  [ **  ]  */
      0x00,    /*  [     ]  */
     
      /* '9' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x60,    /*  [ **  ]  */
      0x90,    /*  [*  * ]  */
      0x70,    /*  [ *** ]  */
      0x20,    /*  [  *  ]  */
      0x40,    /*  [ *   ]  */
      0x00,    /*  [     ]  */
     
      /* ':' charwidth: 2 */
      0x00,    /*  [  ]  */
      0x00,    /*  [  ]  */
      0x80,    /*  [* ]  */
      0x00,    /*  [  ]  */
      0x00,    /*  [  ]  */
      0x80,    /*  [* ]  */
      0x00,    /*  [  ]  */
     
      /* ';' charwidth: 3 */
      0x00,    /*  [   ]  */
      0x00,    /*  [   ]  */
      0x40,    /*  [ * ]  */
      0x00,    /*  [   ]  */
      0x40,    /*  [ * ]  */
      0x40,    /*  [ * ]  */
      0x80,    /*  [*  ]  */
     
      /* '<' charwidth: 4 */
      0x00,    /*  [    ]  */
      0x20,    /*  [  * ]  */
      0x40,    /*  [ *  ]  */
      0x80,    /*  [*   ]  */
      0x40,    /*  [ *  ]  */
      0x20,    /*  [  * ]  */
      0x00,    /*  [    ]  */
     
      /* '=' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x00,    /*  [     ]  */
      0xF0,    /*  [**** ]  */
      0x00,    /*  [     ]  */
      0xF0,    /*  [**** ]  */
      0x00,    /*  [     ]  */
      0x00,    /*  [     ]  */
     
      /* '>' charwidth: 4 */
      0x00,    /*  [    ]  */
      0x80,    /*  [*   ]  */
      0x40,    /*  [ *  ]  */
      0x20,    /*  [  * ]  */
      0x40,    /*  [ *  ]  */
      0x80,    /*  [*   ]  */
      0x00,    /*  [    ]  */
     
      /* '?' charwidth: 4 */
      0x00,    /*  [    ]  */
      0xC0,    /*  [**  ]  */
      0x20,    /*  [  * ]  */
      0x40,    /*  [ *  ]  */
      0x00,    /*  [    ]  */
      0x40,    /*  [ *  ]  */
      0x00,    /*  [    ]  */
     
      /* '@' charwidth: 8 */
      0x38,    /*  [  ***   ]  */
      0x44,    /*  [ *   *  ]  */
      0x9A,    /*  [*  ** * ]  */
      0xAA,    /*  [* * * * ]  */
      0xB4,    /*  [* ** *  ]  */
      0x40,    /*  [ *      ]  */
      0x30,    /*  [  **    ]  */
     
      /* 'A' charwidth: 6 */
      0x00,    /*  [      ]  */
      0x20,    /*  [  *   ]  */
      0x20,    /*  [  *   ]  */
      0x50,    /*  [ * *  ]  */
      0x70,    /*  [ ***  ]  */
      0x88,    /*  [*   * ]  */
      0x00,    /*  [      ]  */
     
      /* 'B' charwidth: 5 */
      0x00,    /*  [     ]  */
      0xE0,    /*  [***  ]  */
      0x90,    /*  [*  * ]  */
      0xE0,    /*  [***  ]  */
      0x90,    /*  [*  * ]  */
      0xE0,    /*  [***  ]  */
      0x00,    /*  [     ]  */
     
      /* 'C' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x60,    /*  [ **  ]  */
      0x90,    /*  [*  * ]  */
      0x80,    /*  [*    ]  */
      0x90,    /*  [*  * ]  */
      0x60,    /*  [ **  ]  */
      0x00,    /*  [     ]  */
     
      /* 'D' charwidth: 5 */
      0x00,    /*  [     ]  */
      0xE0,    /*  [***  ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0xE0,    /*  [***  ]  */
      0x00,    /*  [     ]  */
     
      /* 'E' charwidth: 4 */
      0x00,    /*  [    ]  */
      0xE0,    /*  [*** ]  */
      0x80,    /*  [*   ]  */
      0xE0,    /*  [*** ]  */
      0x80,    /*  [*   ]  */
      0xE0,    /*  [*** ]  */
      0x00,    /*  [    ]  */
     
      /* 'F' charwidth: 4 */
      0x00,    /*  [    ]  */
      0xE0,    /*  [*** ]  */
      0x80,    /*  [*   ]  */
      0xE0,    /*  [*** ]  */
      0x80,    /*  [*   ]  */
      0x80,    /*  [*   ]  */
      0x00,    /*  [    ]  */
     
      /* 'G' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x70,    /*  [ *** ]  */
      0x80,    /*  [*    ]  */
      0xB0,    /*  [* ** ]  */
      0x90,    /*  [*  * ]  */
      0x70,    /*  [ *** ]  */
      0x00,    /*  [     ]  */
     
      /* 'H' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0xF0,    /*  [**** ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x00,    /*  [     ]  */
     
      /* 'I' charwidth: 2 */
      0x00,    /*  [  ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x00,    /*  [  ]  */
     
      /* 'J' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x10,    /*  [   * ]  */
      0x10,    /*  [   * ]  */
      0x10,    /*  [   * ]  */
      0x90,    /*  [*  * ]  */
      0x60,    /*  [ **  ]  */
      0x00,    /*  [     ]  */
     
      /* 'K' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x90,    /*  [*  * ]  */
      0xA0,    /*  [* *  ]  */
      0xC0,    /*  [**   ]  */
      0xA0,    /*  [* *  ]  */
      0x90,    /*  [*  * ]  */
      0x00,    /*  [     ]  */
     
      /* 'L' charwidth: 4 */
      0x00,    /*  [    ]  */
      0x80,    /*  [*   ]  */
      0x80,    /*  [*   ]  */
      0x80,    /*  [*   ]  */
      0x80,    /*  [*   ]  */
      0xE0,    /*  [*** ]  */
      0x00,    /*  [    ]  */
     
      /* 'M' charwidth: 6 */
      0x00,    /*  [      ]  */
      0x88,    /*  [*   * ]  */
      0xD8,    /*  [** ** ]  */
      0xA8,    /*  [* * * ]  */
      0x88,    /*  [*   * ]  */
      0x88,    /*  [*   * ]  */
      0x00,    /*  [      ]  */
     
      /* 'N' charwidth: 6 */
      0x00,    /*  [      ]  */
      0x88,    /*  [*   * ]  */
      0xC8,    /*  [**  * ]  */
      0xA8,    /*  [* * * ]  */
      0x98,    /*  [*  ** ]  */
      0x88,    /*  [*   * ]  */
      0x00,    /*  [      ]  */
     
      /* 'O' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x60,    /*  [ **  ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x60,    /*  [ **  ]  */
      0x00,    /*  [     ]  */
     
      /* 'P' charwidth: 5 */
      0x00,    /*  [     ]  */
      0xE0,    /*  [***  ]  */
      0x90,    /*  [*  * ]  */
      0xE0,    /*  [***  ]  */
      0x80,    /*  [*    ]  */
      0x80,    /*  [*    ]  */
      0x00,    /*  [     ]  */
     
      /* 'Q' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x60,    /*  [ **  ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x60,    /*  [ **  ]  */
      0x10,    /*  [   * ]  */
     
      /* 'R' charwidth: 5 */
      0x00,    /*  [     ]  */
      0xE0,    /*  [***  ]  */
      0x90,    /*  [*  * ]  */
      0xE0,    /*  [***  ]  */
      0xA0,    /*  [* *  ]  */
      0x90,    /*  [*  * ]  */
      0x00,    /*  [     ]  */
     
      /* 'S' charwidth: 4 */
      0x00,    /*  [    ]  */
      0x60,    /*  [ ** ]  */
      0x80,    /*  [*   ]  */
      0x40,    /*  [ *  ]  */
      0x20,    /*  [  * ]  */
      0xC0,    /*  [**  ]  */
      0x00,    /*  [    ]  */
     
      /* 'T' charwidth: 4 */
      0x00,    /*  [    ]  */
      0xE0,    /*  [*** ]  */
      0x40,    /*  [ *  ]  */
      0x40,    /*  [ *  ]  */
      0x40,    /*  [ *  ]  */
      0x40,    /*  [ *  ]  */
      0x00,    /*  [    ]  */
     
      /* 'U' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x60,    /*  [ **  ]  */
      0x00,    /*  [     ]  */
     
      /* 'V' charwidth: 6 */
      0x00,    /*  [      ]  */
      0x88,    /*  [*   * ]  */
      0x50,    /*  [ * *  ]  */
      0x50,    /*  [ * *  ]  */
      0x20,    /*  [  *   ]  */
      0x20,    /*  [  *   ]  */
      0x00,    /*  [      ]  */
     
      /* 'W' charwidth: 8 */
      0x00,    /*  [        ]  */
      0x82,    /*  [*     * ]  */
      0x54,    /*  [ * * *  ]  */
      0x54,    /*  [ * * *  ]  */
      0x28,    /*  [  * *   ]  */
      0x28,    /*  [  * *   ]  */
      0x00,    /*  [        ]  */
     
      /* 'X' charwidth: 6 */
      0x00,    /*  [      ]  */
      0x88,    /*  [*   * ]  */
      0x50,    /*  [ * *  ]  */
      0x20,    /*  [  *   ]  */
      0x50,    /*  [ * *  ]  */
      0x88,    /*  [*   * ]  */
      0x00,    /*  [      ]  */
     
      /* 'Y' charwidth: 6 */
      0x00,    /*  [      ]  */
      0x88,    /*  [*   * ]  */
      0x50,    /*  [ * *  ]  */
      0x20,    /*  [  *   ]  */
      0x20,    /*  [  *   ]  */
      0x20,    /*  [  *   ]  */
      0x00,    /*  [      ]  */
     
      /* 'Z' charwidth: 4 */
      0x00,    /*  [    ]  */
      0xE0,    /*  [*** ]  */
      0x20,    /*  [  * ]  */
      0x40,    /*  [ *  ]  */
      0x80,    /*  [*   ]  */
      0xE0,    /*  [*** ]  */
      0x00,    /*  [    ]  */
     
      /* '[' charwidth: 3 */
      0xC0,    /*  [** ]  */
      0x80,    /*  [*  ]  */
      0x80,    /*  [*  ]  */
      0x80,    /*  [*  ]  */
      0x80,    /*  [*  ]  */
      0x80,    /*  [*  ]  */
      0xC0,    /*  [** ]  */
     
      /* '\' charwidth: 4 */
      0x80,    /*  [*   ]  */
      0x80,    /*  [*   ]  */
      0x40,    /*  [ *  ]  */
      0x40,    /*  [ *  ]  */
      0x20,    /*  [  * ]  */
      0x20,    /*  [  * ]  */
      0x00,    /*  [    ]  */
     
      /* ']' charwidth: 3 */
      0xC0,    /*  [** ]  */
      0x40,    /*  [ * ]  */
      0x40,    /*  [ * ]  */
      0x40,    /*  [ * ]  */
      0x40,    /*  [ * ]  */
      0x40,    /*  [ * ]  */
      0xC0,    /*  [** ]  */
     
      /* '^' charwidth: 6 */
      0x00,    /*  [      ]  */
      0x20,    /*  [  *   ]  */
      0x50,    /*  [ * *  ]  */
      0x88,    /*  [*   * ]  */
      0x00,    /*  [      ]  */
      0x00,    /*  [      ]  */
      0x00,    /*  [      ]  */
     
      /* '_' charwidth: 6 */
      0x00,    /*  [      ]  */
      0x00,    /*  [      ]  */
      0x00,    /*  [      ]  */
      0x00,    /*  [      ]  */
      0x00,    /*  [      ]  */
      0x00,    /*  [      ]  */
      0xF8,    /*  [***** ]  */
     
      /* '`' charwidth: 3 */
      0x00,    /*  [   ]  */
      0x80,    /*  [*  ]  */
      0x40,    /*  [ * ]  */
      0x00,    /*  [   ]  */
      0x00,    /*  [   ]  */
      0x00,    /*  [   ]  */
      0x00,    /*  [   ]  */
     
      /* 'a' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x00,    /*  [     ]  */
      0x70,    /*  [ *** ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x70,    /*  [ *** ]  */
      0x00,    /*  [     ]  */
     
      /* 'b' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x80,    /*  [*    ]  */
      0xE0,    /*  [***  ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0xE0,    /*  [***  ]  */
      0x00,    /*  [     ]  */
     
      /* 'c' charwidth: 4 */
      0x00,    /*  [    ]  */
      0x00,    /*  [    ]  */
      0x60,    /*  [ ** ]  */
      0x80,    /*  [*   ]  */
      0x80,    /*  [*   ]  */
      0x60,    /*  [ ** ]  */
      0x00,    /*  [    ]  */
     
      /* 'd' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x10,    /*  [   * ]  */
      0x70,    /*  [ *** ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x70,    /*  [ *** ]  */
      0x00,    /*  [     ]  */
     
      /* 'e' charwidth: 4 */
      0x00,    /*  [    ]  */
      0x00,    /*  [    ]  */
      0x60,    /*  [ ** ]  */
      0xA0,    /*  [* * ]  */
      0xC0,    /*  [**  ]  */
      0x60,    /*  [ ** ]  */
      0x00,    /*  [    ]  */
     
      /* 'f' charwidth: 4 */
      0x00,    /*  [    ]  */
      0x60,    /*  [ ** ]  */
      0x80,    /*  [*   ]  */
      0xC0,    /*  [**  ]  */
      0x80,    /*  [*   ]  */
      0x80,    /*  [*   ]  */
      0x00,    /*  [    ]  */
     
      /* 'g' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x70,    /*  [ *** ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x70,    /*  [ *** ]  */
      0x10,    /*  [   * ]  */
      0x60,    /*  [ **  ]  */
     
      /* 'h' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x80,    /*  [*    ]  */
      0xE0,    /*  [***  ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x00,    /*  [     ]  */
     
      /* 'i' charwidth: 2 */
      0x80,    /*  [* ]  */
      0x00,    /*  [  ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x00,    /*  [  ]  */
     
      /* 'j' charwidth: 3 */
      0x40,    /*  [ * ]  */
      0x00,    /*  [   ]  */
      0x40,    /*  [ * ]  */
      0x40,    /*  [ * ]  */
      0x40,    /*  [ * ]  */
      0x40,    /*  [ * ]  */
      0x80,    /*  [*  ]  */
     
      /* 'k' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x80,    /*  [*    ]  */
      0x90,    /*  [*  * ]  */
      0xE0,    /*  [***  ]  */
      0xA0,    /*  [* *  ]  */
      0x90,    /*  [*  * ]  */
      0x00,    /*  [     ]  */
     
      /* 'l' charwidth: 2 */
      0x00,    /*  [  ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x00,    /*  [  ]  */
     
      /* 'm' charwidth: 6 */
      0x00,    /*  [      ]  */
      0x00,    /*  [      ]  */
      0xF0,    /*  [****  ]  */
      0xA8,    /*  [* * * ]  */
      0xA8,    /*  [* * * ]  */
      0xA8,    /*  [* * * ]  */
      0x00,    /*  [      ]  */
     
      /* 'n' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x00,    /*  [     ]  */
      0xE0,    /*  [***  ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x00,    /*  [     ]  */
     
      /* 'o' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x00,    /*  [     ]  */
      0x60,    /*  [ **  ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x60,    /*  [ **  ]  */
      0x00,    /*  [     ]  */
     
      /* 'p' charwidth: 5 */
      0x00,    /*  [     ]  */
      0xE0,    /*  [***  ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0xE0,    /*  [***  ]  */
      0x80,    /*  [*    ]  */
      0x80,    /*  [*    ]  */
     
      /* 'q' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x70,    /*  [ *** ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x70,    /*  [ *** ]  */
      0x10,    /*  [   * ]  */
      0x10,    /*  [   * ]  */
     
      /* 'r' charwidth: 4 */
      0x00,    /*  [    ]  */
      0x00,    /*  [    ]  */
      0xA0,    /*  [* * ]  */
      0xC0,    /*  [**  ]  */
      0x80,    /*  [*   ]  */
      0x80,    /*  [*   ]  */
      0x00,    /*  [    ]  */
     
      /* 's' charwidth: 4 */
      0x00,    /*  [    ]  */
      0x00,    /*  [    ]  */
      0x60,    /*  [ ** ]  */
      0xC0,    /*  [**  ]  */
      0x20,    /*  [  * ]  */
      0xC0,    /*  [**  ]  */
      0x00,    /*  [    ]  */
     
      /* 't' charwidth: 3 */
      0x00,    /*  [   ]  */
      0x80,    /*  [*  ]  */
      0xC0,    /*  [** ]  */
      0x80,    /*  [*  ]  */
      0x80,    /*  [*  ]  */
      0x40,    /*  [ * ]  */
      0x00,    /*  [   ]  */
     
      /* 'u' charwidth: 5 */
      0x00,    /*  [     ]  */
      0x00,    /*  [     ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x90,    /*  [*  * ]  */
      0x70,    /*  [ *** ]  */
      0x00,    /*  [     ]  */
     
      /* 'v' charwidth: 4 */
      0x00,    /*  [    ]  */
      0x00,    /*  [    ]  */
      0xA0,    /*  [* * ]  */
      0xA0,    /*  [* * ]  */
      0x40,    /*  [ *  ]  */
      0x40,    /*  [ *  ]  */
      0x00,    /*  [    ]  */
     
      /* 'w' charwidth: 6 */
      0x00,    /*  [      ]  */
      0x00,    /*  [      ]  */
      0xA8,    /*  [* * * ]  */
      0xA8,    /*  [* * * ]  */
      0x50,    /*  [ * *  ]  */
      0x50,    /*  [ * *  ]  */
      0x00,    /*  [      ]  */
     
      /* 'x' charwidth: 4 */
      0x00,    /*  [    ]  */
      0x00,    /*  [    ]  */
      0xA0,    /*  [* * ]  */
      0x40,    /*  [ *  ]  */
      0x40,    /*  [ *  ]  */
      0xA0,    /*  [* * ]  */
      0x00,    /*  [    ]  */
     
      /* 'y' charwidth: 4 */
      0x00,    /*  [    ]  */
      0x00,    /*  [    ]  */
      0xA0,    /*  [* * ]  */
      0xA0,    /*  [* * ]  */
      0x40,    /*  [ *  ]  */
      0x80,    /*  [*   ]  */
      0x80,    /*  [*   ]  */
     
      /* 'z' charwidth: 4 */
      0x00,    /*  [    ]  */
      0x00,    /*  [    ]  */
      0xE0,    /*  [*** ]  */
      0x40,    /*  [ *  ]  */
      0x80,    /*  [*   ]  */
      0xE0,    /*  [*** ]  */
      0x00,    /*  [    ]  */
     
      /* '{' charwidth: 4 */
      0x20,    /*  [  * ]  */
      0x40,    /*  [ *  ]  */
      0x40,    /*  [ *  ]  */
      0x80,    /*  [*   ]  */
      0x40,    /*  [ *  ]  */
      0x40,    /*  [ *  ]  */
      0x20,    /*  [  * ]  */
     
      /* '|' charwidth: 2 */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x80,    /*  [* ]  */
      0x00,    /*  [  ]  */
     
      /* '}' charwidth: 4 */
      0x80,    /*  [*   ]  */
      0x40,    /*  [ *  ]  */
      0x40,    /*  [ *  ]  */
      0x20,    /*  [  * ]  */
      0x40,    /*  [ *  ]  */
      0x40,    /*  [ *  ]  */
      0x80,    /*  [*   ]  */
     
      /* '~' charwidth: 7 */
      0x00,    /*  [       ]  */
      0x64,    /*  [ **  * ]  */
      0x98,    /*  [*  **  ]  */
      0x00,    /*  [       ]  */
      0x00,    /*  [       ]  */
      0x00,    /*  [       ]  */
      0x00    /*  [       ]  */
};

const uint8_t  five_dot_width_table[] = {
       2, /* ' ' */
       2, /* '!' */
       4, /* '"' */
       8, /* '#' */
       4, /* '$' */
       8, /* '%' */
       6, /* '&' */
       2, /* ''' */
       3, /* '(' */
       3, /* ')' */
       6, /* '*' */
       6, /* '+' */
       3, /* ',' */
       4, /* '-' */
       2, /* '.' */
       4, /* '/' */
       5, /* '0' */
       3, /* '1' */
       5, /* '2' */
       5, /* '3' */
       5, /* '4' */
       4, /* '5' */
       5, /* '6' */
       4, /* '7' */
       5, /* '8' */
       5, /* '9' */
       2, /* ':' */
       3, /* ';' */
       4, /* '<' */
       5, /* '=' */
       4, /* '>' */
       4, /* '?' */
       8, /* '@' */
       6, /* 'A' */
       5, /* 'B' */
       5, /* 'C' */
       5, /* 'D' */
       4, /* 'E' */
       4, /* 'F' */
       5, /* 'G' */
       5, /* 'H' */
       2, /* 'I' */
       5, /* 'J' */
       5, /* 'K' */
       4, /* 'L' */
       6, /* 'M' */
       6, /* 'N' */
       5, /* 'O' */
       5, /* 'P' */
       5, /* 'Q' */
       5, /* 'R' */
       4, /* 'S' */
       4, /* 'T' */
       5, /* 'U' */
       6, /* 'V' */
       8, /* 'W' */
       6, /* 'X' */
       6, /* 'Y' */
       4, /* 'Z' */
       3, /* '[' */
       4, /* '\' */
       3, /* ']' */
       6, /* '^' */
       6, /* '_' */
       3, /* '`' */
       5, /* 'a' */
       5, /* 'b' */
       4, /* 'c' */
       5, /* 'd' */
       4, /* 'e' */
       4, /* 'f' */
       5, /* 'g' */
       5, /* 'h' */
       2, /* 'i' */
       3, /* 'j' */
       5, /* 'k' */
       2, /* 'l' */
       6, /* 'm' */
       5, /* 'n' */
       5, /* 'o' */
       5, /* 'p' */
       5, /* 'q' */
       4, /* 'r' */
       4, /* 's' */
       3, /* 't' */
       5, /* 'u' */
       4, /* 'v' */
       6, /* 'w' */
       4, /* 'x' */
       4, /* 'y' */
       4, /* 'z' */
       4, /* '{' */
       2, /* '|' */
       4, /* '}' */
       7 /* '~' */
};
#endif

struct FONT_DEF
{
   uint8_t store_width;            /* glyph storage width in bytes */
   uint8_t glyph_height;         /* glyph height for storage */
   uint8_t fixed_width;            /* fixed width of glyphs. If zero */
                                         /* then use the width table. */
   uint8_t glyph_beg;              /* start ascii offset in table */
   uint8_t glyph_end;             /* end ascii offset in table */
   uint8_t glyph_def;             /*  for undefined glyph  */
}fonts={
     1,  7, 0, ' ','~','.'
};

uint8_t glcd_Buffer[GLCD_Y_BYTES][GLCD_X_BYTES];

const uint8_t glcd_MaskArray[8] =
         {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};

/////////////////////////////////////////////////////////////////////////
// Function Prototypes
/////////////////////////////////////////////////////////////////////////
void glcd_init(int1 mode);
void glcd_pixel(int8 x, int8 y, int1 color);
void glcd_fillScreen(int1 color);
void glcd_writeByte(int1 side, BYTE data);
BYTE glcd_readByte(int1 side);
void glcd_update();
void glcd_Glyph(uint8_t left, uint8_t top, uint8_t width, uint8_t height, uint16_t *glyph, uint8_t store_width);
void glcd_Text(uint8_t left, uint8_t top, char *str);
/////////////////////////////////////////////////////////////////////////

#ifdef FAST_GLCD
struct
{
   int8 left[512];
   int8 right[512];
} displayData;
#endif


// Purpose:       Initialize the LCD.
//                Call before using any other LCD function.
// Inputs:        OFF - Turns the LCD off
//                ON  - Turns the LCD on
void glcd_init(int1 mode)
{
   // Initialze some pins
   output_high(GLCD_RST);
   output_low(GLCD_E);
   output_low(GLCD_CS1);
   output_low(GLCD_CS2);

   output_low(GLCD_DI);                 // Set for instruction
   glcd_writeByte(GLCD_LEFT,  0xC0);    // Specify first RAM line at the top
   glcd_writeByte(GLCD_RIGHT, 0xC0);    //   of the screen
   glcd_writeByte(GLCD_LEFT,  0x40);    // Set the column address to 0
   glcd_writeByte(GLCD_RIGHT, 0x40);
   glcd_writeByte(GLCD_LEFT,  0xB8);    // Set the page address to 0
   glcd_writeByte(GLCD_RIGHT, 0xB8);

   if(mode == ON)
   {
      glcd_writeByte(GLCD_LEFT,  0x3F); // Turn the display on
      glcd_writeByte(GLCD_RIGHT, 0x3F);
   }
   else
   {
      glcd_writeByte(GLCD_LEFT,  0x3E); // Turn the display off
      glcd_writeByte(GLCD_RIGHT, 0x3E);
   }

   glcd_fillScreen(OFF);                // Clear the display

   #ifdef FAST_GLCD
   glcd_update();
   #endif
}


// Purpose:    Update the LCD with data from the display arrays
#ifdef FAST_GLCD
void glcd_update()
{
   int8 i, j;
   int8 *p1, *p2;

   p1 = displayData.left;
   p2 = displayData.right;

   // Loop through the vertical pages
   for(i = 0; i < 8; ++i)
   {
      output_low(GLCD_DI);                      // Set for instruction
      glcd_writeByte(GLCD_LEFT, 0x40);          // Set horizontal address to 0
      glcd_writeByte(GLCD_RIGHT, 0x40);
      glcd_writeByte(GLCD_LEFT, i | 0xB8);      // Set page address
      glcd_writeByte(GLCD_RIGHT, i | 0xB8);
      output_high(GLCD_DI);                     // Set for data

      // Loop through the horizontal sections
      for(j = 0; j < 64; ++j)
      {
         glcd_writeByte(GLCD_LEFT, *p1++);      // Turn pixels on or off
         glcd_writeByte(GLCD_RIGHT, *p2++);     // Turn pixels on or off
      }
   }
}
#endif

void glcd_updateA()
{
   int8 i, j;
   int8 *p;

   p = glcd_Buffer;

   // Loop through the vertical pages
   for(i = 0; i < 8; ++i)
   {
      output_low(GLCD_DI);                      // Set for instruction
      glcd_writeByte(GLCD_LEFT, 0x40);          // Set horizontal address to 0
      glcd_writeByte(GLCD_RIGHT, 0x40);
      glcd_writeByte(GLCD_LEFT, i | 0xB8);      // Set page address
      glcd_writeByte(GLCD_RIGHT, i | 0xB8);
      output_high(GLCD_DI);                     // Set for data

      // Loop through the horizontal sections
      for(j = 0; j < 64; ++j)
      {
         glcd_writeByte(GLCD_LEFT, *p++);      // Turn pixels on or off
      }
   }
}
// Purpose:    Turn a pixel on a graphic LCD on or off
// Inputs:     1) x - the x coordinate of the pixel
//             2) y - the y coordinate of the pixel
//             3) color - ON or OFF
void glcd_pixel(int8 x, int8 y, int1 color)
#ifdef FAST_GLCD
{
   int8* p;
   int16 temp;
   temp =  y/8;
   temp *= 64;
   temp += x;

   if(x > 63)
   {
      p = displayData.right + temp - 64;
   }
   else
   {
      p = displayData.left + temp;
   }

   if(color)
   {
      bit_set(*p, y%8);
   }
   else
   {
      bit_clear(*p, y%8);
   }
}
#else
{
   BYTE data;
   int1 side = GLCD_LEFT;  // Stores which chip to use on the LCD

   if(x > 63)              // Check for first or second display area
   {
      x -= 64;
      side = GLCD_RIGHT;
   }

   output_low(GLCD_DI);                         // Set for instruction
   bit_clear(x,7);                              // Clear the MSB. Part of an instruction code
   bit_set(x,6);                                // Set bit 6. Also part of an instruction code
   glcd_writeByte(side, x);                     // Set the horizontal address
   glcd_writeByte(side, (y/8 & 0xBF) | 0xB8);   // Set the vertical page address
   output_high(GLCD_DI);                        // Set for data
   glcd_readByte(side);                         // Need two reads to get data
   data = glcd_readByte(side);                  //  at new address

   if(color == ON)
      bit_set(data, y%8);        // Turn the pixel on
   else                          // or
      bit_clear(data, y%8);      // turn the pixel off

   output_low(GLCD_DI);          // Set for instruction
   glcd_writeByte(side, x);      // Set the horizontal address
   output_high(GLCD_DI);         // Set for data
   glcd_writeByte(side, data);   // Write the pixel data
}
#endif


// Purpose:    Fill the LCD screen with the passed in color
// Inputs:     ON  - turn all the pixels on
//             OFF - turn all the pixels off
void glcd_fillScreen(int1 color)
#ifdef FAST_GLCD
{
   int8  data;
   int8  *p1, *p2;
   int16 i;

   p1 = displayData.left;
   p2 = displayData.right;
   data = 0xFF * color;

   for(i=0; i<512; ++i)
   {
      *p1++ = data;
      *p2++ = data;
   }
}
#else
{
   int8 i, j;

   // Loop through the vertical pages
   for(i = 0; i < 8; ++i)
   {
      output_low(GLCD_DI);                      // Set for instruction
      glcd_writeByte(GLCD_LEFT, 0b01000000);    // Set horizontal address to 0
      glcd_writeByte(GLCD_RIGHT, 0b01000000);
      glcd_writeByte(GLCD_LEFT, i | 0b10111000);// Set page address
      glcd_writeByte(GLCD_RIGHT, i | 0b10111000);
      output_high(GLCD_DI);                     // Set for data

      // Loop through the horizontal sections
      for(j = 0; j < 64; ++j)
      {
         glcd_writeByte(GLCD_LEFT, 0xFF*color);  // Turn pixels on or off
         glcd_writeByte(GLCD_RIGHT, 0xFF*color); // Turn pixels on or off
      }
   }
}
#endif


// Purpose:    Write a byte of data to the specified chip
// Inputs:     1) chipSelect - which chip to write the data to
//             2) data - the byte of data to write
void glcd_writeByte(int1 side, BYTE data)
{
   if(side)                   // Choose which side to write to
      output_high(GLCD_CS2);
   else
      output_high(GLCD_CS1);

   output_low(GLCD_RW);       // Set for writing
   output_d(data);            // Put the data on the port
   delay_cycles(1);
   output_high(GLCD_E);       // Pulse the enable pin
   delay_cycles(5);
   output_low(GLCD_E);

   output_low(GLCD_CS1);      // Reset the chip select lines
   output_low(GLCD_CS2);
}


// Purpose:    Reads a byte of data from the specified chip
// Ouputs:     A byte of data read from the chip
BYTE glcd_readByte(int1 side)
{
   BYTE data;                 // Stores the data read from the LCD

   set_tris_d(0xFF);          // Set port d to input
   output_high(GLCD_RW);      // Set for reading

   if(side)                   // Choose which side to write to
      output_high(GLCD_CS2);
   else
      output_high(GLCD_CS1);

   delay_cycles(1);
   output_high(GLCD_E);       // Pulse the enable pin
   delay_cycles(4);
   data = input_d();          // Get the data from the display's output register
   output_low(GLCD_E);

   output_low(GLCD_CS1);      // Reset the chip select lines
   output_low(GLCD_CS2);
   return data;               // Return the read data
}

#include "graphics.c"
void glcd_fillscrn(int8 side)
{
   int i,j;
    for(i = 0; i < 8; ++i)
   {
      output_low(GLCD_DI);                      // Set for instruction
      if(side == ON)
      {
         glcd_writeByte(GLCD_CS1, 0b01000000);     // Set horizontal address to 0
         glcd_writeByte(GLCD_CS1, i | 0b10111000); // Set page address
      }
      else
      {
         glcd_writeByte(GLCD_CS2, 0b01000000);
         glcd_writeByte(GLCD_CS2, i | 0b10111000);
      }
      output_high(GLCD_DI);                     // Set for data

      // Loop through the horizontal sections
      for(j = 0; j < 64; ++j)
      {
         if(side == ON)
         {
            glcd_writeByte(GLCD_CS1, 0x00);  // Turn pixels on or off
         }
         {
            glcd_writeByte(GLCD_CS2, 0x00);  // Turn pixels on or off
         }
      }
   }
}

/*
 Writes a glyph("letter") to the display at location x,y
 (adapted function from the MJK-code)
 Arguments are:
    column    - x corrdinate of the left part of glyph         
    row       - y coordinate of the top part of glyph       
    width       - size in pixels of the width of the glyph   
    height      - size in pixels of the height of the glyph   
    glyph     - an unsigned char pointer to the glyph pixels
                to write assumed to be of length "width"
*/

void glcd_Glyph(uint8_t left, uint8_t top,
            uint8_t width, uint8_t height,
            uint16_t *glyph, uint8_t store_width)
{
   uint8_t bit_pos;
   uint8_t byte_offset;
   uint8_t y_bits;
   uint8_t remaining_bits;
   uint8_t mask;
   uint8_t char_mask;
   uint8_t x,z;
   uint16_t *glyph_scan;
   uint8_t glyph_offset;
   
   char tt[16];
   int i, j;
   bit_pos = top & 0x07;      /* get the bit offset into a byte */

   glyph_offset = 0;         /* start at left side of the glyph rasters */
    char_mask = 0x80;         /* initial character glyph mask */
 
     for (x = left; x < (left + width); x++)
     {
         byte_offset = top >> 3;           /* get the byte offset into y direction */
         y_bits = height;            /* get length in y direction to write */
         remaining_bits = 8 - bit_pos;   /* number of bits left in byte */
         mask = glcd_MaskArray[bit_pos];   /* get mask for this bit */
         glyph_scan = glyph + glyph_offset;    /* point to base of the glyph */
 
       /* boundary checking here to account for the possibility of  */
       /* write past the bottom of the screen.                        */
       while((y_bits) && (byte_offset < GLCD_Y_BYTES)) /* while there are bits still to write */
       {
         /* check if the character pixel is set or not */
 
         if(*glyph_scan & char_mask)
         {
            glcd_Buffer[byte_offset][x] |= mask;   /* set image pixel */
            //glcd_writeByte(GLCD_CS1,glcd_Buffer[byte_offset][x]);
         }
         else
         {
             glcd_Buffer[byte_offset][x] &= ~mask;   /* clear the image pixel */
            //glcd_writeByte(GLCD_CS1,glcd_Buffer[byte_offset][x]);
         }
         
         if(glcd_MaskArray[0] & 0x80)
         {
            mask >>= 1;
         }
         else
         {
            mask <<= 1;
         }
         
         y_bits--;
         remaining_bits--;
         if(remaining_bits == 0)
         {
            /* just crossed over a byte boundry, reset byte counts */
            remaining_bits = 8;
            byte_offset++;
            mask = glcd_MaskArray[0];
         }

         /* bump the glyph scan to next raster */
         glyph_scan += store_width;
      }
     
      /* shift over to next glyph bit */
 
      char_mask >>= 1;
      if(char_mask == 0)            /* reset for next byte in raster */
      {
         char_mask = 0x80;
         glyph_offset++;
      }
 }
}

/*
 Prints the given string at location x,y in the specified font.
 Prints each character given via calls to lcd_glyph. The entry string
 is null terminated and non 0x20->0x7e characters are ignored.
 (adapted function from the MJK-code)
 Arguments are:                                                   
   left       coordinate of left start of string.               
   top        coordinate of top of string.
   font       font number to use for display (see fonts.h)
   str         text string to display (null-terminted)
*/

void glcd_Text(uint8_t left, uint8_t top, char *str)
{
   uint8_t x;
   uint8_t glyph;
   uint8_t width;
   uint8_t height;
   uint8_t store_width;
   uint16_t *glyph_ptr;
   uint8_t *ptr;
   
   char tt[10];
   int16 i;
   x=left;

     while(*str != 0x00)
     {
        glyph = (uint8_t)*str;

      /* check to make sure the symbol is a legal one */
      /* if not then just replace it with the default character */
      if((glyph < fonts.glyph_beg) || (glyph > fonts.glyph_end))
      {
         glyph = fonts.glyph_def;
      }

       // make zero based index into the font data arrays
       glyph -= fonts.glyph_beg;
       width = fonts.fixed_width;   /* check if it is a fixed width */
 
      if(width == 0)
      {
         width=five_dot_width_table[glyph];/* get the variable width instead */
      }
      height = fonts.glyph_height;
      store_width = fonts.store_width;
      ptr = five_dot_glyph_table;

      glyph_ptr = (ptr + (uint16_t)glyph * (uint16_t)store_width * (uint16_t)height);
      i = *(glyph_ptr+1);
      itoa(i,10,tt);
      glcd_text57(75,10,tt,1,ON);
      delay_ms(200);
      /* range check / limit things here */
      if(x > GLCD_RIGHTA)
      {
         x = GLCD_RIGHTA;
      }
      if((x + width) > GLCD_RIGHTA+1)
      {
         width = GLCD_RIGHTA - x + 1;
      }
      if(top > GLCD_BOTTOM)
      {
         top = GLCD_BOTTOM;
      }
      if((top + height) > GLCD_BOTTOM+1)
      {
         height = GLCD_BOTTOM - top + 1;
      }

       glcd_Glyph(x,top,width,height,glyph_ptr,store_width);  /* plug symbol into buffer */

      x += width;                     /* move right for next character */
      str++;                        /* point to next character in string */
   }
}

#endif
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