📄 osdtest.bas
字号:
'OSDSTICK.BAS: OnScreen Simmstick Modul for TV-Box
'Hardware: 礟D 6450 from NEC
' AT90S2313
'Autor: Hartmut Wendt (c) TCS AG 2004
'History:
'V1.00 first release
$regfile = "2313def.dat"
$crystal = 8000000
$baud = 9600
'$lib "mcsbyte.lib"
'**** declaration *************************************************************
Declare Sub Clear
Declare Sub Byte_trans(byval Osd_byte As Byte)
Declare Sub Write_txt
Declare Sub Get_xy(byval Xypos As Byte)
'**** define variables ********************************************************
Dim Osd_byte As Byte
Const Loeschen = &H7F
Dim Osd_l As Byte
Dim S1 As String * 25
Dim L As Byte
Dim K As Byte
Dim Bg_color As Byte
Dim Bg_assignment As Byte
'**** port declaration ********************************************************
Ddrb = &B10100010 'set DDR Register Port B
Ddrd = &B00100000 'set DDR Register Port D
'Busy input
Busy Alias Portb.0 'Clock output
Clk Alias Portb.7 'Strobe output
Stb Alias Portb.1 'Data output
Daten Alias Portb.5
Led Alias Portd.5
Waitms 500
Gosub Grundeinstellung
Clear
Bg_color = 1
S1 = Lookupstr(0 , Text1 ) 'show copyright
Write_txt
Enable Interrupts
Do
'Main loop
L = Inkey() 'Get data from serial port
If L = "#" Then
'receive command
L = Waitkey()
Select Case L
Case "c" : Clear 'Clear screen
Case "b"
L = Waitkey()
If L = &H31 Then 'blink on
Byte_trans &B10001000
Else
Byte_trans &B10000000 'blink off
End If
Case "s" 'screen color
L = Waitkey()
L = L - &H30
If L < 8 Then Bg_color = L
L = &B11001000 + Bg_color
Byte_trans L
Case "g" 'gotoXY
Get_xy &B10100000 'set x position
Get_xy &B10010000 'set y position
Case "m" 'video mode
L = Waitkey()
If L = &H30 Then 'display on, chars white
'set background
L = &B11001000 + Bg_color
Byte_trans L
'display on
Byte_trans &B11110101 'video extern
Byte_trans &B11101111 'display on
Elseif L = &H31 Then 'display on, chars transparent
'set background
L = &B11010000 + Bg_color
Byte_trans L
Byte_trans &B11110101 'video extern
Byte_trans &B11101111 'display on
Elseif L = &H32 Then 'display off,
'display off
Byte_trans &B11100111
Elseif L = &H33 Then 'display on, solid background
'set background
L = &B11001000 + Bg_color
Byte_trans L
Byte_trans &B11110111 'video intern
Byte_trans &B11101111 'display on
End If
End Select
Elseif L >= &H20 And L < &H80 Then
'receive any char
L = L - &H20
L = Lookup(l , Charset )
Byte_trans L
End If
'ext. watchdog reset
'If Portd.6 = 0 Then
' Portd.6 = 1
'Else
' Portd.6 = 0
'End If
Loop
End 'end program
Sub Byte_trans(byval Osd_byte As Byte)
'send a byte to the uPD6450
Dim Osd_j As Byte
Warten:
If Busy = 0 Then
For Osd_j = 1 To 8
If Osd_byte.7 = 1 Then
Set Daten
Else
Reset Daten
End If
Clk = 0
Waitus 3
Clk = 1
Waitus 3
Rotate Osd_byte , Left , 1
Clk = 0
Next
Else
Goto Warten
End If
Stb = 1 'Strobe Impuls
Waitus 1
Stb = 0
End Sub
Grundeinstellung:
Byte_trans &B11111111 'format assignment command
Byte_trans &B10000000 'character size assignment command
Byte_trans &B01000110 'assignment command for display position vertikal address
Byte_trans &B11000110 'assignment command for display position horizontal adress
Byte_trans &B11111100 'format assignment command
Byte_trans &B11101101 'display on/off,blink,and LC oscillation commands
Byte_trans &B11001001 'background internal video signalcolor assinment command
Byte_trans &B10000000 'blink data command for each character
Byte_trans &B11110111 'external/internal video switching
Return
Sub Clear
'clears the screen
Dim Osd_i As Integer
Byte_trans &B10010000 'Zeile 1
Byte_trans &B10100000 'Zeichen 1
For Osd_i = 0 To 287
Byte_trans Loeschen
Next
End Sub
Sub Write_txt
'write a string from eeprom onto the screen
Dim B1 As Byte
Dim B2 As Byte
Dim Sx As String * 1
For B1 = 1 To Len(s1)
Sx = Mid(s1 , B1 , 1)
B2 = Asc(sx) - &H20
B2 = Lookup(b2 , Charset )
Byte_trans B2
Next B1
End Sub
Sub Get_xy(byval Xypos As Byte)
'set x or y position for text input via com
L = Waitkey()
K = Waitkey()
If L >= &H30 And K >= &H30 Then
L = L - &H30
K = K - &H30
L = L * 10
L = L + K
L = L + Xypos
Byte_trans L
End If
End Sub
Charset:
Data &H10 , &H3B , &H3C , &H3D , &H3E , &H10 , &H10 , &H10 , &H7E , &H7D , &H10 , &H10 , &H0F , &H0D , &H0E , &H6D
Data &H00 , &H01 , &H02 , &H03 , &H04 , &H05 , &H06 , &H07 , &H08 , &H09 , &H0A , &H6B , &H0B , &H00 , &H0C , &H50
Data &H10 , &H11 , &H12 , &H13 , &H14 , &H15 , &H16 , &H17 , &H18 , &H19 , &H1A , &H1B , &H1C , &H1D , &H1E , &H00
Data &H20 , &H21 , &H22 , &H23 , &H24 , &H25 , &H26 , &H27 , &H28 , &H29 , &H2A , &H76 , &H77 , &H3F , &H10 , &H10
Data &H10 , &H51 , &H52 , &H53 , &H54 , &H55 , &H56 , &H57 , &H58 , &H59 , &H5A , &H5B , &H5C , &H5D , &H5E , &H5F
Data &H60 , &H61 , &H62 , &H63 , &H64 , &H65 , &H66 , &H67 , &H68 , &H69 , &H6A , &H70 , &H71 , &H72 , &H73 , &H75
Text1:
Data "OSD STICK V1.0"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -