Yoctopuce Yocto-MaxiDisplay Mode D'emploi page 115

Module électronique
Table des Matières

Publicité

let disp: YDisplay;
let l1: YDisplayLayer;
let h: number;
let w: number;
let y: number;
let x: number;
let vx: number;
let vy: number;
async function startDemo(): Promise<void>
{
await YAPI.LogUnhandledPromiseRejections();
// Setup the API to use the VirtualHub on local machine
let errmsg:
YErrorMsg
if(await YAPI.RegisterHub('127.0.0.1', errmsg) != YAPI.SUCCESS) {
console.log('Cannot contact VirtualHub on 127.0.0.1:
return;
}
// Select specified device, or use first available one
let serial:
string
if (serial[8] != '-') {
let
anydisplay
if (anydisplay) {
let module:
serial
} else {
console.log('No matching device connected, check cable
await YAPI.FreeAPI();
return;
}
}
console.log('Using device '
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(): Promise<void>
www.yoctopuce.com
= new YErrorMsg();
= process.argv[process.argv.length-1];
= YDisplay.FirstDisplay();
YModule
= await anydisplay.get_module();
= await module.get_serialNumber();
+ serial);
+ ".display");
/ 2,
h
/ 2,
YDisplayLayer.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
stop");
15. Utilisation du Yocto-MaxiDisplay en TypeScript
/ 8);
'+errmsg.msg);
!');
,
"Hello
world!");
109

Publicité

Table des Matières
loading

Ce manuel est également adapté pour:

Yocto-displayYocto-color-v2

Table des Matières