📄 6100_for_mega_128l.bas
字号:
'Ansteuerung eines Nokia 6100 Farb-Display
'Copyright Martin Kuehn Januar 2004
'martin-k@x-mail.net
'Dieses Programm dient nur f黵 Demonstrationszwecke und ist absichtlich
'sehr einfach gehalten. Es ging mir nicht darum, elegant zu programmieren,
'sondern exemplarisch die Display-Ansteuerung aufzuzeigen.
'Prozessor: AVR Mega128, 3 Volt, Taktfrequenz 4 MHz
'Viele Werte zur Ansteuerung sind willk黵lich gew鋒lt und k鰊nen noch
'optimiert werden.
'Controller PCF8833
'Display Pin 1 VDIGITAL 3 Volt
' 2 Reset => AVR Pin A0
' 3 SDATA A4
' 4 SCLK A3
' 5 CS A1
' 6 VDISPLAY 3 Volt
' 7 NC
' 8 GND
Ddra = &B11111111 'Port A als Output
Dim A As Byte , B As Byte , R As Integer , S As Byte
Porta.1 = 0
Porta.4 = 0
Porta.3 = 0
Waitms 5
Porta.1 = 1
Waitms 5
'Initialisierung Reset
Porta.0 = 1
Waitms 10
Porta.0 = 0
Waitms 20
Porta.0 = 1
Waitms 10
Porta.1 = 1
Porta.4 = 1
Porta.3 = 1
Waitms 5
'Software Reset
A = &H01
Gosub Command
Gosub Cs
'Sleep Out
A = &H11
Gosub Command
Gosub Cs
'Booster ON
A = &H03
Gosub Command
Gosub Cs
'Booster Voltage muss stabil sein, sonst geht Display nicht an
Waitms 50
'Display On
A = &H29
Gosub Command
Gosub Cs
Wait 3
'Normal display mode
A = &H13
Gosub Command
Gosub Cs
'Display inversion off
A = &H20
Gosub Command
Gosub Cs
'Data order
A = &HBA
Gosub Command
Gosub Cs
'Memory data access control
A = &H36
Gosub Command
A = 8 'bgr
Gosub Parameter
Gosub Cs
'Set interface colour pixel format
'A = &H3A
'Gosub Command
'A = 2 '8 bit
'Gosub Parameter
'Gosub Cs
'x
A = &H2A
Gosub Command
A = 7
Gosub Parameter
A = 118
Gosub Parameter
Gosub Cs
'y
A = &H2B
Gosub Command
A = 4
Gosub Parameter
A = 122
Gosub Parameter
Gosub Cs
' Bascom Demo-Version ist speicherlimitiert, daher einige Schleifen l鰏chen
'Write pixel
A = &H2C
Gosub Command
S = 0
'roter Balken
For R = 1 To 1998
If S = 0 Then A = 15
If S = 1 Then A = 240
If S = 2 Then A = 255
Gosub Parameter
S = S + 1
If S = 3 Then S = 0
Next R
S = 0
'gr黱er Balken
For R = 1 To 1998
If S = 0 Then A = 240
If S = 1 Then A = 255
If S = 2 Then A = 15
Gosub Parameter
S = S + 1
If S = 3 Then S = 0
Next R
S = 0
'blauer Balken
For R = 1 To 1998
If S = 0 Then A = 255
If S = 1 Then A = 15
If S = 2 Then A = 240
Gosub Parameter
S = S + 1
If S = 3 Then S = 0
Next R
S = 0
'gelber Balken
For R = 1 To 1998
If S = 0 Then A = 0
If S = 1 Then A = 240
If S = 2 Then A = 15
Gosub Parameter
S = S + 1
If S = 3 Then S = 0
Next R
S = 0
'magenta Balken
For R = 1 To 1998
If S = 0 Then A = 15
If S = 1 Then A = 0
If S = 2 Then A = 240
Gosub Parameter
S = S + 1
If S = 3 Then S = 0
Next R
S = 0
'cyan Balken
For R = 1 To 1998
If S = 0 Then A = 240
If S = 1 Then A = 15
If S = 2 Then A = 0
Gosub Parameter
S = S + 1
If S = 3 Then S = 0
Next R
'wei遝r Balken
A = 0
For R = 1 To 1998
Gosub Parameter
Next R
'schwarzer Balken
A = 255
For R = 1 To 1998
Gosub Parameter
Next R
Gosub Cs
End
'Unterprogramme, Timing der Datenleitungen
'Senden eines Befehls
Command:
Porta.3 = 0
Porta.1 = 0 'Cs auf 0 Start der Sequenz
Porta.3 = 0
Porta.4 = 0 '0 f黵 Command
Porta.3 = 1
Porta.3 = 0
B = A And 128
If B = 128 Then Porta.4 = 1
If B = 0 Then Porta.4 = 0
Porta.3 = 1
Porta.3 = 0
B = A And 64
If B = 64 Then Porta.4 = 1
If B = 0 Then Porta.4 = 0
Porta.3 = 1
Porta.3 = 0
B = A And 32
If B = 32 Then Porta.4 = 1
If B = 0 Then Porta.4 = 0
Porta.3 = 1
Porta.3 = 0
B = A And 16
If B = 16 Then Porta.4 = 1
If B = 0 Then Porta.4 = 0
Porta.3 = 1
Porta.3 = 0
B = A And 8
If B = 8 Then Porta.4 = 1
If B = 0 Then Porta.4 = 0
Porta.3 = 1
Porta.3 = 0
B = A And 4
If B = 4 Then Porta.4 = 1
If B = 0 Then Porta.4 = 0
Porta.3 = 1
Porta.3 = 0
B = A And 2
If B = 2 Then Porta.4 = 1
If B = 0 Then Porta.4 = 0
Porta.3 = 1
Porta.3 = 0
B = A And 1
If B = 1 Then Porta.4 = 1
If B = 0 Then Porta.4 = 0
Porta.3 = 1
Return
'Senden eines Wertes
Parameter:
Porta.3 = 0
Porta.1 = 0 'Cs auf 0 Start der Sequenz
Porta.3 = 0
Porta.4 = 1 '1 f黵 Parameter
Porta.3 = 1
Porta.3 = 0
B = A And 128
If B = 128 Then Porta.4 = 1
If B = 0 Then Porta.4 = 0
Porta.3 = 1
Porta.3 = 0
B = A And 64
If B = 64 Then Porta.4 = 1
If B = 0 Then Porta.4 = 0
Porta.3 = 1
Porta.3 = 0
B = A And 32
If B = 32 Then Porta.4 = 1
If B = 0 Then Porta.4 = 0
Porta.3 = 1
Porta.3 = 0
B = A And 16
If B = 16 Then Porta.4 = 1
If B = 0 Then Porta.4 = 0
Porta.3 = 1
Porta.3 = 0
B = A And 8
If B = 8 Then Porta.4 = 1
If B = 0 Then Porta.4 = 0
Porta.3 = 1
Porta.3 = 0
B = A And 4
If B = 4 Then Porta.4 = 1
If B = 0 Then Porta.4 = 0
Porta.3 = 1
Porta.3 = 0
B = A And 2
If B = 2 Then Porta.4 = 1
If B = 0 Then Porta.4 = 0
Porta.3 = 1
Porta.3 = 0
B = A And 1
If B = 1 Then Porta.4 = 1
If B = 0 Then Porta.4 = 0
Porta.3 = 1
Return
Cs:
Porta.1 = 1
Return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -