User Manual

- 8 -
RUN_SINGLE_SHOT: Single measurement mode, in which the camera takes a measurement
and then automatically switches to RUN_IDLE. There are two ways to measure, one is synchronous
measurement and the other is asynchronous measurement (default is asynchronous).
RUN_CONTINUOUS: Continuous measurement mode, in which the camera will
automatically perform continuous measurement until the user manually sets it to RUN_IDLE or
RUN_SINGLE_SHOT mode; the measurement data is returned by the structure form, refer to the
MeasureDataTypeDef structure, and the data type is enumerated by returning the packet type.
(RetPacketTypedef) makes a distinction.
5. After all the steps are successfully configured, there are two ways to obtain measurement data,
one is synchronous measurement (only one measurement is supported), and the other is
asynchronous (supports single measurement and continuous measurement).
(1) Synchronous measurement (only one measurement is supported), and the
HPS3D_SingleMeasurement function in api.h is called to perform a single measurement. The
sample code is as follows:
HPS3D_SingleMeasurement(&handle);
printf
("distance average:%d\n",handle.MeasureData.full_depth_data->distance_average);
Note
In the HPS3D_SingleMeasurement function, the communication mode handle.SyncMode is set to
the synchronous mode SYNC. If it is set to the asynchronous mode, the handle.SyncMode is set to
the asynchronous mode ASYNC after the function.
2Asynchronous measure(Support single measure and continuously measure)
Set operation mode, code is as follow:
/*Set to continuous measurement mode*/
handle.RunMode =
RUN_CONTINUOUS
;
/*Set to single measurement mode*/
handle.RunMode =
RUN_SINGLE_SHOT
;
HPS3D_SetRunMode(&handle);
Write the observer callback function, the code is as follows:
/*
* User processing function,Continuous measurement or asynchronous mode
* in which the observer notifies the callback function
* */
void
*
User_Func
(HPS3D_HandleTypedef *handle,AsyncIObserver_t *event)
{
if
(event->AsyncEvent ==
ISubject_Event_DataRecvd
)
{
switch
(event->RetPacketType)
{
case
SIMPLE_ROI_PACKET
:
break
;
case
FULL_ROI_PACKET
:
break
;
case
FULL_DEPTH_PACKET
:
printf
("distance average:%d