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

Table des Matières

Publicité

<HTML>
<HEAD>
<TITLE>Hello World</TITLE>
<SCRIPT
type="text/javascript"
<SCRIPT
type="text/javascript"
<SCRIPT
language='javascript1.5'
<!--
// Use explicit error handling rather than exceptions
yDisableExceptions();
// Setup the API to use the VirtualHub on local machine
if(yRegisterHub('http://127.0.0.1:4444/')
alert("Cannot contact VirtualHub on
}
var
led;
function refresh()
{
var
serial = document.getElementById('serial').value;
if(serial ==
// Detect any conected module suitable for the demo
led = yFirstLed();
if(led) {
serial = led.module().get_serialNumber();
document.getElementById('serial').value
}
}
led = yFindLed(serial+".led");
if(led.isOnline()) {
document.getElementById('msg').value
} else {
document.getElementById('msg').value
}
setTimeout('refresh()',500);
}
function switchIt(state)
{
if (state)
led.set_power(Y_POWER_ON);
else
led.set_power(Y_POWER_OFF);
}
-->
</SCRIPT>
</HEAD>
<BODY onload='refresh();'>
Module to use: <input id='serial'>
<input
id='msg' style='color:red;border:none;'
<a href='javascript:switchIt(true);'>ON</a><br>
<a href='javascript:switchIt(false);'>OFF</a>
</BODY>
</HTML>
7.3. 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.
<HTML>
<HEAD>
<TITLE>Module Control</TITLE>
<SCRIPT
type="text/javascript"
<SCRIPT
language='javascript1.5'
<!--
// Use explicit error handling rather than exceptions
yDisableExceptions();
// Setup the API to use the VirtualHub on local machine
if(yRegisterHub('http://127.0.0.1:4444/')
alert("Cannot contact VirtualHub on
}
www.yoctopuce.com
src="yocto_api.js"></SCRIPT>
src="yocto_led.js"></SCRIPT>
type='text/JavaScript'>
'') {
src="yocto_api.js"></SCRIPT>
type='text/JavaScript'>
7. Utilisation du Yocto-Demo en Javascript
!=
YAPI_SUCCESS) {
127.0.0.1");
= serial;
= '';
=
'Module not
connected';
readonly><br>
!=
YAPI_SUCCESS) {
127.0.0.1");
27

Publicité

Table des Matières
loading

Table des Matières