Contrôle De La Partie Module - Yoctopuce Yocto-RangeFinder Mode D'emploi

Table des Matières

Publicité

13. Utilisation du Yocto-RangeFinder avec Android
handler.postDelayed(r,
}
@Override
protected
void
{
super.onStop();
handler.removeCallbacks(r);
YAPI.FreeAPI();
}
@Override
public
void
onItemSelected(AdapterView<?>
{
serial
= parent.getItemAtPosition(pos).toString();
}
@Override
public
void
onNothingSelected(AdapterView<?> arg0)
{
}
final
Runnable
{
public
void
{
if
(serial
YRangeFinder
YLightSensor
YTemperature
try {
);
);
));
} catch
}
}
handler.postDelayed(this,
}
};
}
13.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;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.Switch;
import android.widget.TextView;
import com.yoctopuce.YoctoAPI.YAPI;
import com.yoctopuce.YoctoAPI.YAPI_Exception;
import com.yoctopuce.YoctoAPI.YModule;
public class
ModuleControl
{
private ArrayAdapter<String> aa;
private
YModule
92
500);
onStop()
r
= new Runnable()
run()
!= null) {
rf
=
YRangeFinder.FindRangeFinder(serial
ir
=
YLightSensor.FindLightSensor(serial
tmp
=
YTemperature.FindTemperature(serial
_rfView.setText(String.format(Locale.US, "%.1f",
_irView.setText(String.format(Locale.US, "%.1f",
_tmpView.setText(String.format(Locale.US, "%.1f",
(YAPI_Exception
e.printStackTrace();
1000);
extends
Activity
module
= null;
parent,
View
view,
e) {
implements
OnItemSelectedListener
int
pos,
long
id)
+ ".rangeFinder1");
+ ".lightSensor1");
+ ".temperature1");
rf.getCurrentValue())
ir.getCurrentValue())
tmp.getCurrentValue()
www.yoctopuce.com

Publicité

Table des Matières
loading

Table des Matières