PROGRAM NOKI6610;{Nokia 6610 LCD kijelzt vezrl program LDS176.rta:Sarok Adrin} USES DOS,CRT{,graflite,graph,graflite 130X130 PIXEL}; {Nyomtatport bektse: LPT, LCD kioszts: 1 VCC +3,3V 6 Q4 2 RES External Reset -active low 7 Q5 3 DATA serial data input 8 Q6 4 CLK serial clock 9 Q7 5 -CS Chip Enable input -active low 6 VCC +3,3V - Digitlis rsz betp 7 N.C. 8 GND 0V 9 VLED- 10 VLED+ } VAR nokiahsz:word;{bet httrszn} nokiabsz:word;{bet szn} times,timesr:string; C:CHAR; cn:byte; rajzx,rajzy:integer; i:longint; pbe:array[0..7]of byte;{ezt rja ki a nyomtatportra} b1:byte; karakter:array[1..8,1..5]of byte; {port[$378]:=pbe[6]+pbe[5]*2+pbe[2]*4+pbe[7]*8+pbe[4]*16+pbe[5]*32+pbe[6]*64+pbe[7]*128;} CONST ncolor16:array[0..16]of word = ($0000,$0008,$0080,$0077,$0800,$0F0F,$0B22,$AAAA,$7777,$000F,$00F0,$00FF, $FF00,$FF6A,$FFF0,$FFFF,$FFA0); CONST ncolor12:array[0..16]of word = ($000,$008,$080,$077,$800,$F0F,$B22,$AAA,$777,$00F,$0F0,$0FF, $F00,$F6A,$FF0,$FFF,$FA0); CONST ncolor8:array[0..16]of word = ($00,$08,$80,$77,$00,$0F,$22,$AA,$77,$0F,$F0,$FF, $00,$6A,$F0,$FF,$A0); (*Epson S1D15G10 Parancskszlet*) const DISON:byte=$af; const DISOFF :byte=$ae; const DISNOR :byte=$a6; const DISINV :byte=$a7; const SLPIN :byte=$95; const SLPOUT :byte=$94; const COMSCN :byte=$bb; const DISCTL :byte=$ca; const PASET :byte=$75; const CASET :byte=$15; const DATCTR :byte=$bc; const RGBSET8 :byte=$ce; const RAMWR :byte=$5c; const RAMRD :byte=$5d; const PTLIN :byte=$a8; const PTLOUT :byte=$a9; const RMWIN :byte=$e0; const RMWOUT :byte=$ee; const ASCSET :byte=$aa; const SCSTART :byte=$ab; const OSCON :byte=$d1; const OSCOFF :byte=$d2; const PWRCTR :byte=$20; const VOLCTR :byte=$81;(*64 fokozat van*) const VOLUP :byte=$d6;(*64 fokozat van*) const VOLDOWN :byte=$d7;(*64 fokozat van*) const TMPGRD :byte=$82; const EPCTIN :byte=$cd; const EPCOUT :byte=$cc; const EPMWR :byte=$fc; const EPMRD :byte=$fd; const EPSRRD1 :byte=$7c; const EPSRRD2 :byte=$7d; const NOP :byte=$25; const ENDPAGE :byte=132; const ENDCOL :byte=130; const NOKIAFONT1:ARRAY[32..122,1..5] of byte = ( {nokia ASCII (nokia+32)} ( $00, $00, $00, $00, $00 ), { sp 0} ( $00, $00, $2f, $00, $00 ), { ! 1 33} ( $00, $07, $00, $07, $00 ), { " 2 } ( $14, $7f, $14, $7f, $14 ), { # 3 } ( $24, $2a, $7f, $2a, $12 ), { $ 4 } ( $c4, $c8, $10, $26, $46 ), { % 5 } ( $36, $49, $55, $22, $50 ), { & 6 } ( $00, $05, $03, $00, $00 ), { ' 7 } ( $00, $1c, $22, $41, $00 ), { ( 8 } ( $00, $41, $22, $1c, $00 ), { ) 9 } ( $14, $08, $3E, $08, $14 ), { * 10 } ( $08, $08, $3E, $08, $08 ), { + 11 } ( $00, $00, $50, $30, $00 ), { , 12 } ( $10, $10, $10, $10, $10 ), { - 13 } ( $00, $60, $60, $00, $00 ), { . 14 } ( $20, $10, $08, $04, $02 ), { / 15 } ( $3E, $51, $49, $45, $3E ), { 0 16 48} ( $00, $42, $7F, $40, $00 ), { 1 17 } ( $42, $61, $51, $49, $46 ), { 2 18 } ( $21, $41, $45, $4B, $31 ), { 3 19 } ( $18, $14, $12, $7F, $10 ), { 4 20 } ( $27, $45, $45, $45, $39 ), { 5 21 } ( $3C, $4A, $49, $49, $30 ), { 6 22 } ( $01, $71, $09, $05, $03 ), { 7 23 } ( $36, $49, $49, $49, $36 ), { 8 24 } ( $06, $49, $49, $29, $1E ), { 9 25 } ( $00, $36, $36, $00, $00 ), { : 26 } ( $00, $56, $36, $00, $00 ), { ; 27 } ( $08, $14, $22, $41, $00 ), { < 28 } ( $14, $14, $14, $14, $14 ), { = 29 } ( $00, $41, $22, $14, $08 ), { > 30} ( $02, $01, $51, $09, $06 ), { ? 31} ( $32, $49, $59, $51, $3E ), { @ 32} ( $7E, $11, $11, $11, $7E ), { A 33 65} ( $7F, $49, $49, $49, $36 ), { B 34} ( $3E, $41, $41, $41, $22 ), { C 35} ( $7F, $41, $41, $22, $1C ), { D 36} ( $7F, $49, $49, $49, $41 ), { E 37} ( $7F, $09, $09, $09, $01 ), { F 38} ( $3E, $41, $49, $49, $7A ), { G 39} ( $7F, $08, $08, $08, $7F ), { H 40} ( $00, $41, $7F, $41, $00 ), { I 41} ( $20, $40, $41, $3F, $01 ), { J 42} ( $7F, $08, $14, $22, $41 ), { K 43} ( $7F, $40, $40, $40, $40 ), { L 44} ( $7F, $02, $0C, $02, $7F ), { M 45} ( $7F, $04, $08, $10, $7F ), { N 46} ( $3E, $41, $41, $41, $3E ), { O 47} ( $7F, $09, $09, $09, $06 ), { P 48} ( $3E, $41, $51, $21, $5E ), { Q 49} ( $7F, $09, $19, $29, $46 ), { R 50} ( $46, $49, $49, $49, $31 ), { S 51} ( $01, $01, $7F, $01, $01 ), { T 52} ( $3F, $40, $40, $40, $3F ), { U 53} ( $1F, $20, $40, $20, $1F ), { V 54} ( $3F, $40, $38, $40, $3F ), { W 55} ( $63, $14, $08, $14, $63 ), { X 56} ( $07, $08, $70, $08, $07 ), { Y 57} ( $61, $51, $49, $45, $43 ), { Z 58} ( $00, $7F, $41, $41, $00 ), { [ 59} ( $55, $2A, $55, $2A, $55 ), {55 60} ( $00, $41, $41, $7F, $00 ), { ] 61} ( $04, $02, $01, $02, $04 ), { ^ 62} ( $40, $40, $40, $40, $40 ), { _ 63} ( $00, $01, $02, $04, $00 ), { ' 64} ( $20, $54, $54, $54, $78 ), { a 65 97} ( $7F, $48, $44, $44, $38 ), { b 66} ( $38, $44, $44, $44, $20 ), { c 67} ( $38, $44, $44, $48, $7F ), { d 68} ( $38, $54, $54, $54, $18 ), { e 69} ( $08, $7E, $09, $01, $02 ), { f 70} ( $0C, $52, $52, $52, $3E ), { g 71} ( $7F, $08, $04, $04, $78 ), { h 72} ( $00, $44, $7D, $40, $00 ), { i 73} ( $20, $40, $44, $3D, $00 ), { j 74} ( $7F, $10, $28, $44, $00 ), { k 75} ( $00, $41, $7F, $40, $00 ), { l 76} ( $7C, $04, $18, $04, $78 ), { m 77} ( $7C, $08, $04, $04, $78 ), { n 78} ( $38, $44, $44, $44, $38 ), { o 79} ( $7C, $14, $14, $14, $08 ), { p 80} ( $08, $14, $14, $18, $7C ), { q 81} ( $7C, $08, $04, $04, $08 ), { r 82} ( $48, $54, $54, $54, $20 ), { s 83} ( $04, $3F, $44, $40, $20 ), { t 84} ( $3C, $40, $40, $20, $7C ), { u 85} ( $1C, $20, $40, $20, $1C ), { v 86} ( $3C, $40, $30, $40, $3C ), { w 87} ( $44, $28, $10, $28, $44 ), { x 88} ( $0C, $50, $50, $50, $3C ), { y 89} ( $44, $64, $54, $4C, $44 ) { z 90} ); function getdatestr:string; var s,s1:string; e,h,n,d:word; begin getdate(e,h,n,d); s:=''; str(e,s1); {if e<10 then s1:='0'+s1;} s:=s+s1+'.'; str(h,s1); if h<10 then s1:='0'+s1; s:=s+s1+'.'; str(n,s1); if n<10 then s1:='0'+s1; s:=s+s1+'.'; getdatestr:=s; end; function gettimestr:string; var s,s1:string; e,h,n,d:word; begin gettime(e,h,n,d); s:=''; str(e,s1); if e<10 then s1:='0'+s1; s:=s+s1+':'; str(h,s1); if h<10 then s1:='0'+s1; s:=s+s1+':'; str(n,s1); if n<10 then s1:='0'+s1; s:=s+s1; gettimestr:=s; end; function lintstr(w : longint) : String; var s : String; begin Str(w,s); LintStr := s; end; procedure portout; begin port[$378]:=(pbe[0]+pbe[1]*2+pbe[2]*4+pbe[3]*8+ pbe[4]*16+pbe[5]*32+pbe[6]*64+pbe[7]*128); {delay(1);} end; procedure writedc(wdc:byte);{soros adat, vagy parancs irasa} var fi:byte; begin for fi:=0 to 7 do begin pbe[5]:=(wdc shr (7-fi))and 1; {byte lebontsa bitekre} { write(pbe[5]);} portout; pbe[6]:=1;{sCLK} portout; pbe[6]:=0;{sCLK} portout; end; {write(' ');} end; {procedure writedc12(wdc:word); var fi:byte; begin for fi:=0 to 11 do begin pbe[5]:=(wdc shr (11-fi))and 1; portout; pbe[6]:=1;(*sCLK*) portout; pbe[6]:=0;(*sCLK*) portout; end; end;} procedure writecommand(wc:byte);{ha az els bit=0, akkor command.} begin textcolor(14); pbe[7]:=0; {-ChipEnable} portout; pbe[5]:=0; {Data 9.bit -> 0=Command} portout; pbe[6]:=1; {CLK} portout; { delay(1);} pbe[6]:=0; {CLK} portout; (* delay(1);*) writedc(wc); pbe[7]:=1; {-ChipDisble} portout; end; procedure writedata(wd:byte); begin textcolor(10); pbe[7]:=0; {-ChipEnable} portout; pbe[5]:=1; {data 9.bit -> 1=Data} portout; pbe[6]:=1; {CLK} portout; { delay(1);} pbe[6]:=0; {CLK} portout; (*delay(1);*) writedc(wd); pbe[7]:=1; {-ChipDisble} portout; end; procedure nokiagotoxy(xnokia,ynokia:byte); {Nokia LCD Position} begin {bytefornokia:=(:byte=$40|(ynokia&$07)); { // Y axe initialisation: 0100 0yyy} writecommand($40+ynokia and $07); {bytefornokia:=(:byte=$80|(xnokia$7f)); /{/ X axe initialisation: 1xxx xxxx} writecommand($80+xnokia and $7f); end; procedure nokiabetu(nox,noy:byte;nb:char); {1 karakter kirsa az LCD-re} var ordch,chbit:byte;{karakter rtke-ASCII} choszlop:byte;{oszlop 1-5-ig} begin ordch:=ord(nb); for choszlop:=1 to 5 do begin writecommand(CASET); (*set column address*) writeData(nox+choszlop); (* start*) writeData(nox+choszlop); (* end *) writecommand(PASET); writeData(noy+2); (* start*) writeData(noy+10); (* end *) writecommand(RAMWR); for chbit:=0 to 7 do begin if(nokiafont1[ordch,choszlop] shr (chbit))and 1=1 then begin writedata(hi(nokiabsz)); writedata(lo(nokiabsz)); end else begin writedata(hi(nokiahsz)); writedata(lo(nokiahsz)); end end; end; end; procedure nokiaprint(nkx,nky:byte;np:string); { String kirsa az LCD-re} var ip,ip1:byte; begin for ip:=1 to length(np)do begin nokiabetu(nkx+(ip-1)*6,nky,np[ip]); end; end; procedure betuszin(nbs:word); begin nokiabsz:=nbs; end; procedure hatterszin(nhs:word); begin nokiahsz:=nhs; end; procedure Pixel(x,y:integer;color:word); { // Draw a pixel at the specified coordinates and color // x = column address [0..129] // y = row address [0..129] // color = 16-bit color value: 0000_RRRR_GGGG_BBBB} begin {x:=x+2; (*A l'that= r;sy a 2.sorn'l keydodik*)} writecommand(CASET); (*set column address*) writeData(x); (* start*) writeData(x); (* end *) writecommand(PASET); writeData(y+2); (* start*) writeData(y+2); (* end *) writecommand(RAMWR); writeData(hi(color)); writeData(lo(color)); end; procedure nokiasik(ns1,ns2,ns3,ns4:byte;nscol:word); var xt,yt,si:byte; begin {x:=x+2; (*A l'that= r;sy a 2.sorn'l keydodik*)} writecommand(CASET); (*set column address*) writeData(ns1); (* start*) writeData(ns3); (* end *) writecommand(PASET); writeData(ns2+2); (* start*) writeData(ns4+2); (* end *) xt:=ns3-ns1; yt:=ns4-ns2; writecommand(RAMWR); for si:=1 to xt*yt do begin writeData(hi(nscol)); writeData(lo(nscol)); end; end; procedure terulet(tx1,ty1,tx2,ty2:byte); begin writecommand($15); writedata(tx1); writedata(tx2); writecommand($75); writedata(ty1+2); writedata(ty2+2); end; procedure nokiateglalap(nt1,nt2,nt3,nt4:byte;ntc:word); var tdiff:byte; tv:byte; begin tdiff:=nt3-nt1; terulet(nt1,nt2,nt3,nt2); writecommand(RAMWR); for tv:=1 to tdiff do begin writeData(hi(ntc)); writeData(lo(ntc)); end; terulet(nt1,nt4,nt3,nt4); writecommand(RAMWR); for tv:=1 to tdiff do begin writeData(hi(ntc)); writeData(lo(ntc)); end; tdiff:=nt4-nt2; terulet(nt1,nt2,nt1,nt4); writecommand(RAMWR); for tv:=1 to tdiff do begin writeData(hi(ntc)); writeData(lo(ntc)); end; terulet(nt3,nt2,nt3,nt4); writecommand(RAMWR); for tv:=1 to tdiff do begin writeData(hi(ntc)); writeData(lo(ntc)); end; end; procedure contrast(contr:byte); begin writecommand({25}VOLCTR); writedata(contr);{21 -csak az als 7 bit fontos} end; procedure displayon; begin writecommand({29}DISON); end; procedure displayoff; begin writecommand({28}DISOFF); end; procedure invertON; begin writecommand({21}DisINV); end; procedure invertOFF; begin writecommand({20}DisNOR); end; procedure initlcdepson; begin pbe[6]:=0;(*CLK*) pbe[5]:=0;(*sData*) pbe[7]:=1;(*CS*) pbe[4]:=0;(*Reset*) portout; delay(200); pbe[4]:=1;(*Reset*) portout; writecommand(DISCTL); writedata(7);(*3>12bit???*) writecommand(COMSCN); writedata($01);(*Common Scanning Direction 1->80 81<- 160*) writecommand(OSCON);{FONTOS!} writecommand(SLPOUT);{FONTOS!} writecommand(VOLCTR);(*Contrast/Brightness*){FONTOS!} writedata($27);(*Kontraszt*) writedata($03)(*bels ellenlls*); writecommand(PWRCTR);{FONTOS!} writedata($0F)(*Minden szart bekapcsol*); delay(50); writecommand(DISINV);{ennel a tipusnal kell} writecommand(DATCTR); writedata($00);(*Norml display, page/column cimzs, nincs tukrozes*) writedata($01);(*Norml RGB*) writedata($04);(*3:12bit 5:16bit*) writecommand(DISON); delay(100); writecommand(ramwr); for i:=1 to 132*132*2 do begin writedata(hi(nokiahsz));(*Fill screen RED*) writedata(lo(nokiahsz));(*Fill screen RED*) end; nokiasik(0,0,128,128,$000F); end; BEGIN nokiahsz:={F7}$0FFF; nokiabsz:=$0A00; clrscr; textcolor(15); writeln('Nokia 6610 LCD vezrl program - Sarok Adrin'); {initlcd; readkey;} initlcdepson; {writeln('Ready...');} nokiaprint(3,0,'....................'); nokiabsz:=$000F; nokiaprint(3,10,'Nokia 6610 CSTN'); nokiabsz:=$0A00; nokiaprint(3,20,' Kijelzo'); nokiaprint(3,30,'Meghajto Program'); nokiaprint(3,40,'Irta:'); nokiabsz:=$00F0; nokiaprint(3,50,'Sarok Adrian'); nokiabsz:=$0F00; nokiaprint(3,60,'Keszult:6'); nokiaprint(3,70,'2008.Aug.13-15'); nokiabsz:=$0A00; nokiaprint(3,80,'Jo jatek...'); nokiaprint(3,90,'Szelesseg (karakter):'); nokiaprint(1,100,'123456789013456789012'); randomize; nokiateglalap(0,0,129,129,$000F); nokiateglalap(1,1,128,128,$000F); repeat c:=chr(1); if keypressed then c:=readkey; if c=chr(0)then{funkcio bill.} begin if keypressed then c:=readkey; if c=('H')then rajzy:=rajzy-1;{Fel} if c=('P')then rajzy:=rajzy+1;{Le} if c=('K')then rajzx:=rajzx-1;{Bal} if c=('M')then rajzx:=rajzx+1;{Jobb} if rajzx>129 then rajzx:=129; if rajzx<0 then rajzx:=0; if rajzy>129 then rajzy:=129; if rajzy<0 then rajzy:=0; pixel(rajzx,rajzy,$0F0F); c:=chr(1); writeLN(rajzx,'.',rajzy,' '); end; if c='+'then writecommand($d6); if c='8'then nokiabsz:=nokiabsz+1; if c='5'then nokiabsz:=nokiabsz-1; if nokiabsz>65535 then nokiabsz:=0; if nokiabsz<=0 then nokiabsz:=65535; if c='-'then writecommand($d7); if c='i'then inverton; if c='o'then invertoff; if c='d'then displayon; if c='x'then displayoff; {if (c='r')or(c='R')then resetlcd;} times:=gettimestr; if timesr<>times then begin timesr:=times; {nokiabsz:=random(256);} nokiaprint(3,110,'Color:'+lintstr(nokiabsz)); nokiaprint(3,120,times+'/'+getdatestr); end; until (c=chr(27))or(c='q'); if c<>'q'then displayoff; writeln(port[$378]); if c<>'q'then port[$378]:=0; (*readkey;*) writeln; {myname;} END.