Yoctopuce Yocto-Thermocouple Mode D'emploi page 93

Table des Matières

Publicité

@Override
public
void
onCreate(Bundle
{
super.onCreate(savedInstanceState);
setContentView(R.layout.modulecontrol);
Spinner my_spin
my_spin.setOnItemSelectedListener(this);
aa
= new
ArrayAdapter<String>(this,
aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
my_spin.setAdapter(aa);
}
@Override
protected
void
{
super.onStart();
try {
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 {
field
field.setText(module.getSerialNumber());
field
field.setText(module.getLogicalName());
field
field.setText(String.format("%d%%",
field
field.setText(module.getUpTime() /
field
field.setText(module.getUsbCurrent() +
Switch
sw.setChecked(module.getBeacon() == YModule.BEACON_ON);
field
field.setText(module.get_lastLogs());
} catch
(YAPI_Exception
e.printStackTrace();
}
}
@Override
public
void
onItemSelected(AdapterView<?>
{
String
hwid
module
= YModule.FindModule(hwid);
DisplayModuleInfo();
}
@Override
public
void
onNothingSelected(AdapterView<?> arg0)
www.yoctopuce.com
savedInstanceState)
= (Spinner) findViewById(R.id.spinner1);
onStart()
r
= YModule.FirstModule();
(r
!= null) {
hwid
= r.get_hardwareId();
= r.nextModule();
e) {
onStop()
== 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);
= (TextView) findViewById(R.id.logs);
e) {
= parent.getItemAtPosition(pos).toString();
13. Utilisation du Yocto-Thermocouple avec Android
android.R.layout.simple_spinner_item);
module.getLuminosity()));
1000
+
"
sec");
"
mA");
parent,
View
view,
int
pos,
long
id)
87

Publicité

Table des Matières
loading

Table des Matières