1  | '-----------------------------------------------------------------------------------------
  | 
2  | 'name                     : ks108.bas
  | 
3  | 'copyright                : (c) 1995-2005, MCS Electronics
  | 
4  | 'purpose                  : demonstrates the KS108 based graphical display support
  | 
5  | 'micro                    : Mega323
  | 
6  | 'suited for demo          : no
  | 
7  | 'commercial addon needed  : no
  | 
8  | '-----------------------------------------------------------------------------------------
  | 
9  | 
  | 
10  | $regfile = "m32def.dat"                                     ' specify the used micro
  | 
11  | $crystal = 8000000                                          ' used crystal frequency
  | 
12  | $baud = 19200                                               ' use baud rate
  | 
13  | $hwstack = 32                                               ' default use 32 for the hardware stack
  | 
14  | $swstack = 10                                               ' default use 10 for the SW stack
  | 
15  | $framesize = 40                                             ' default use 40 for the frame space
  | 
16  | 
  | 
17  | Ddra = $b11111111
  | 
18  | Porta = $b11111111
  | 
19  | 
  | 
20  | Ddrc = $b11111111
  | 
21  | Portc = $b11111111
  | 
22  | 
  | 
23  | 'some routines to control the display are in the glcdKS108.lib file
  | 
24  | $lib "glcdKS108.lbx"
  | 
25  | Wait 2
  | 
26  | Print "Config"
  | 
27  | 
  | 
28  | 'First we define that we use a graphic LCD
  | 
29  | Config Graphlcd = 128 * 64sed , Dataport = Porta , Controlport = Portc , Ce = 0 , Ce2 = 1 , Cd = 2 , Rd = 3 , Reset = 5 , Enable = 4
  | 
30  | 
  | 
31  | 'The dataport is the portname that is connected to the data lines of the LCD
  | 
32  | 'The controlport is the portname which pins are used to control the lcd
  | 
33  | 'CE =CS1  Chip select
  | 
34  | 'CE2=CS2  Chip select second chip
  | 
35  | 'CD=Data/instruction
  | 
36  | 'RD=Read
  | 
37  | 'RESET = reset
  | 
38  | 'ENABLE= Chip Enable
  | 
39  | Cls
  | 
40  | Wait 1
  | 
41  | 
  | 
42  | 'Dim variables (y not used)
  | 
43  | Dim X As Byte , Y As Byte
  | 
44  | 
  | 
45  | 'specify the font we want to use
  | 
46  | Setfont Font8x8
  | 
47  | 
  | 
48  | 
  | 
49  | 'You can use locate but the columns have a range from 1-128
  | 
50  | 'When you want to show somthing on the LCD, use the LDAT command
  | 
51  | 'LCDAT Y , COL, value
  | 
52  | Lcdat 1 , 1 , "123"
  | 
53  | 
  | 
54  | 'lcdat accepts an additional param for inversing the text
  | 
55  | Lcdat 2 , 1 , "123" , 1                                     ' will inverse the text
  | 
56  | 
  | 
57  | 'Now use a different font
  | 
58  | 'Setfont Font8x8
  | 
59  | 'since the 16*16 font uses 2 rows, show on row 3
  | 
60  | 'Lcdat 1 , 1 , "2345"
  | 
61  | 'Lcdat 2 , 56 , "2345656"
  | 
62  | Wait 1
  | 
63  | Line(0 , 0) -(127 , 64) , 1                                 'make line
  | 
64  | Wait 2
  | 
65  | Line(0 , 0) -(127 , 64) , 0                                 'remove line
  | 
66  | 
  | 
67  | For Y = 1 To 20
  | 
68  |    Circle(30 , 30) , Y , 1
  | 
69  |    Waitms 100
  | 
70  | Next
  | 
71  | 
  | 
72  | Wait 1
  | 
73  | Glcdcmd &H3E , 1 : Glcdcmd &H3E , 2                         ' both displays off
  | 
74  | Wait 1
  | 
75  | Glcdcmd &H3F , 1 : Glcdcmd &H3F , 2                         'both on
  | 
76  | 'GLCDCMD accepts an additional param to select the chip
  | 
77  | 'With multiple, GLCDCMD statements, it is best to specify the chip only the first time
  | 
78  | 
  | 
79  | 
  | 
80  | Showpic 0 , 0 , Plaatje                                     'show a comnpressed picture
  | 
81  | End                                                         'end program
  | 
82  | 
  | 
83  | 
  | 
84  | 'we need to include the font files
  | 
85  | 'Notice that this is a testfont with only numbers defined !
  | 
86  | '$include "smallfont8x8.font"
  | 
87  | $include "font8x8.font"
  | 
88  | '$include "font16x16.font"
  | 
89  | 
  | 
90  | 
  | 
91  | Plaatje:
  | 
92  | 'include the picture data
  | 
93  | $bgf "ks108.bgf"
  |