Mega Code Archive

 
Categories / Delphi / Hardware
 

Seri port uygulaması

//NUH EROĞLU unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, jpeg, ExtCtrls, CPort, StdCtrls, SendKeys; type TForm1 = class(TForm) arkapilan: TImage; menu: TShape; tamam: TShape; pirog_arttir: TShape; pirog_azalt: TShape; ses_kapa: TShape; ses_ac: TShape; yon_ust: TShape; yon_alt: TShape; yon_sol: TShape; yon_sag: TShape; Memo1: TMemo; baglan: TButton; ayril: TButton; ComPort1: TComPort; av: TShape; pp: TShape; sessiz: TShape; Timer1: TTimer; Edit1: TEdit; CheckBox1: TCheckBox; procedure baglanClick(Sender: TObject); procedure ayrilClick(Sender: TObject); procedure ComPort1RxChar(Sender: TObject; Count: Integer); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure CheckBox1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; Tusla : boolean ; implementation {$R *.dfm} procedure TForm1.baglanClick(Sender: TObject); begin ComPort1.Open end; procedure TForm1.ayrilClick(Sender: TObject); begin ComPort1.Close end; procedure hepsinormal(); begin form1.yon_ust.Brush.Color := clblack ; form1.yon_alt.Brush.Color := clblack ; form1.yon_sag.Brush.Color := clblack ; form1.yon_sol.Brush.Color := clblack ; form1.menu.Brush.Color := clblack ; form1.av.Brush.Color := clblack ; form1.tamam.Brush.Color := clblack ; form1.pp.Brush.Color := clblack ; form1.ses_ac.Brush.Color := clblack ; form1.ses_kapa.Brush.Color := clblack ; form1.pirog_arttir.Brush.Color := clblack ; form1.pirog_azalt.Brush.Color := clblack ; form1.sessiz.Brush.Color := clblack ; end; function TusNoOlsunTusIsimi(no:integer):string ; var isim : string; begin case no of 5: isim := 'Yön > Yukari' ; 69: isim := 'Yön > Asagi' ; 53: isim := 'Yön > Sag' ; 85: isim := 'Yön > Sol' ; 37: isim := 'Menü' ; 12: isim := 'A>V' ; 117: isim := 'Tamam' ; 34: isim := 'P<P4' ; // 5: isim := 'Ses > Arttir" ; // 69: isim := 'Ses > Azalt' ; 2: isim := 'Program > Arttir' ; 66: isim := 'Program > Azalt' ; 91: isim := 'Sessiz' ; 67: isim := '1' ; 35: isim := '2' ; 99: isim := '3' ; 19: isim := '4' ; 83: isim := '5' ; 51: isim := '6' ; 115: isim := '7' ; 11: isim := '8' ; 75: isim := '9' ; 3: isim := '0' ; 43: isim := '-/--' ; 106: isim := '<< GERI AL' ; 122: isim := ' > OYNAT' ; 58: isim := '>> ILERI AL' ; 26: isim := '[] DURDUR' ; 90: isim := '|| ARAVER' ; else isim:='..'; end; result := isim ; end; function TusNoOlsunTusKarakter(no:integer):string ; var isim : string; begin case no of 5: isim := SK_UP ; 69: isim := SK_DOWN ; 53: isim := SK_RIGHT ; 85: isim := SK_LEFT ; 37: isim := SK_ESC ; 12: isim := 'AV' ; 117: isim := SK_ENTER ; 34: isim := 'PP4' ; // 5: isim := 'Ses > Arttir" ; // 69: isim := 'Ses > Azalt' ; 2: isim := SK_PGUP ; 66: isim := SK_PGDN ; 91: isim := 'Sessiz' ; 67: isim := '1' ; 35: isim := '2' ; 99: isim := '3' ; 19: isim := '4' ; 83: isim := '5' ; 51: isim := '6' ; 115: isim := '7' ; 11: isim := '8' ; 75: isim := '9' ; 3: isim := '0' ; 43: isim := 'aaaa' ; 106: isim := 'GERI AL' ; 122: isim := 'OYNAT' ; 58: isim := 'ILERI AL' ; 26: isim := 'DURDUR' ; 90: isim := 'ARAVER' ; else isim:='tt'; end; result := isim ; end; procedure TForm1.ComPort1RxChar(Sender: TObject; Count: Integer); var gelenbilgi:string; begin ComPort1.ReadStr(GelenBilgi,1); if tusla then SendKeyString( TusNoOlsunTusKarakter( ord( GelenBilgi[1] ) ) ) ; Memo1.Lines.Add( TusNoOlsunTusIsimi( ord( GelenBilgi[1] ) ) ) ; Edit1.Text := inttostr( ord( GelenBilgi[1] ) ) + ' : ' + GelenBilgi[1] ; //Memo1.Lines.Add(inttostr(ord(GelenBilgi[1]))+' > '+GelenBilgi); { hepsinormal(); case ord( GelenBilgi[1] ) of 5: yon_ust.Brush.Color := clwhite ; 69: yon_alt.Brush.Color := clwhite ; 53: yon_sag.Brush.Color := clwhite ; 85: yon_sol.Brush.Color := clwhite ; 37: menu.Brush.Color := clwhite ; 12: av.Brush.Color := clwhite ; 117: tamam.Brush.Color := clwhite ; 34: pp.Brush.Color := clwhite ; // 5: ses_ac.Brush.Color := clwhite ; // 69: ses_kapa.Brush.Color := clwhite ; 2: pirog_arttir.Brush.Color := clwhite ; 66: pirog_azalt.Brush.Color := clwhite ; 91: sessiz.Brush.Color := clwhite ; else hepsinormal(); end; } end; procedure TForm1.FormCreate(Sender: TObject); begin ComPort1.Open end; procedure TForm1.FormDestroy(Sender: TObject); begin ComPort1.Close; end; procedure TForm1.Timer1Timer(Sender: TObject); begin hepsinormal(); end; procedure TForm1.CheckBox1Click(Sender: TObject); begin tusla :=CheckBox1.Checked ; end; end. //NUH EROĞLU