Yoctopuce Yocto-MaxiDisplay Mode D'emploi page 169

Module électronique
Table des Matières

Publicité

NSLog(@"
demo
NSLog(@"
demo any
exit(1);
}
int main(int
argc,
{
NSError
*error;
YDisplay
*disp;
YDisplayLayer
*l0, *l1;
int
h, w, y, x, vx, vy;
@autoreleasepool {
// Setup the API to use local USB devices
if([YAPI
RegisterHub:@"usb": &error] != YAPI_SUCCESS) {
NSLog(@"RegisterHub error:
usage();
return
1;
}
if(argc <
2) {
disp
=
[YDisplay
if(disp
== nil) {
NSLog(@"No module connected (check USB
usage();
return
1;
}
} else {
NSString
*target
disp
=
[YDisplay
if(![disp
isOnline]) {
NSLog(@"Module not connected (check identification and USB
usage();
return
1;
}
}
// clear screen (and all layers)
[disp resetAll];
// retreive the display size
w
=
[disp get_displayWidth];
h
=
[disp get_displayHeight];
// reteive the first layer
l0
=
[disp get_displayLayer:0];
// display a text in the middle of the screen
[l0 drawText:w
// visualize each corner
[l0
moveTo:0
:5];
[l0
lineTo:0
:0];
[l0
lineTo:5
:0];
[l0
moveTo:0
:h
[l0
lineTo:0
:h
[l0
lineTo:5
:h
[l0 moveTo:w
-
[l0 lineTo:w
-
[l0 lineTo:w
-
[l0 moveTo:w
-
[l0 lineTo:w
-
[l0 lineTo:w
-
// draw a circle in the top left corner of layer 1
l1
=
[disp get_displayLayer:1];
[l1 clear];
[l1 drawCircle:h
// and animate the layer
NSLog(@"Use Ctrl-C to
x
=
0;
y
=
0;
vx
=
1;
vy
=
1;
while
([disp
isOnline]) {
x
+=
vx;
y
+=
vy;
if
((x <
0)
if
((y <
0)
www.yoctopuce.com
<logical_name>");
const char
* argv[])
%@", [error localizedDescription]);
FirstDisplay];
=
[NSString
stringWithUTF8String:argv[1]];
FindDisplay:target];
/
2
:h
/
2
:Y_ALIGN_CENTER
-
6];
-
1];
-
1];
1
:h
-
6];
1
:h
-
1];
6
:h
-
1];
1
:5];
1
:0];
6
:0];
/
8
:h
/
8
:h
/
8];
stop");
|| (x > w
-
(h
/ 4)))
|| (y > h
-
(h
/ 4)))
21. Utilisation du Yocto-MaxiDisplay en Objective-C
(use any discovered
cable)");
:@"Hello
world!"];
vx
=
-vx;
vy
=
-vy;
device)");
cable)");
163

Publicité

Table des Matières
loading

Ce manuel est également adapté pour:

Yocto-displayYocto-color-v2

Table des Matières