si114x_algorithm.c File Reference

Configures and calculates gestures from Si1147.

License

Copyright 2018 Silicon Laboratories Inc. www.silabs.com

SPDX-License-Identifier: Zlib

The licensor of this software is Silicon Laboratories Inc.

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

Definition in file si114x_algorithm.c .

#include " si114x_algorithm.h "
#include " si114x_functions.h "
#include " si1147_i2c.h "

Macros

#define GESTURE_IRQ (IE_ALS_EVRYSAMPLE | IE_PS1_EVRYSAMPLE | IE_PS2_EVRYSAMPLE | IE_PS3_EVRYSAMPLE)
#define GESTURE_TASKLIST 0x7
#define HOVER_TASKLIST 0x1
#define LED1I 0xb
#define LED2I 0xb
#define LED3I 0xb
#define MEASRATE_FAST 320
#define MEASRATE_SLOW 32000
#define PS_HOVER_THRESHOLD 295
#define PS_THRESHOLD 275
#define SI1147_DEVICE_ID 0x47
#define UV_IRQ_EN IE_ALS_EVRYSAMPLE
#define UV_TASKLIST 0x80

Functions

static gesture_t ProcessSi1147Samples (Si114x_Sample_TypeDef *samples)
Implements the algorithm for detecting gestures on the sensor STK. Should be called with new sample data every time an interrupt is received.
static void readPSData (HANDLE si114x_handle , Si114x_Sample_TypeDef *sample)
Reads the PS measurement data from the Si1147.
int Si1147_ConfigureDetection (I2C_TypeDef *i2c, uint8_t addr, int lowpower)
Initializes and configures the Si1147 sensor.
int Si1147_Detect_Device (I2C_TypeDef *i2c, uint8_t addr)
Detects whether Si1147 is on the i2c bus.
int Si1147_GetInterruptOutputEnable (I2C_TypeDef *i2c, uint8_t addr, int *enable)
Get the enable status of the Si1147 interrupt pin.
int Si1147_MeasureUVAndObjectPresent (I2C_TypeDef *i2c, uint8_t addr, uint16_t *uvIndex, int *objectDetect)
Reads the UV measurement data and checks for object in proximity to the Si1147.
gesture_t Si1147_NewSample (I2C_TypeDef *i2c, uint8_t addr, uint32_t timestamp)
Reads new measurement data and processes a new sample. This function should be called every time an interrupt for a new sample is received.
int Si1147_SetInterruptOutputEnable (I2C_TypeDef *i2c, uint8_t addr, int enable)
Enables or disables the Si1147 interrupt pin.

Variables

static si114x_i2c_t * si114x_handle = &si114x_i2c
static si114x_i2c_t si114x_i2c

Function Documentation

static gesture_t ProcessSi1147Samples ( Si114x_Sample_TypeDef * samples )
static

Implements the algorithm for detecting gestures on the sensor STK. Should be called with new sample data every time an interrupt is received.

Parameters
[in] samples New sample data received from the sensor.
Returns
Returns the type of gesture detected (as defined by gesture_t).

Definition at line 237 of file si114x_algorithm.c .

Referenced by Si1147_NewSample() .

static void readPSData ( HANDLE si114x_handle,
Si114x_Sample_TypeDef * sample
)
static

Reads the PS measurement data from the Si1147.

Parameters
[in] si114x_handle Contains i2c peripheral information. See definition of si114x_i2c_t.
[out] sample The sample data read from the sensor.

Definition at line 187 of file si114x_algorithm.c .

References Si114xReadFromRegister() .

Referenced by Si1147_NewSample() .