Contrôle De La Partie Module - Yoctopuce Yocto-RangeFinder Mode D'emploi

Table des Matières

Publicité

{
NSLog(@"usage: demo <serial_number>
NSLog(@"
demo
NSLog(@"
demo any
exit(1);
}
int main(int
argc,
{
NSError
*error;
if
(argc <
2) {
usage();
}
@autoreleasepool {
// Setup the API to use local USB devices
if([YAPI
RegisterHub:@"usb": &error] != YAPI_SUCCESS) {
NSLog(@"RegisterHub error:
return
1;
}
NSString
*target
YRangeFinder
*rf;
YLightSensor
*ir;
YTemperature
*tmp;
if
([target
isEqualToString:@"any"]) {
rf
=
[YRangeFinder
if
(rf
== NULL) {
NSLog(@"No module connected (check USB
return
1;
}
} else {
rf
=
[YRangeFinder
];
}
if
(![rf
isOnline]) {
NSLog(@"Module not connected (check identification and USB
}
NSString
*serial
ir
=
[YLightSensor
[serial stringByAppendingString:@".lightSensor1"]];
tmp
=
[YTemperature
[serial stringByAppendingString:@".temperature1"]];
while(1) {
if(![rf
isOnline]) {
NSLog(@"Module not connected (check identification and USB
break;
}
NSLog(@"Distance
NSLog(@"Ambiant IR
NSLog(@"Temperature :
NSLog(@"
(press Ctrl-C to
[YAPI
Sleep:1000:NULL];
}
[YAPI
FreeAPI];
}
return
0;
}
20.2. Contrôle de la partie module
Chaque module peut-être contrôlé d'une manière similaire, vous trouverez ci dessous un simple
programme d'exemple affichant les principaux paramètres d'un module et permettant d'activer la
balise de localisation.
#import <Foundation/Foundation.h>
#import "yocto_api.h"
static void usage(const char
{
NSLog(@"usage: %s <serial or logical name>
www.yoctopuce.com
");
<logical_name>");
const char
* argv[])
%@", [error localizedDescription]);
=
[NSString
stringWithUTF8String:argv[1]];
FirstRangeFinder];
FindRangeFinder:[target
=
[[rf
module]
serialNumber];
FindLightSensor:
FindTemperature:
:
%f\n", [rf get_currentValue]);
:
%f\n", [ir get_currentValue]);
%f\n", [tmp get_currentValue]);
exit)\n");
*exe)
20. Utilisation du Yocto-RangeFinder en Objective-C
(use any discovered
device)");
cable)");
stringByAppendingString:@".rangeFinder1"]
[ON/OFF]\n", exe);
cable)");
cable)\n");
157

Publicité

Table des Matières
loading

Table des Matières