Yoctopuce Yocto-Color Mode D'emploi page 88

Table des Matières

Publicité

13. Utilisation du Yocto-Color en Delphi
SysUtils,
yocto_api,
yocto_colorled;
Procedure
Usage();
var
exe : string;
begin
exe:= ExtractFileName(paramstr(0));
WriteLn(exe+'
WriteLn(exe+'
WriteLn(exe+'
halt;
End;
procedure
setcolor(led1,led2:TYColorLed; color:integer);
begin
if (led1.isOnline()) then
begin
led1.set_rgbColor(color);
led2.rgbMove(color,1000);
end
else
Writeln('Module not connected (check identification and USB
end;
var
c
: char;
led1,led2 : TYColorLed;
m
: TYmodule;
errmsg
: string;
serial
: string;
begin
if (paramcount<1) then
// Setup the API to use local USB devices
if
yRegisterHub('usb', errmsg)<>YAPI_SUCCESS
begin
Write('RegisterHub error:
exit;
end;
// first one of the two RBG leds
if
paramstr(1)='any'
begin
led1 := yFirstColorLed();
if
led1=nil
begin
writeln('No module connected (check USB
halt;
end
end
else
led1:= YFindColorLed(paramstr(1)+'.colorled1');
// make sure it is online
if not(led1.isOnline()) then
begin
writeln('No module connected (check USB
halt;
end;
// lets find the device serial to find the second led
m := led1.Get_module();
serial := m.get_serialNumber();
led1 := yFindColorLed(serial+'.colorLed1');
led2 := yFindColorLed(serial+'.colorLed2');
Writeln('r: set to
Writeln('g: set to
Writeln('b: set to
Writeln('x:
exit');
repeat
read(c);
case
c
of
'r'
: setcolor(led1,led2,$FF0000);
82
<serial_number>');
<logical_name>');
any');
// immediate switch
// smooth transition
usage();
'+errmsg);
then
then
red');
green');
blue');
then
cable)');
cable)');
cable)');
www.yoctopuce.com

Publicité

Table des Matières
loading

Table des Matières