Add support for APDS9960 proximity sensor

6.0.0a
* Add support for APDS9960 proximity sensor (#3051)
This commit is contained in:
Theo Arends 2018-06-26 17:51:43 +02:00
parent 04e1416eaa
commit b1258477a5
3 changed files with 41 additions and 41 deletions

View File

@ -1,4 +1,5 @@
/* 6.0.0a
* Add support for APDS9960 proximity sensor (#3051)
* Add increment and decrement value to command Counter (#2838)
* Add option 0 to command Timers disarming all timers (#2962)
* Add time in minutes to rule Time#Initialized, Time#set and Time#Minute (#2669)

View File

@ -276,6 +276,7 @@
// #define USE_INA219 // Add I2C code for INA219 Low voltage and current sensor (+1k code)
// #define USE_MGS // Add I2C code for Xadow and Grove Mutichannel Gas sensor using library Multichannel_Gas_Sensor (+10k code)
#define MGS_SENSOR_ADDR 0x04 // Default Mutichannel Gas sensor i2c address
// #define USE_APDS9960 // Add I2C code for APDS9960 Proximity Sensor. Disables SHT and VEML6070 (+4k7 code)
#endif // USE_I2C
// -- SPI sensors ---------------------------------

View File

@ -1,5 +1,7 @@
/*
Copyright (c) 2017 Shawn Hymel/Sparkfun and Theo Arends. All rights reserved.
xdrv_13_apds9960.ino - Support for I2C APDS9960 Proximity Sensor for Sonoff-Tasmota
Copyright (C) 2018 Shawn Hymel/Sparkfun and Theo Arends
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@ -23,30 +25,28 @@
POSSIBILITY OF SUCH DAMAGE.
*/
//#define USE_APDS9960 // uncomment to enable the sensor
// !!!!!! turn off conflicting drivers !!!!
#if defined(USE_SHT) || defined(USE_VEML6070)
#warning I will turn off conflicting drivers (SHT and VEML6070) !!!
#undef USE_SHT // SHT-Driver blocks gesture sensor
#undef USE_VEML6070 // address conflict on the I2C-bus
#endif
#ifdef USE_I2C
#ifdef USE_APDS9960
enum GestureCommands {
CMND_GESTURE };
const char kGestureCommands[] PROGMEM =
"Gesture" ;
/*********************************************************************************************\
* APDS9960
* APDS9960 - Digital Proximity Ambient Light RGB and Gesture Sensor
*
* Source: Shawn Hymel (SparkFun Electronics)
* Adaption for TASMOTA: Christian Baars
*
* I2C Address: 0x39
\*********************************************************************************************/
#if defined(USE_SHT) || defined(USE_VEML6070)
#warning **** Turned off conflicting drivers SHT and VEML6070 ****
#ifdef USE_SHT
#undef USE_SHT // SHT-Driver blocks gesture sensor
#endif
#ifdef USE_VEML6070
#undef USE_VEML6070 // address conflict on the I2C-bus
#endif
#endif
#define APDS9960_I2C_ADDR 0x39
#define APDS9960_CHIPID_1 0xAB
@ -57,7 +57,11 @@ const char kGestureCommands[] PROGMEM =
#define GESTURE_SENSITIVITY_1 50
#define GESTURE_SENSITIVITY_2 20
enum GestureCommands {
CMND_GESTURE };
const char kGestureCommands[] PROGMEM =
"Gesture" ;
uint8_t APDS9960addr;
uint8_t APDS9960type = 0;
@ -65,7 +69,6 @@ char APDS9960stype[7];
char currentGesture[6];
bool gesture_mode = true;
volatile uint8_t recovery_loop_counter = 0; //count number of stateloops to switch the sensor off, if needed
#define APDS9960_LONG_RECOVERY 50 //long pause after sensor overload in loops
#define APDS9960_MAX_GESTURE_CYCLES 50 //how many FIFO-reads are allowed to prevent crash
@ -80,14 +83,12 @@ const char HTTP_APDS_9960_SNS[] PROGMEM = "%s"
"{s}" "Proximity" "{m}%s{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
#endif // USE_WEBSERVER
/*********************************************************************************************\
* APDS9960
*
* Programmer : APDS9960 Datasheet and Sparkfun
\*********************************************************************************************/
/* Misc parameters */
#define FIFO_PAUSE_TIME 30 // Wait period (ms) between FIFO reads
@ -253,7 +254,6 @@ enum {
APDS9960_ALL_STATE
};
/* Container for gesture data */
typedef struct gesture_data_type {
uint8_t u_data[32];
@ -275,8 +275,6 @@ typedef struct gesture_data_type {
int16_t gesture_state_ = 0;
int16_t gesture_motion_ = DIR_NONE;
/*******************************************************************************
* Helper functions
******************************************************************************/