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 = 6000000 ' used crystal frequency
|
12 | $baud = 9600 ' 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 |
|
18 | 'some routines to control the display are in the glcdKS108.lib file
|
19 | $lib "glcdKS108.lbX"
|
20 |
|
21 |
|
22 | Wait 2
|
23 |
|
24 | Print "Config" ' printing will still work as only the receiver pin is disabled
|
25 |
|
26 |
|
27 | 'First we define that we use a graphic LCD
|
28 | Config Graphlcd = 128 * 64sed , Dataport = Porta , Controlport = Portc , Ce = 0 , Ce2 = 1 , Cd = 4 , Rd = 3 , Reset = 2 , Enable = 5
|
29 |
|
30 | 'The dataport is the portname that is connected to the data lines of the LCD
|
31 | 'The controlport is the portname which pins are used to control the lcd
|
32 | 'CE =CS1 Chip select
|
33 | 'CE2=CS2 Chip select second chip
|
34 | 'CD=Data/instruction
|
35 | 'RD=Read
|
36 | 'RESET = reset
|
37 | 'ENABLE= Chip Enable
|
38 |
|
39 |
|
40 |
|
41 | 'Dim variables (y not used)
|
42 | Dim X As Byte , Y As Byte
|
43 |
|
44 | $include "font8x8.font"
|
45 |
|
46 | Print "Cls"
|
47 | Cls
|
48 |
|
49 | Wait 1
|
50 |
|
51 | 'specify the font we want to use
|
52 | Setfont Font8x8
|
53 |
|
54 |
|
55 | 'You can use locate but the columns have a range from 1-128
|
56 | 'When you want to show somthing on the LCD, use the LDAT command
|
57 | 'LCDAT Y , COL, value
|
58 | Lcdat 1 , 1 , "123"
|
59 |
|
60 | 'lcdat accepts an additional param for inversing the text
|
61 | Lcdat 2 , 1 , "123" , 1 ' will inverse the text
|
62 |
|
63 | 'Now use a different font
|
64 | 'Setfont Font8x8
|
65 | 'since the 16*16 font uses 2 rows, show on row 3
|
66 | 'Lcdat 1 , 1 , "2345"
|
67 | 'Lcdat 2 , 56 , "2345656"
|
68 | Wait 1
|
69 | Line(0 , 0) -(127 , 64) , 1 'make line
|
70 | Wait 2
|
71 | Line(0 , 0) -(127 , 64) , 0 'remove line
|
72 |
|
73 | For Y = 1 To 20
|
74 | Circle(30 , 30) , Y , 1
|
75 | Waitms 100
|
76 | Next
|
77 |
|
78 | Wait 1
|
79 | Glcdcmd &H3E , 1 : Glcdcmd &H3E , 2 ' both displays off
|
80 | Wait 1
|
81 | Glcdcmd &H3F , 1 : Glcdcmd &H3F , 2 'both on
|
82 | 'GLCDCMD accepts an additional param to select the chip
|
83 | 'With multiple, GLCDCMD statements, it is best to specify the chip only the first time
|
84 | 'show a comnpressed picture
|
85 | End 'end program
|
86 |
|
87 |
|
88 | 'we need to include the font files
|
89 | 'Notice that this is a testfont with only numbers defined !
|
90 | '$include "smallfont8x8.font"
|
91 |
|
92 | '$include "font16x16.font"
|