Skip to content

Commit 8843c05

Browse files
committed
drivers: sensor: apds9960: Setup gesture sensing configuration
Created sensor specific channels and Kconfig for gesture sensing. Signed-off-by: Thomas Lang <[email protected]>
1 parent 4fe2c5b commit 8843c05

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

drivers/sensor/apds9960/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,20 @@ config APDS9960_PPULSE_COUNT
135135
range 1 64
136136
default 8
137137

138+
config APDS9960_ENABLE_GESTURE
139+
bool "Gesture Sense"
140+
default n
141+
help
142+
Enable Gesture Sense.
143+
144+
config APDS9960_GESTURE_PROXIMITY
145+
int "Gesture Proximity Enter Threshold"
146+
range 0 255
147+
default 40
148+
149+
config APDS9960_GESTURE_DIFFERENCE
150+
int "Minimum IR diode difference for gesture"
151+
range 0 255
152+
default 5
153+
138154
endif # APDS9960

drivers/sensor/apds9960/apds9960.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <string.h>
2323
#include <zephyr/logging/log.h>
2424

25-
#include "apds9960.h"
25+
#include <zephyr/drivers/sensor/apds9960.h>
2626

2727
LOG_MODULE_REGISTER(APDS9960, CONFIG_SENSOR_LOG_LEVEL);
2828

drivers/sensor/apds9960/apds9960_trigger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
extern struct apds9960_data apds9960_driver;
1616

17-
#include <zephyr/logging/log.h>
17+
#include <zephyr/drivers/sensor/apds9960.h>
1818
LOG_MODULE_DECLARE(APDS9960, CONFIG_SENSOR_LOG_LEVEL);
1919

2020
void apds9960_work_cb(struct k_work *work)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define ZEPHYR_DRIVERS_SENSOR_APDS9960_APDS9960_H_
1010

1111
#include <zephyr/drivers/gpio.h>
12+
#include <zephyr/drivers/i2c.h>
1213

1314
#define APDS9960_ENABLE_REG 0x80
1415
#define APDS9960_ENABLE_GEN BIT(6)
@@ -227,12 +228,26 @@ struct apds9960_config {
227228
uint8_t pled_boost;
228229
};
229230

231+
/* apds9960 specific channels */
232+
enum sensor_channel_apds9960 {
233+
SENSOR_CHAN_APDS9960_GESTURE = SENSOR_CHAN_PRIV_START,
234+
};
235+
236+
enum apds9960_gesture {
237+
APDS9960_GESTURE_NONE,
238+
APDS9960_GESTURE_UP,
239+
APDS9960_GESTURE_DOWN,
240+
APDS9960_GESTURE_LEFT,
241+
APDS9960_GESTURE_RIGHT,
242+
};
243+
230244
struct apds9960_data {
231245
struct gpio_callback gpio_cb;
232246
struct k_work work;
233247
const struct device *dev;
234248
uint16_t sample_crgb[4];
235249
uint8_t pdata;
250+
enum apds9960_gesture gesture;
236251

237252
#ifdef CONFIG_APDS9960_TRIGGER
238253
sensor_trigger_handler_t p_th_handler;

0 commit comments

Comments
 (0)