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

Table des Matières

Publicité

9. Utilisation du Yocto-Color en C++
led1->set_rgbColor(color);
led2->rgbMove(color, 1000);
} else {
cout
<<
"Module not connected (check identification and USB cable)"
}
yFreeAPI();
return
0;
}
9.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.
#include <iostream>
#include <stdlib.h>
#include "yocto_api.h"
using namespace
std;
static void usage(const
{
cout
<<
"usage: "
exit(1);
}
int main(int
argc,
{
string
errmsg;
// Setup the API to use local USB devices
if(yRegisterHub("usb",
cerr
<<
"RegisterHub error: "
return
1;
}
if(argc <
2)
usage(argv[0]);
YModule *module = yFindModule(argv[1]);
if (module->isOnline()) {
if
(argc >
2) {
if (string(argv[2])
module->set_beacon(Y_BEACON_ON);
else
module->set_beacon(Y_BEACON_OFF);
}
cout
<<
"serial:
cout
<<
"logical name: "
cout
<<
"luminosity:
cout
<<
"beacon:
if (module->get_beacon()
cout
<<
"ON"
else
cout
<<
"OFF"
cout
<<
"upTime:
cout
<<
"USB current:
cout
<<
"Logs:"
} else {
cout
<<
argv[1]
<< endl;
}
yFreeAPI();
return
0;
}
54
// immediate switch
// smooth transition
char
*exe)
<< exe <<
" <serial or logical name> [ON/OFF]"
const
char
*
argv[])
errmsg)
!=
YAPI_SUCCESS) {
<< errmsg << endl;
==
"ON")
"
<<
module->get_serialNumber()
<<
module->get_logicalName()
"
<<
module->get_luminosity()
";
==
Y_BEACON_ON)
<< endl;
<< endl;
"
<<
module->get_upTime()
"
<<
module->get_usbCurrent()
<<
endl
<<
module->get_lastLogs()
<<
" not connected (check identification and USB cable)"
// use serial or logical name
<< endl;
<< endl;
<< endl;
/
1000
<<
" sec"
<<
" mA"
<< endl;
<< endl;
<< endl;
<< endl;
<< endl;
www.yoctopuce.com

Publicité

Table des Matières
loading

Table des Matières