Contrôle De La Partie Module - Yoctopuce Yocto-4-20mA-Tx Mode D'emploi

Table des Matières

Publicité

17. Utilisation du Yocto-4-20mA-Tx avec Android
aa.notifyDataSetChanged();
}
@Override
protected
void
{
super.onStop();
YAPI.FreeAPI();
}
@Override
public
void
onItemSelected(AdapterView<?>
{
serial
= parent.getItemAtPosition(pos).toString();
}
@Override
public
void
onNothingSelected(AdapterView<?> arg0)
{
}
public
void
updateOutput(View
{
TextView editText1
double
value;
try {
value
} catch
(NumberFormatException
Toast.makeText(this,
editText1.setText("");
return;
}
YCurrentLoopOutput
".currentLoopOutput");
int
loopPower
try {
loopPower
if
(loopPower
Toast.makeText(this,
editText1.setText("");
return;
}
if
(loopPower
Toast.makeText(this,
Toast.LENGTH_LONG).show();
editText1.setText("");
return;
}
loop.set_current(value);
Toast.makeText(this,
Toast.LENGTH_LONG).show();
} catch
(YAPI_Exception
Toast.makeText(this,
).show();
e.printStackTrace();
}
}
}
17.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.
package com.yoctopuce.doc_examples;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
118
onStop()
view)
= (TextView) findViewById(R.id.editText1);
= Double.parseDouble(editText1.getText().toString());
"Invalid Number.
loop
=
YCurrentLoopOutput.FindCurrentLoopOutput(serial
= 0;
= loop.get_loopPower();
== YCurrentLoopOutput.LOOPPOWER_NOPWR) {
"Current loop not
== YCurrentLoopOutput.LOOPPOWER_LOWPWR) {
"Insufficient voltage on current
"current loop set to "
e) {
"Error:"
parent,
View
view,
ex) {
",
Toast.LENGTH_LONG).show();
powered",
+ Double.toString(value) +
+
e.getLocalizedMessage(),
int
pos,
long
id)
+
Toast.LENGTH_LONG).show();
loop",
"
mA",
Toast.LENGTH_LONG
www.yoctopuce.com

Publicité

Table des Matières
loading

Table des Matières