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]IOExceptionpublic double getDistance()
public int getEchoPinID()
public int getTrigPinID()
public TiEventType getType()
ITiEventListenergetType in interface ITiEventListenerpublic void measure()
throws IOException
IOExceptionpublic void onEvent(ITiEvent evt)
ITiEventListeneronEvent in interface ITiEventListenerevt - event objectpublic void setSpeed(double speed)
speed - current speed,default:340