public class TiHCSR04 extends Object implements ITiEventListener
Constructor and Description |
---|
TiHCSR04(TiGPIO gpio,
int trigPinID,
int echoPinID)
TiHCSR04 initialization
|
Modifier and Type | Method and Description |
---|---|
double |
getDistance()
Gets the distance, unit:m
|
int |
getEchoPinID()
Gets the echo pin id
|
int |
getTrigPinID()
Gets the trig pin id
|
TiEventType |
getType()
the event type of the listener
|
void |
measure()
Startup distance measurement
|
void |
onEvent(ITiEvent evt)
triggered when the event occurs
|
void |
setSpeed(double speed)
Set the sound speed
|
public TiHCSR04(TiGPIO gpio, int trigPinID, int echoPinID) throws IOException
gpio
- TiGPIO object[IN]trigPinID
- trig pin id[IN]echoPinID
- echo id[IN]IOException
public double getDistance()
public int getEchoPinID()
public int getTrigPinID()
public TiEventType getType()
ITiEventListener
getType
in interface ITiEventListener
public void measure() throws IOException
IOException
public void onEvent(ITiEvent evt)
ITiEventListener
onEvent
in interface ITiEventListener
evt
- event objectpublic void setSpeed(double speed)
speed
- current speed,default:340