Pages

Selasa, 17 Juni 2014

Animasi Dot matrix 24 x 24

Rangkaian Animasi Dot Matrik 24 x 24


Listing Kodenya : dng Bascom AVR
$regfile = "m32def.dat"
$crystal = 8000000
$hwstack = 32
$swstack = 32
$framesize = 24

'bagian properti GIF
Const Total_frame = 3
Const Width = 24
Const Height = 24


Const Number_of_matrix_in_row = Width / 8
Const Byte_in_col = Height / 8
Const Frame_size = Width * Byte_in_col
Const Number_of_byte_in_8_col = Byte_in_col * 8

Declare Sub Readframe(byval Frame_number As Word)
' Port A for COL refresh
Config Porta = Output
' Port D for 74595 register
Config Portd = Output
Config Timer0 = Timer , Prescale = 64                       'Clock value: 15.625 kHz
On Ovf0 Refresh
Enable Timer0                                               ' enable the timer interrupt
Enable Interrupts
Sh_cp Alias Portd.3
Ds Alias Portd.4
St_cp Alias Portd.5
Mr Alias Portd.6
Oe Alias Portd.7
Col_port Alias Porta
Dim Col As Byte
Dim Buf(frame_size) As Byte
Dim I As Byte
Dim Matrix_counter As Word
Dim Buf_idx As Word
Dim Col_number_in_buf As Byte
Dim Frame_count As Word

Reset Mr
Set Mr
Reset Oe
Do
For Frame_count = 1 To Total_frame
 Readframe Frame_count
 Waitms 200
Next Frame_count
Loop
End                                                         'end program

Sub Readframe(byval Frame_number As Word)
 Local Idx As Word
 Local Lookup_idx As Word
 Disable Timer0
 Decr Frame_number
 'Start of Frame in lookup table
 Lookup_idx = Frame_number * Frame_size
 For Idx = 0 To Frame_size
  Buf(idx) = Lookup(lookup_idx , Ani )
  Incr Lookup_idx
 Next Idx
 Enable Timer0
End Sub

Refresh:
 Reset Mr
 Set Mr
 Col_port = &H00
 Set Oe
 Col_port = 2 ^ Col
 For Matrix_counter = 1 To Number_of_matrix_in_row
  Col_number_in_buf = Number_of_matrix_in_row - Matrix_counter
  Col_number_in_buf = Col_number_in_buf * Number_of_byte_in_8_col
  Buf_idx = Col * Byte_in_col
  Buf_idx = Buf_idx + Col_number_in_buf
  For I = 1 To Byte_in_col
   Shiftout Ds , Sh_cp , Buf(buf_idx) , 1 , 8
   Incr Buf_idx
  Next I
 Next Matrix_counter
 Reset St_cp
Set St_cp
Reset Oe
If Col < 7 Then
 Incr Col
Else
 Col = 0
End If
Return

'Ini bagian properties tabel
Delay:
'Frame 1
Data 200%
'Frame 2
Data 100%
'Frame 3
Data 100%
'Frame 4
Data 100%
'Frame 5
Data 100%
'Frame 6
Data 100%
'Frame 7
Data 100%
'Frame 8
Data 100%

Ani:
Data &HFF , &HFF , &HFF                                     '########################
Data &HFF , &HFF , &HFF                                     '########################
Data &H33 , &H33 , &H33                                     '..##..##..##..##..##..##
Data &H33 , &H33 , &H33                                     '..##..##..##..##..##..##
Data &HFF , &HFF , &HFF                                     '########################
Data &HFF , &HFF , &HFF                                     '########################
Data &H80 , &H00 , &H01                                     '#......................#
Data &H80 , &H00 , &H01                                     '#......................#
Data &H81 , &H81 , &H81                                     '#......##......##......#
Data &H81 , &H81 , &H81                                     '#......##......##......#
Data &H81 , &H99 , &H81                                     '#......##..##..##......#
Data &H81 , &H99 , &H81                                     '#......##..##..##......#
Data &H81 , &H99 , &H81                                     '#......##..##..##......#
Data &H81 , &HFF , &H81                                     '#......##########......#
Data &H81 , &HFF , &H81                                     '#......##########......#
Data &H80 , &H00 , &H01                                     '#......................#
Data &H80 , &H00 , &H01                                     '#......................#
Data &H80 , &H00 , &H01                                     '#......................#
Data &HFF , &HFF , &HFF                                     '########################
Data &HFF , &HFF , &HFF                                     '########################
Data &H33 , &H33 , &H33                                     '..##..##..##..##..##..##
Data &H33 , &H33 , &H33                                     '..##..##..##..##..##..##
Data &HFF , &HFF , &HFF                                     '########################
Data &HFF , &HFF , &HFF                                     '########################

