GLCD in Text Mode - PIC Development Board + PIC16F877A

Post Reply
Anobium
Posts: 20
Joined: Fri Aug 01, 2014 9:17 am

GLCD in Text Mode - PIC Development Board + PIC16F877A

Post by Anobium » Sat Aug 16, 2014 10:19 am

The ST7920 GLCD driver operates in two modes, text and graphics. This demo shows you how to use the text mode.

Essentially, it uses the LCD driver with a small GLCD handler.

Code: Select all

'  FILE:    PIC_GCB_16F877a_GCD_TextMode_Example.gcb
'  DATE:    07/08/14
'  VERSION: 0.1
'  AUTHOR:  Anobium
'
'This program was written using the Great Cow Basic IDE for use with the PIC
'16F8777A development board (HCDVBD0003) and the GLCD module
'(HCMODU0032) to display some example text.


'Chip Settings. Assumes the development board with with a 16F877a at 4 or 20 Mhz
#chip 16F877a,20

'Uses GLCD in 4 pin mode and define LCD pins
 #define LCD_IO 4
 #define LCD_RW PORTE.1
 #define LCD_RS PORTE.0
 #define LCD_Enable PORTE.2
 #define LCD_DB4 PORTD.4
 #define LCD_DB5 PORTD.5
 #define LCD_DB6 PORTD.6
 #define LCD_DB7 PORTD.7
 #define LCD_SPEED FAST

 dim outstring as string * 16
'Main program

   'Clear the LCD
   CLS
   'Display some text on both lines
   Locate 0,0
   Print "HOBBY COMPONENTS"
   wait 1 s
   CLS
   print ChipNameStr +" @ "+str(ChipMhz) + "Mhz"
   Locate 1,0
   print "by Anobium"

cls
for yy = 0 to 3
    for xx = 0 to 7

        Locate xx,yy
        outstring = str(xx)
        outstring = outstring + str(yy)
        print outstring
        wait 100 ms
    next
next


end


#define locate ST7920Locate
Sub ST7920Locate( In PrintLocX , In PrintLocY )

' DESCRIPTIONS:
' Place a character to the GLCD controller on the specified row and column.
' Due to the design of the ST7920 controller (to accomodate Mandarin and Cyrillic), you must place the text on the column
' according to the numbers above the diagram below:
'
' |--0--|--1--|--2--|...	...|--7--|
' +--+--+--+--+--+---------------------+
' |H |e |l |l |o |  ...                | <- row 0 (address 0x80)
' +--+--+--+--+--+---------------------+
' |T |h |i |s |  |i ...				   | <- row 1 (address 0x90)
' +--+--+--+--+--+---------------------+
' |' |' |' |' |' |' ...				   | <- row 2 (address 0x88)
' +--+--+--+--+--+---------------------+
' |- |- |- |- |- |- ...				   | <- row 3 (address 0x98)
' +--+--+--+--+--+---------------------+
'
' Example:
' Writing 'a' onto the 1st column, and 1st row:
' |--0--|--1--|--2--|...	  ...|--7--|
' +--+--+--+--+--+---------------------+
' |  |  |  |  |  |  ...                | <- row 0 (address 0x80)
' +--+--+--+--+--+---------------------+
' |  |  |a |  |  |  ...				   | <- row 1 (address 0x90)
' +--+--+--+--+--+---------------------+
' |  |  |  |  |  |  ...				   | <- row 2 (address 0x88)
' +--+--+--+--+--+---------------------+
' |  |  |  |  |  |  ...				   | <- row 3 (address 0x98)
' +--+--+--+--+--+---------------------+



	select case  PrintLocY
               case 0
                    col = PrintLocX OR 0x80

               case 1
                    col = PrintLocX OR 0x90

               case 2
                    col = PrintLocX OR 0x88

               case 3
                    col = PrintLocX OR 0x98

               case else
                    col = PrintLocX OR 0x80
            end select
            SET LCD_RS OFF
            LCDWriteByte ( col)

end sub


You do not have the required permissions to view the files attached to this post.

Post Reply