Witam - w ramach zabawy z graficznym lcd 128x64 opartym o sterownik KS108 ( z MAX'a 6 ) napisałem taki programik:
Kod:
'-----------------------------------------------------------------------------------------
'name : ks108.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : demonstrates the KS108 based graphical display support
'micro : Mega323
'suited for demo : no
'commercial addon needed : no
'-----------------------------------------------------------------------------------------
$regfile = "m644pdef.dat" ' specify the used micro
$crystal = 16000000 ' used crystal frequency
$baud = 19200 ' use baud rate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
'$sim
'some routines to control the display are in the glcdKS108.lib file
$lib "glcdKS108.lbx"
Waitms 200
'Print "Test program by SP3SWJ for KS0108 LCD" ' printing will still work as only the receiver pin is disabled
'First we define that we use a graphic LCD
Config Graphlcd = 128 * 64sed , Dataport = Portb , Controlport = Portc , Ce = 7 , Ce2 = 6 , Cd = 3 , Rd = 4 , Reset = 5 , Enable = 2
Config Pind.6 = Input : Set Pind.6
Config Pind.7 = Input : Set Pind.7
S1 Alias Pind.6
S2 Alias Pind.7
Dim A As Word
Dim B As Word
'The dataport is the portname that is connected to the data lines of the LCD
'The controlport is the portname which pins are used to control the lcd
'CE =CS1 Chip select
'CE2=CS2 Chip select second chip
'CD=Data/instruction
'RD=Read
'RESET = reset
'ENABLE= Chip Enable
'When you want to show somthing on the LCD, use the LCDAT command
'LCDAT LINES , COLUMN, VALIUE , COLOR
'You can use locate but the
'COMULNS have a range from 1-128 pixels
'LINES number of lines
'1 2 3 4 5 6 7 8 for 8x8 font
'1,3,5,7 for 16x16 lines 2 4 6 is shifted 8 not allowed
'VALUE displayed value
'not longer than 16 chars for 8x8
'not longer than 8 for 16x16
'last char Is Rollover Half Screen - line can not be to longer
'COLOR 1 will inverse the text 0 = normal
Wait 1
Cls
Setfont Font16x16
B = 16
A = 0
Do
Lcdat 7 , 1 , A ; " "
If S1 = 0 Then
Waitms 100
If S1 = 0 Then
Incr A
If A > 361 Then
A = 360
End If
End If
End If
If S2 = 0 Then
Waitms 100
If S2 = 0 Then
Decr A
If A < 0 Or A > 361 Then
A = 0
End If
End If
End If
Line(23 , 17) -(23 , 30) , 1
If A > 9 Then
B = B - 8
Elseif A > 99 Then
B = B - 8
Else
B = 16
End If
Lcdat 1 , B , A
Loop
'we need to include the font files
$include "font16x16.font"
Po przekroczeniu zmiennej A wartości 9 efekt jest taki jak na foto:
czy może ktoś podpowiedzieć co robię źle - pozdrawiam Jacek.