Hey Leute,
vor einer Weile hatte Tommy ja mal von LUNA berichtet.
Ich habe es mir nun mal angeguckt und finde es echt toll, deshalb habe ich hier mal für Interressierte die Initialisierung
eines Displays (128x64 Pixeln hier aus dem Shop) mit Einbindung einer Grafik in Luna.
vor einer Weile hatte Tommy ja mal von LUNA berichtet.
Ich habe es mir nun mal angeguckt und finde es echt toll, deshalb habe ich hier mal für Interressierte die Initialisierung
eines Displays (128x64 Pixeln hier aus dem Shop) mit Einbindung einer Grafik in Luna.
Code:
' *******************************************
' GCD mit SSD1306-Controller an ATmega16
' *******************************************
' Display: Monochrome 1.3" 128x64 OLED graphic display(AVR-praxis.de)
'********************************************
'Systemdefinition
'********************************************
avr.device=atmega16
avr.clock=20000000
avr.stack =32
#library "Library/spi.interface"
#includedata bild,"D:\elektronik\luna\Lunabilder\Excalibur128x64.lp" 'Lunapicture mit 128x64Pixeln laden
'********************************************
'Ausgänge
'********************************************
#define cs as portb.1 'Pin5 Chipselect des Displays
#define restart as portb.2 'Pin4 Reset
#define dc as portb.3 'Pin3 Data/Command auswahlpin 1=Data 0=Command
#define mosi as Portb.5 'Pin1 Data
#define sck as Portb.7 'Pin2 CLK
cs.mode=output,low
restart.mode=output,low
dc.mode=output.low
mosi.mode=output
sck.mode=output
'********************************************
'Initialisieren
'********************************************
'SPI Initialisieren
spi.master
spi.Clock=4
spi.enable
spi.SpeedDouble
'Display initialisieren
restart=0 'Display resetten
waitms 30
restart=1
dc=0 'Kommandos senden
dim i as byte
for i=0 to 24
SPI.Master.writebyte InitGLCD.bytevalue(i)
next
dc=1
'********************************************
'Hauptprogramm
'********************************************
bildsenden(bild.addr)
halt()
'********************************************
'Unterprogramme
'********************************************
procedure bildsenden(imgadr as word)
dim i,a,cc as byte
dim c,w,h,size as word
w = flash.ByteValue(imgAdr)
incr imgAdr
h = flash.ByteValue(imgAdr)
add imgAdr,3
size = h / 8
size = size * w
decr size
clr c
do
a = flash.ByteValue(imgAdr)
incr imgAdr
if a = &h77 then
cc = flash.ByteValue(imgAdr)
if cc then
incr imgAdr
a = flash.ByteValue(imgAdr)
incr imgAdr
for i = 1 to cc
spi.master.writebyte a
incr c
next
else
exit
end if
else
spi.master.writebyte a
incr c
end if
loop until c > size or c > 1023
endproc
'********************************************
'Datentabellen
'********************************************
data InitGLCD
.db 0xae 'Display ausschalten
.db 0xd5 'Oszillatorfrequenz Display einstellenn
.db 0x80
.db 0xa8 'Multiplexing einstellen
.db 0x3f
.db 0xd3 'Offset einstellen 0x00
.db 0x00
.db 0x40 'Startlinie bei 0x00 definieren
.db 0x8d
.db 0x14 'Ladungspumpe für Displayspannung aktivieren
.db 0x20 'Horizontaler Adressierungsmodus
.db 0x00
.db 0xa1 'Columnadresse 127=segment0
.db 0xc8 'Com Output Scan direction
.db 0xda 'Configuration com pins
.db 0x12
.db 0x81 'Kontrasteinstellung
.db 0x9f
.db 0xd9 'Pre-chargeperiode
.db 0x22
.db 0xdb 'VCOMH deselect level
.db 0x40
.db 0xa4 'Display aktivieren
.db 0xa6 'nichtinverses Display
.db 0xaf 'Display einschalten mit clear screen
endData