128x64 Pixels Graphical Monochrom LCD Display with KS0108

2013-10-16
2013-10-17
  • The last few weeks working on a graphic display 128x64 with KS0108. The Hugh has written a very good library (glcd.h).
    This display has two KS0108 (and KS0107) chips that control the two halves of the screen.
    The only change I made in library is to change the way I activated the two chips. Specifically, in the library two chips activated with <<1>> while my display need <<0>>
    Set GLCD_CS1 Off
    Set GLCD_CS2 Off
    Yet reached the tables with Greek characters ASCII 128-254 and wrote three additional subroutines to be able to write large (16x16) characters and symbols. These subroutines are:

    Sub GLCDBigPrint(In PrintLocX, In PrintLocY, PrintData As String)
    Sub GLCDDrawBigChar (In CharLocX, In CharLocY, In CharCode)
    Sub GLCDDrawBigSymbol (In CharLocX, In CharLocY, In CharCode)

    The results are shown in the video: http://www.youtube.com/watch?v=iWcuWUNAn9w&feature=youtu.be

    The modified library shown below
    https://docs.google.com/file/d/0B2_M89qREbBgcjVqSUZWUGV4V28/edit?
    usp=sharing
    Ιn http://www.henningkarlsen.com/electronics/r_fonts.php you can find other character sets.

    My test program:

    'Chip Settings
    #chip 18F2550, 8
    #config FOSC_INTOSC_HS, WDT=OFF, LVP=OFF, BOR=OFF, MCLRE=OFF

    'Include
    #include "glcd.h"

    'Defines
    #define GLCD_DB0 PORTB.0
    #define GLCD_DB1 PORTB.1
    #define GLCD_DB2 PORTB.2
    #define GLCD_DB3 PORTB.3
    #define GLCD_DB4 PORTB.4
    #define GLCD_DB5 PORTB.5
    #define GLCD_DB6 PORTC.6
    #define GLCD_DB7 PORTC.7
    #define GLCD_CS1 PORTA.0
    #define GLCD_CS2 PORTA.1
    #define GLCD_RESET PORTC.2
    #define GLCD_RS PORTA.2
    #define GLCD_RW PORTA.3
    #define GLCD_ENABLE PORTA.5

    'Variables
    dim ab as String
    dim greek as String

    dir PORTB Out
    dir PORTA Out
    dir PORTC out

    call InitGLCD
    Start:
    Call GLCDPrint 1 , 2 , "English Characters"
    call GLCDPrint 1 , 13 , "ABCDEFGHIJKLMNOPQ"
    call GLCDPrint 1 , 23 , "RSTUVWXYZ"
    Call GLCDPrint 1 , 33 , "abcdefghijklmnopq"
    call GLCDPrint 1 , 43 , "rstuvwxyz123456789"
    call GLCDPrint 1 , 53 , "0!@#$%^&()+<>?/"
    call Box 0 , 0 , 127 , 63
    wait 15 s
    Call GLCDCLS
    Call GLCDPrint 1 , 2 , "Greek Characters"
    Call GLCDPrint 1 , 13, "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠ"
    Call GLCDPrint 1, 23 , "ΡΣΤΥΦΧΨΩ"
    call GLCDPrint 1, 33 , "αβγδεζηθικλμνξοπρ"
    CALL GLCDPrint 1, 43 , "σςτυφχψωάέήίόώύϊϋ"
    call Box 0 , 0 , 127 , 63
    wait 15 s
    call GLCDCLS
    Call GLCDBigPrint 3 , 10, "Print Big"
    Call GLCDBigPrint 1 , 30, "Character"
    wait 15 s
    Call GLCDCLS
    Call GLCDBigPrint 1 , 1 , "ABCDEFGHI"
    Call GLCDBigPrint 1 , 15 , "JKLMNOPQR"
    Call GLCDBigPrint 1 , 30 , "STUVWXYZ"
    call Box 0 , 0 , 127 , 63
    wait 25 s
    Call GLCDCLS
    Call GLCDBigPrint 1 , 1 , "abcdefgh"
    Call GLCDBigPrint 1 , 15 , "ijklmnop"
    call GLCDBigPrint 1 , 30 , "qrstuvwx"
    call GLCDBigPrint 1 , 45 , "yz"
    call Box 0 , 0 , 127 , 63
    wait 25 s
    Call GLCDCLS
    call GLCDBigPrint 1 , 1 , "012345678"
    Call GLCDBigPrint 1 , 15 , "9`~^[]{},"
    Call GLCDBigPrint 1 , 30 , "<>?+=-
    '"
    Call GLCDBigPrint 1 , 45 , "!@#$%&()"
    call Box 0 , 0 , 127 , 63
    wait 25 s
    Call GLCDCLS
    Call GLCDBigPrint 30 , 10, "Print"
    Call GLCDBigPrint 20 , 30, "Symbols"
    wait 15 s
    Call GLCDCLS
    sym=0
    col=1
    for i=1 to 9
    sym +=1
    Call GLCDDrawBigSymbol col , 1 , sym
    col = col+14
    next i
    col=1
    for i=1 to 9
    sym +=1
    Call GLCDDrawBigSymbol col , 15 , sym
    col = col+14
    next i
    col=1
    for i=1 to 9
    sym +=1
    Call GLCDDrawBigSymbol col , 30 , sym
    col = col+14
    next i
    col=1
    for i=1 to 9
    sym +=1
    Call GLCDDrawBigSymbol col , 45 , sym
    col=col+14
    next i
    wait 25 s
    Call GLCDCLS
    goto Start

     
    Last edit: Dimitris Katsaounis 2013-10-16
    • I also found a CS1 and CS2 issue but for me they were just backward.
      I had to define the CS2 connection in software as connected to the CS1 connection on the PIC and the CS1 connection in software as connected to the CS2 line on the PIC.

      define GLCD_CS1 PORTB.3 'CS2 connection since CS1, CS2 are backward
      define GLCD_CS2 PORTB.4 'CS1 connection since CS1, CS2 are backward

      Schematic and code sample are at the link below.

      http://www.greatcowbasic.com/sample-projects.html

      I look forward to trying out your library. Its looks great.
      The GLCD is another great but undocumented feature in GCB.
      I tried to include some detail in my GCB manual:

      http://www.greatcowbasic.com/uploads/9/2/9/8/9298268/gcb_chipino_user_manual_v1.0_-_sample.pdf

       
  • Anobium
    Anobium
    2013-10-17

    Nice job. Thank you for sharing.