Yoctopuce Yocto-MaxiDisplay Mode D'emploi page 59

Module électronique
Table des Matières

Publicité

#include "yocto_api.h"
#include "yocto_display.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace
std;
static void
usage(void)
{
cout
<<
"Wrong command line arguments"
cout
<<
"usage: demo <serial_number>"
cout
<<
"
cout
<<
"
u64
now
= YAPI::GetTickCount();
while (YAPI::GetTickCount() -
// wait 3 sec to show the message
}
exit(1);
}
int main(int
argc,
{
string
errmsg;
string
target;
YDisplay
*disp;
YDisplayLayer
*l0,
int
w, h, x, y, vx,
if(argc
< 2) {
usage();
}
// Setup the API to use local USB devices
if
(YAPI::RegisterHub("usb",
cerr
<<
"RegisterHub error: "
usage();
return 1;
}
target
= (string) argv[1];
if
(target
== "any") {
disp
=
YDisplay::FirstDisplay();
if
(disp
== NULL) {
cout
<<
"No module connected (check USB cable)"
usage();
return 1;
}
} else {
disp
=
YDisplay::FindDisplay(target
}
if (!disp->isOnline()) {
cout
<<
"Module is offline (check USB cable)"
usage();
return 1;
}
disp->resetAll();
// retreive the display size
w
= disp->get_displayWidth();
h
= disp->get_displayHeight();
// reteive the first layer
l0
= disp->get_displayLayer(0);
l0->clear();
// 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
-
1, h
l0->lineTo(w
-
1, h
www.yoctopuce.com
demo <logical_name>"
demo any (use any discovered device)"
now
< 3000) {
const char
* argv[])
*l1;
vy;
errmsg) != YAPI::SUCCESS) {
<<
errmsg
2, h
/
2, YDisplayLayer::ALIGN_CENTER,
- 6);
- 1);
- 1);
- 6);
- 1);
<< endl;
<< endl;
<< endl;
<< endl;
<< endl;
<< endl;
+ ".display");
<< endl;
"Hello world!"
10. Utilisation du Yocto-MaxiDisplay en C++
);
53

Publicité

Table des Matières
loading

Ce manuel est également adapté pour:

Yocto-displayYocto-color-v2

Table des Matières