Odpowiedz 
 
Ocena wątku:
  • 0 Głosów - 0 Średnio
  • 1
  • 2
  • 3
  • 4
  • 5
Bascom AVR
SQ2EER Offline
Jacek sk
***

Liczba postów: 182
Dołączył: 17-06-2009
Post: #41
RE: Bascom AVR
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:

İmage

czy może ktoś podpowiedzieć co robię źle - pozdrawiam Jacek.
04-09-2011 22:04
Znajdź wszystkie posty użytkownika Odpowiedz cytując ten post
Odpowiedz 


Wiadomości w tym wątku
Bascom AVR - SP5FCS - 15-08-2010, 22:43
RE: Bascom AVR - SP3SWJ - 06-10-2010, 21:56
RE: Bascom AVR - SQ2EER - 25-10-2010, 21:07
RE: Bascom AVR - SP3SWJ - 25-10-2010, 21:17
RE: Bascom AVR - SQ2EER - 25-10-2010, 21:23
RE: Bascom AVR - SP3SWJ - 25-10-2010, 21:35
RE: Bascom AVR - SQ2EER - 25-10-2010, 21:39
RE: Bascom AVR - SP3SWJ - 25-10-2010, 22:05
RE: Bascom AVR - SQ2EER - 25-10-2010, 22:28
RE: Bascom AVR - SP3SWJ - 27-10-2010, 1:49
RE: Bascom AVR - SQ2EER - 18-03-2011, 21:39
RE: Bascom AVR - SP3SWJ - 18-03-2011, 22:02
RE: Bascom AVR - SQ2EER - 18-03-2011, 22:22
RE: Bascom AVR - SQ9MDD - 18-03-2011, 22:31
RE: Bascom AVR - SQ2EER - 18-03-2011, 23:03
RE: Bascom AVR - SP3SWJ - 18-03-2011, 23:05
RE: Bascom AVR - SQ2EER - 18-03-2011, 23:15
RE: Bascom AVR - SQ2EER - 04-09-2011 22:04
RE: Bascom AVR - SP3SWJ - 04-09-2011, 22:09
RE: Bascom AVR - SQ2EER - 04-09-2011, 22:22
RE: Bascom AVR - SP3SWJ - 04-09-2011, 22:36
RE: Bascom AVR - SQ9MDD - 06-05-2012, 16:10
RE: Bascom AVR - SP3SWJ - 06-05-2012, 16:10
RE: Bascom AVR - SQ9MDD - 06-05-2012, 16:21
RE: Bascom AVR - SP3SWJ - 06-05-2012, 16:34
RE: Bascom AVR - SQ9MDD - 06-05-2012, 16:41
RE: Bascom AVR - SP3SWJ - 06-05-2012, 16:41

Skocz do:


Użytkownicy przeglądający ten wątek: 1 gości