Yoctopuce Yocto-MaxiDisplay Mode D'emploi page 105

Module électronique
Table des Matières

Publicité

public class
ModuleControl
{
private ArrayAdapter<String> aa;
private
YModule
@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);
www.yoctopuce.com
extends
Activity
module
= null;
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();
14. Utilisation du Yocto-MaxiDisplay avec Android
implements
OnItemSelectedListener
android.R.layout.simple_spinner_item);
module.getLuminosity()));
1000
+
"
sec");
"
mA");
parent,
View
view,
int
pos,
long
id)
99

Publicité

Table des Matières
loading

Ce manuel est également adapté pour:

Yocto-displayYocto-color-v2

Table des Matières