Yoctopuce Yocto-MaxiDisplay Mode D'emploi page 127

Module électronique
Table des Matières

Publicité

disp
=
YDisplay.FindDisplay(serial
//clean up
await disp.resetAll();
// retreive the display size
w
= await disp.get_displayWidth();
h
= await disp.get_displayHeight();
// reteive the first layer
let
l0
= await disp.get_displayLayer(0);
// display a text in the middle of the screen
await
l0.drawText(w
// visualize each corner
await l0.moveTo(0, 5);
await l0.lineTo(0, 0);
await l0.lineTo(5, 0);
await l0.moveTo(0,
await l0.lineTo(0,
await l0.lineTo(5,
await
l0.moveTo(w
await
l0.lineTo(w
await
l0.lineTo(w
await
l0.moveTo(w
await
l0.lineTo(w
await
l0.lineTo(w
// draw a circle in the top left corner of layer 1
l1
= await disp.get_displayLayer(1);
await l1.clear();
await
l1.drawCircle(h
// and animate the layer
console.log("Use Ctrl-C to
x
= 0;
y
= 0;
vx
= 1;
vy
= 1;
refresh();
}
async function refresh() {
if (await disp.isOnline()) {
x
+= vx;
y
+= vy;
if
((x
< 0) ||
if
((y
< 0) ||
await l1.setLayerPosition(x, y, 0);
} else {
console.log('Module not
}
setTimeout(refresh, 5);
}
startDemo();
Comme décrit au début de ce chapitre, vous devez avoir installé Node.js v7.6 ou suivant pour
essayer ces exemples. Si vous l'avez fait, vous pouvez maintenant taper les deux commandes
suivantes pour télécharger automatiquement les librairies dont cet exemple dépend:
npm install
Une fois terminé, vous pouvez lancer votre code d'exemple dans Node.js avec la commande
suivante, en remplaçant les [...] par les arguments que vous voulez passer au programme:
node demo.js
[...]
Le même exemple, mais dans un navigateur
Si vous voulez voir comment utiliser la librairie dans un navigateur plutôt que dans Node.js, changez
de répertoire et allez dans example_html/Doc-GettingStarted-Yocto-MaxiDisplay. Vous y
www.yoctopuce.com
+ ".display");
/ 2,
h
/ 2, l0.ALIGN_CENTER,
h
- 6);
h
- 1);
h
- 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)))
vx
(y
>
h
-
(h
/ 4)))
vy
connected');
16. Utilisation du Yocto-MaxiDisplay en JavaScript / EcmaScript
"Hello
world!");
= -vx;
= -vy;
121

Publicité

Table des Matières
loading

Ce manuel est également adapté pour:

Yocto-displayYocto-color-v2

Table des Matières