' Frame 2
' Delay : 1000ms
Data &HFF , &HFF , &HFF                                     '########################
Data &HFF , &HFF , &HFF                                     '########################
Data &HCC , &HCC , &HCC                                     '##..##..##..##..##..##..
Data &HCC , &HCC , &HCC                                     '##..##..##..##..##..##..
Data &HFF , &HFF , &HFF                                     '########################
Data &HFF , &HFF , &HFF                                     '########################
Data &H80 , &H00 , &H01                                     '#......................#
Data &H80 , &H00 , &H01                                     '#......................#
Data &H80 , &H00 , &H01                                     '#......................#
Data &H81 , &H82 , &H01                                     '#......##.....#........#
Data &H81 , &H83 , &H01                                     '#......##.....##.......#
Data &H81 , &HFF , &H81                                     '#......##########......#
Data &H81 , &HFF , &H81                                     '#......##########......#
Data &H81 , &H80 , &H01                                     '#......##..............#
Data &H81 , &H80 , &H01                                     '#......##..............#
Data &H80 , &H00 , &H01                                     '#......................#
Data &H80 , &H00 , &H01                                     '#......................#
Data &H80 , &H00 , &H01                                     '#......................#
Data &HFF , &HFF , &HFF                                     '########################
Data &HFF , &HFF , &HFF                                     '########################
Data &HCC , &HCC , &HCC                                     '##..##..##..##..##..##..
Data &HCC , &HCC , &HCC                                     '##..##..##..##..##..##..
Data &HFF , &HFF , &HFF                                     '########################
Data &HFF , &HFF , &HFF                                     '########################

' Frame 3
' Delay : 1000ms
Data &HFF , &HFF , &HFF                                     '########################
Data &HFF , &HFF , &HFF                                     '########################
Data &H99 , &H99 , &H99                                     '#..##..##..##..##..##..#
Data &H99 , &H99 , &H99                                     '#..##..##..##..##..##..#
Data &HFF , &HFF , &HFF                                     '########################
Data &HFF , &HFF , &HFF                                     '########################
Data &H80 , &H00 , &H01                                     '#......................#
Data &H80 , &H00 , &H01                                     '#......................#
Data &H81 , &H83 , &H01                                     '#......##.....##.......#
Data &H81 , &HC3 , &H81                                     '#......###....###......#
Data &H81 , &HE1 , &H81                                     '#......####....##......#
Data &H81 , &HF1 , &H81                                     '#......#####...##......#
Data &H81 , &HB9 , &H81                                     '#......##.###..##......#
Data &H81 , &H9F , &H81                                     '#......##..######......#
Data &H81 , &H8F , &H01                                     '#......##...####.......#
Data &H80 , &H00 , &H01                                     '#......................#
Data &H80 , &H00 , &H01                                     '#......................#
Data &H80 , &H00 , &H01                                     '#......................#
Data &HFF , &HFF , &HFF                                     '########################
Data &HFF , &HFF , &HFF                                     '########################
Data &H99 , &H99 , &H99                                     '#..##..##..##..##..##..#
Data &H99 , &H99 , &H99                                     '#..##..##..##..##..##..#
Data &HFF , &HFF , &HFF                                     '########################
Data &HFF , &HFF , &HFF                                     '########################

1 komentar:

Silahkan berkomentar !