yono / Mbed 2 deprecated Pixart

Dependencies:   BLE_API mbed nRF51822 paw8001motion32_5_m0_keil_split

Fork of Pixart by Lonnie Zhang

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pxialg.h Source File

pxialg.h

00001 #ifndef PXIALG_H__
00002 #define PXIALG_H__
00003 #include "stdint.h"
00004 
00005 
00006 #define PXIALG_API
00007 
00008 
00009 typedef enum {
00010     FLAG_DATA_READY = 0,
00011     FLAG_DATA_NOT_READY,
00012     FLAG_DATA_LOSS,
00013     FLAG_NO_TOUCH,
00014     FLAG_DATA_ERROR,
00015     FLAG_POOR_SIGNAL,
00016     FLAG_FIFO_ERROR,
00017 } PXI_STATUS_FLAG;
00018 
00019 /**
00020 * @brief When HRD and MEMS data are ready, call this function to do the algorithm processing
00021 * @param[in] HRD_Data Pointer to the buffer where HRD data (13 Bytes) is stored.
00022 * @param[in] MEMS_Data Pointer to the buffer where MEMS data (3*sizeof(float) Bytes) is stored.
00023 * @return one of the PXI_STATUS_FLAG types.
00024 */
00025 PXIALG_API int32_t PxiAlg_Process(unsigned char *HRD_Data, float *MEMS_Data);
00026 
00027 /**
00028 * @brief Call this function to get Heart Rate
00029 * @param[out] hr Pointer to a float variable where heart rate is stored
00030 * @return None
00031 */
00032 PXIALG_API void PxiAlg_HrGet(float *hr);
00033 
00034 /**
00035 * @brief Call this function to determine the version of the algorithm
00036 * @return Version of the algorithm
00037 */
00038 //Note: Recommend call PxiAlg_Version() function to get the version of the algorithm first. If return value is 1025, it means the version is 25th version. If return value is 0, it means unconnected the library.
00039 PXIALG_API int32_t PxiAlg_Version(void) ;
00040 
00041 /**
00042 * @brief Call this function to get Ready_Flag
00043 * @return Ready_Flag
00044 */
00045 PXIALG_API unsigned char PxiAlg_GetReadyFlag(void);
00046 
00047 /**
00048 * @brief Call this function to get Motion_Flag
00049 * @return Motion_Flag
00050 */
00051 PXIALG_API unsigned char PxiAlg_GetMotionFlag(void);
00052 
00053 /**
00054 * @brief Call this function to notify algorithm the MEMS Scale of Motion Sensor
00055 * @param[in] scale The MEMS Scale of Motion Sensor. Only 0(±2G), 1(±4G, ±8G, ±16G) are supported.
00056 * @return 1 for success. 0 for failure.
00057 */
00058 PXIALG_API uint8_t PxiAlg_SetMemsScale(int scale);
00059 
00060 /**
00061 * @brief Call this function to get PPG Signal Grade. High signal grade is meant high signal at steady state.
00062 * @param[out] grade Pointer to a float variable where signal grade is stored.
00063 * @return Return 1 when Signal Grade is ready. Otherwise, return 0.
00064 */
00065 PXIALG_API uint8_t PxiAlg_GetSigGrade(float *grade);
00066 
00067 /**
00068 * @brief Call this function to set PPG Signal Grade Threshold. Default Signal Grade Threshold is 40.
00069 * @param[in] threshold The PPG Signal Grade Threshold. Its value ranges from 0 to 100.
00070 * @return 1 for success. 0 for failure.
00071 */
00072 PXIALG_API uint8_t PxiAlg_SetSigGradeThrd(float thrd);
00073 
00074 /**
00075 * @brief Call this function to enable or disable fast output mode
00076 * @param[in] enable The flag of fast output mode.
00077 * @when enable fast output mode, 1st HR value is output about 6 sec.
00078 * @For getting high accuracy, please don’t move in the beginning.
00079 */
00080 PXIALG_API void PxiAlg_EnableFastOutput(uint8_t en);
00081 
00082 /**
00083 * @brief Call this function to enable or disable motion mode. Default is disable motion mode.
00084 * @param[in] enable The flag of motion mode.
00085 * @enable motion mode for whole body movement: such as running
00086 * @disable motion mode for parts body movement: such as car driving, weight lifting, slow walking, bicycling
00087 */
00088 PXIALG_API void PxiAlg_EnableMotionMode(uint8_t en);
00089 
00090 /**
00091 * @brief Call this function to enable or disable auto mode. Default is enable auto mode.
00092 * @param[in] enable The flag of auto mode.
00093 */
00094 PXIALG_API void PxiAlg_EnableAutoMode(uint8_t en);
00095 
00096 /**
00097 * @brief Call this function to open algorithm
00098 */
00099 PXIALG_API void PxiAlg_Open(void);
00100 
00101 /**
00102 * @brief Call this function to close/reset algorithm
00103 */
00104 PXIALG_API void PxiAlg_Close(void);
00105 
00106 /**
00107 * @brief Call this function to get the alarm flag of fast output
00108 * @param[out] get the alarm flag of fast output when signal is poor during 60 seconds in the beginning.
00109 * @return Return 1 when the flag is set. Otherwise, return 0.
00110 */
00111 PXIALG_API uint8_t PxiAlg_GetFastOutAlarmFlag(void);
00112 
00113 /**
00114 * @brief Call this function to enable or disable mems0 signal grade mode for factory testing
00115 * @param[in] 1 : enable. 0 : disable.
00116 */
00117 PXIALG_API void PxiAlg_EnableMEMS0SigGrade(uint8_t en);
00118 
00119 /**
00120 * @brief Call this function to get the alarm flag of signal bad
00121 * @param[out] get the alarm flag of bad signal
00122 * @return Return 1 when the flag is set. Otherwise, return 0.
00123 * @when get this flag=1, host could reset algorithm and stop heart calculation.
00124 */
00125 PXIALG_API uint8_t PxiAlg_GetSignalBadAlarm();
00126 
00127 /**
00128 * @brief Call this function to set PPG buffer pointer and size
00129 * @param[in] ppg_buffer Pointer to a float buffer where the PPG data would be stored
00130 * @param[in] size PPG buffer size
00131 * @return None
00132 */
00133 PXIALG_API void PxiAlg_SetPPGBuffer(float *ppg_buffer, int32_t size);
00134 
00135 #endif /* PXIALG_H__ */