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

Table des Matières

Publicité

}
Target
= await (await i2cPort.get_module()).get_serialNumber();
}
i2cPort
=
if (await i2cPort.isOnline()) {
await i2cPort.set_i2cMode("400kbps");
await i2cPort.set_i2cVoltageLevel(YI2cPort.I2CVOLTAGELEVEL_3V3);
await i2cPort.reset();
// do not forget to configure the powerOutput and
// of the Yocto-I2C as well if used
WriteLine("****************************");
WriteLine("* make sure voltage levels
WriteLine("* are properly configured
WriteLine("****************************");
List<int>
List<int>
int
tempReg
if
((tempReg
tempReg
} else {
tempReg
}
WriteLine("Ambiant temperature: "
);
} else {
WriteLine("Module not connected (check identification and USB
}
} catch
(YAPI_Exception
WriteLine("error: "
}
YAPI.FreeAPI();
return 0;
}
}
}
20.6. 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.
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Windows.UI.Xaml.Controls;
using com.yoctopuce.YoctoAPI;
namespace
Demo
{
public
class
Demo
{
public
string
public
string
public
bool
Beacon
public override async Task<int> Run()
{
YModule
m;
string
errmsg
if (await YAPI.RegisterHub(HubURL) != YAPI.SUCCESS) {
WriteLine("RegisterHub error: "
return -1;
}
m
=
YModule.FindModule(Target
if (await m.isOnline()) {
if (Beacon) {
await m.set_beacon(YModule.BEACON_ON);
www.yoctopuce.com
YI2cPort.FindI2cPort(Target
toSend
= new List<int>(new int[] {
received
= await
i2cPort.i2cSendAndReceiveArray(0x1f, toSend,
= (received[0] << 8) + received[1];
& 0x1000) != 0) {
-= 0x2000;
// perform sign extension
&= 0x0fff;
// clear status bits
ex) {
+ ex.Message);
:
DemoBase
HubURL
{ get; set; }
Target
{ get; set; }
{ get; set; }
= "";
+ ".module");
20. Utilisation du Yocto-I2C avec Universal Windows Platform
+ ".i2cPort");
*");
*");
0x05
});
+
String.Format("{0:0.000}", (tempReg
+ errmsg);
// use serial or logical name
2);
/ 16.0))
cable)");
165

Publicité

Table des Matières
loading

Table des Matières