protected void onStart()
{
super.onStart();
try {
aa.clear();
YAPI.EnableUSBHost(this);
YAPI.RegisterHub("usb");
YModule r = YModule.FirstModule();
while
String
aa.add(hwid);
r = r.nextModule();
}
} catch
(YAPI_Exception
e.printStackTrace();
}
// refresh Spinner with detected relay
aa.notifyDataSetChanged();
}
@Override
protected void onStop()
{
super.onStop();
YAPI.FreeAPI();
}
private void DisplayModuleInfo()
{
TextView field;
if
(module ==
return;
try {
field =
field.setText(module.getSerialNumber());
field =
field.setText(module.getLogicalName());
field =
field.setText(String.format("%d%%", module.getLuminosity()));
field =
field.setText(module.getUpTime()
field =
field.setText(module.getUsbCurrent()
Switch
Log.d("switch",
sw.setChecked(module.getBeacon()
field =
field.setText(module.get_lastLogs());
} catch
(YAPI_Exception
e.printStackTrace();
}
}
@Override
public void
onItemSelected(AdapterView<?> parent,
{
String
hwid = parent.getItemAtPosition(pos).toString();
module = YModule.FindModule(hwid);
DisplayModuleInfo();
}
@Override
public void
onNothingSelected(AdapterView<?>
{
}
public void
refreshInfo(View
{
DisplayModuleInfo();
}
public void
toggleBeacon(View
{
if
(module ==
return;
boolean
on =
www.yoctopuce.com
(r !=
null) {
hwid = r.get_hardwareId();
e) {
null)
(TextView)
findViewById(R.id.serialfield);
(TextView)
findViewById(R.id.logicalnamefield);
(TextView)
findViewById(R.id.luminosityfield);
(TextView)
findViewById(R.id.uptimefield);
(TextView)
findViewById(R.id.usbcurrentfield);
sw =
(Switch)
findViewById(R.id.beaconswitch);
"beacon"
+ module.get_beacon());
(TextView)
findViewById(R.id.logs);
e) {
view)
view)
null)
((Switch)
view).isChecked();
16. Utilisation du Yocto-Demo avec Android
/
1000
+
"
sec");
+
"
mA");
== YModule.BEACON_ON);
View
view,
int
arg0)
pos,
long
id)
95