procedure TForm1.Button1Click(Sender: TObject);
var
valueMask: word;
begin
{ Create IP connection }
ipcon := TIPConnection.Create;
{ Create device object }
idi4 := TBrickletIndustrialDigitalIn4.Create(UID, ipcon);
{ Connect to brickd }
ipcon.Connect(HOST, PORT);
{ Don't use device before ipcon is connected }
{ Get current value as bitmask }
valueMask := idi4.GetValue;
Label1.Caption := Format('Value Mask: %d', [valueMask]);
// WriteLn(Format('Value Mask: %d', [valueMask]));
// WriteLn('Press key to exit');
// ReadLn;
ipcon.Destroy; { Calls ipcon.Disconnect internally }
end;
{ Callback procedure for interrupt callback }
procedure TExample.InterruptCB(sender: TBrickletIndustrialDigitalIn4;
const interruptMask: word; const valueMask: word);
begin
WriteLn(Format('Interrupt Mask: %d', [interruptMask]));// hier will ich den Button ändern (off/on)
WriteLn(Format('Value Mask: %d', [valueMask])); // die 3 Zeilen zu ändern krieg ich hin
WriteLn('');
end;
//das gehört auch noch irgendwo hin
{ Register interrupt callback to procedure InterruptCB }
idi4.OnInterrupt := {$ifdef FPC}@{$endif}InterruptCB;
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
ipcon: TIPConnection;
idi4: TBrickletIndustrialDigitalIn4;
procedure InterruptCB(Sender: TBrickletIndustrialDigitalIn4; const interruptMask: word; const valueMask: word);
public
end;
...
const
HOST = 'localhost';
PORT = 4223;
UID = 'XYZ'; { Change XYZ to the UID of your Industrial Digital In 4 Bricklet }
procedure TForm1.FormCreate(Sender: TObject);
begin
{ Create IP connection }
ipcon := TIPConnection.Create;
{ Create device object }
idi4 := TBrickletIndustrialDigitalIn4.Create(UID, ipcon);
{ Connect to brickd }
ipcon.Connect(HOST, PORT);
{ Don't use device before ipcon is connected }
{ Register interrupt callback to procedure InterruptCB }
idi4.OnInterrupt := @InterruptCB;
{ Enable interrupt on pin 0 }
idi4.SetInterrupt(1 shl 0);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
idi4.Free;
ipcon.Free;
end;
procedure TForm1.InterruptCB(Sender: TBrickletIndustrialDigitalIn4;
const interruptMask: word; const valueMask: word);
begin
ShowMessage('Ausgelöst');
end;
procedure TForm1.InterruptCB(Sender: TBrickletIndustrialDigitalIn4; const interruptMask: word; const valueMask: word);
begin
ShowMessage('Ausgelöst');
MyTimer.enabled:=true;
end;
NoCee hat geschrieben:Wo ist der Unterschied zwischen TTimer und TFPTimer?
Mitglieder in diesem Forum: 0 Mitglieder und 4 Gäste