Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_hc_sr04

Driver for HC-SR04 ultrasonic range sensor. More...

Enumerations

enum  bc_hc_sr04_event_t {
  BC_HC_SR04_EVENT_ERROR = 0,
  BC_HC_SR04_EVENT_UPDATE = 1
}
 

Functions

void bc_hc_sr04_init (void)
 
void bc_hc_sr04_set_event_handler (void(*event_handler)(bc_hc_sr04_event_t, void *), void *event_param)
 Set callback function. More...
 
void bc_hc_sr04_set_update_interval (bc_tick_t interval)
 Set measurement interval. More...
 
bool bc_hc_sr04_measure (void)
 Start measurement manually. More...
 
bool bc_hc_sr04_get_distance_millimeter (float *millimeter)
 Get measured distance in millimeters. More...
 

Detailed Description

Driver for HC-SR04 ultrasonic range sensor.

Enumeration Type Documentation

Enumerator
BC_HC_SR04_EVENT_ERROR 

Error event.

BC_HC_SR04_EVENT_UPDATE 

Update event.

Definition at line 10 of file bc_hc_sr04.h.

Function Documentation

bool bc_hc_sr04_get_distance_millimeter ( float *  millimeter)

Get measured distance in millimeters.

Parameters
[in]millimeterPointer to variable where result will be stored
Returns
true When value is valid
false When value is invalid

Definition at line 143 of file bc_hc_sr04.c.

bool bc_hc_sr04_measure ( void  )

Start measurement manually.

Returns
true On success
false When other measurement is in progress

Definition at line 93 of file bc_hc_sr04.c.

Referenced by bc_hc_sr04_set_update_interval().

Here is the call graph for this function:

Here is the caller graph for this function:

void bc_hc_sr04_set_event_handler ( void(*)(bc_hc_sr04_event_t, void *)  event_handler,
void *  event_param 
)

Set callback function.

Parameters
[in]event_handlerFunction address
[in]event_paramOptional event parameter (can be NULL)

Definition at line 71 of file bc_hc_sr04.c.

void bc_hc_sr04_set_update_interval ( bc_tick_t  interval)

Set measurement interval.

Parameters
[in]intervalMeasurement interval

Definition at line 77 of file bc_hc_sr04.c.

Here is the call graph for this function: