{ TELETEXT.PAS } { Teletext SAA5281 s komunikaciou cez I2C. } { } { Datum:14.12.2017 http://www.trsek.com } program Teletext_SAA5281; uses crt,spec,i2c_com,vgaprog; var packet25:array[0..9] of byte; a,b,c:integer; prep:boolean; row,col,stran:byte; stranka:array [0..39,0..23] of byte; hidden:boolean; substr:string[2]; head:byte; hold:byte; klav:char; {$I kodovani.pas} {$I txtvga.pas} function kodovani (kod:byte):byte; begin case kod of 0,16:kodovani:=1; 1,17:kodovani:=12; 2,18:kodovani:=10; 3,19:kodovani:=14; 4,20:kodovani:=9; 5,21:kodovani:=13; 6,22:kodovani:=11; 7,23:kodovani:=15; 35:kodovani:=35; 36:kodovani:=133; 64:kodovani:=159; 91:kodovani:=156; 92:kodovani:=167; 93:kodovani:=236; 94:kodovani:=161; 95:kodovani:=253; 96:kodovani:=130; 123:kodovani:=160; 124:kodovani:=216; 125:kodovani:=163; 126:kodovani:=231; 127:kodovani:=219; 240:kodovani:=181; 243:kodovani:=214; 203:kodovani:=248; 238:kodovani:=162; 245:kodovani:=224; 247:KODOVANI:=233; else kodovani:=kod; end; end; procedure registr(cislo:byte;hodnota:byte); begin i2c_start; i2c_vystup(34); i2c_vystup(cislo); i2c_vystup(hodnota); i2c_stop; end; procedure volba(sto:byte;des:byte;jed:byte;bank:byte;prep:byte); var hold:byte; begin if prep=0 then hold:=0 else hold:=8; i2c_start; i2c_vystup(34); i2c_vystup(2); i2c_vystup(128+bank*64); i2c_vystup(sto and 247+16+hold); i2c_vystup(des + 16); i2c_vystup(jed + 16); i2c_vystup(0); i2c_vystup(0); i2c_vystup(0); i2c_vystup(0); i2c_vystup(0); i2c_stop; delay(1); end; procedure registry; begin registr(0,0+head); {advanced control} registr(1,0*128+0*64+0*32+0*16+0*8+0*4+0*2+0*1); {mode u SAA5254 d4 invert} {registr(2,0);} {registr(3,0);} {registr(4,8);} registr(5,1*128+1*64+0*32+0*16+1*8+1*4+1*2+1*1); {registr(6,204);} {registr(7,0*128+0*64+0*32+0*16+0*8+0*4+0*2+0*1);} {registr(8,0);} {registr(9,0);} {registr(10,0);} {registr(12,0);} {advanced control 2A} {registr(13,0);} {advanced control 2B} end; procedure prevod(vstup:byte); begin substr:=' '; str(vstup,substr); if (ord(substr[1])>ord('9')) or (ord(substr[1])ord('9')) or (ord(substr[2])47) and (readtmp<58); b:=readtmp-48; zapis; row_0; repeat readtmp:=ord(readkey); until (readtmp>47) and (readtmp<58); c:=readtmp-48; zapis; row_0; volba(a,b,c,0,hold); head:=0; end; procedure klavesa; begin if keypressed then begin klav:=readkey; if ord(klav)=27 then begin initscr(false); cursor(1); halt; end else case klav of 'q' :stran:=0; 'w' :stran:=1; 'e' :stran:=2; 'r' :stran:=3; 't' :stran:=4; 'y' :stran:=5; 'u' :stran:=6; 'i' :stran:=7; 'h' :hold_v; 'c' :clear; '1'..'8': hledani; end; end; end; procedure kvalita; var co:string[3]; begin if (status and 1)<>1 then co:='NOV' else if (status and 2)<>2 then co:='NOT' else co:=chr(a+48)+chr(b+48)+chr(c+48); i2c_start; i2c_vystup(34); i2c_vystup(8); i2c_vystup(stran); i2c_vystup(0); i2c_vystup(0); i2c_vystup(ord(co[1])); i2c_vystup(ord(co[2])); i2c_vystup(ord(co[3])); i2c_stop; end; procedure vypis_25; var poz:byte; begin for poz:=1 to 10 do begin gotoxy(50,poz); write(poz-1,'-',packet25[poz-1],' '); end; end; begin clrscr; TextMode(co40); cursor(0); initscr(true); hidden:=false; prep:=false; clear; stran:=0; hold:=1; a:=1;b:=0;c:=0; registry; zapis; volba(a,b,c,0,1); head:=0; repeat row_0; row_1_23; {row_24;} kvalita; {vypis_25;} klavesa; until (1=0); end.