Télécharger Imprimer la page

Yoctopuce Yocto-PT100 Mode D'emploi page 127

Publicité

aa.clear();
YAPI.EnableUSBHost(this);
YAPI.RegisterHub("usb");
YModule
while
String
aa.add(hwid);
r
}
} catch
(YAPI_Exception
e.printStackTrace();
}
// refresh Spinner with detected relay
aa.notifyDataSetChanged();
}
@Override
protected
void
{
super.onStop();
YAPI.FreeAPI();
}
private
void
DisplayModuleInfo()
{
TextView
field;
if
(module
return;
try {
YAPI.UpdateDeviceList();// fixme
field
field.setText(module.getLogicalName());
} catch
(YAPI_Exception
e.printStackTrace();
}
}
@Override
public
void
onItemSelected(AdapterView<?>
{
String
hwid
module
= YModule.FindModule(hwid);
DisplayModuleInfo();
}
@Override
public
void
onNothingSelected(AdapterView<?> arg0)
{
}
public
void
saveName(View
{
if
(module
return;
EditText edit
String
newname
try {
if (!YAPI.CheckLogicalName(newname)) {
Toast.makeText(getApplicationContext(),
Toast.LENGTH_LONG).show();
return;
}
module.set_logicalName(newname);
module.saveToFlash();
edit.setText("");
} catch
(YAPI_Exception
ex.printStackTrace();
}
DisplayModuleInfo();
}
}
Attention, le nombre de cycles d'écriture de la mémoire non volatile du module est limité. Passé cette
limite plus rien ne garantit que la sauvegarde des réglages se passera correctement. Cette limite,
www.yoctopuce.com
r
= YModule.FirstModule();
(r
!= null) {
hwid
= r.get_hardwareId();
= r.nextModule();
e) {
onStop()
== null)
= (TextView) findViewById(R.id.logicalnamefield);
e) {
= parent.getItemAtPosition(pos).toString();
view)
== null)
= (EditText) findViewById(R.id.newname);
= edit.getText().toString();
// do not forget this
ex) {
17. Utilisation du Yocto-PT100 avec Android
parent,
View
view,
int
"Invalid name ("
pos,
long
id)
+
newname
+
")",
121

Publicité

loading