1
+ /* !
2
+ * @file WipperSnapper_I2C_Driver_VEML7700.h
3
+ *
4
+ * Device driver for the VEML7700 digital luminosity (light) sensor.
5
+ *
6
+ * Adafruit invests time and resources providing this open source code,
7
+ * please support Adafruit and open-source hardware by purchasing
8
+ * products from Adafruit!
9
+ *
10
+ * Copyright (c) Tyeth Gundry 2022 for Adafruit Industries.
11
+ *
12
+ * MIT license, all text here must be included in any redistribution.
13
+ *
14
+ */
15
+ #ifndef WipperSnapper_I2C_Driver_VEML7700_H
16
+ #define WipperSnapper_I2C_Driver_VEML7700_H
17
+
18
+ #include " WipperSnapper_I2C_Driver.h"
19
+ #include < Adafruit_VEML7700.h>
20
+
21
+ /* *************************************************************************/
22
+ /* !
23
+ @brief Class that provides a driver interface for a VEML7700 sensor.
24
+ */
25
+ /* *************************************************************************/
26
+ class WipperSnapper_I2C_Driver_VEML7700 : public WipperSnapper_I2C_Driver {
27
+ public:
28
+ /* ******************************************************************************/
29
+ /* !
30
+ @brief Constructor for a VEML7700 sensor.
31
+ @param i2c
32
+ The I2C interface.
33
+ @param sensorAddress
34
+ The 7-bit I2C address of the sensor.
35
+ */
36
+ /* ******************************************************************************/
37
+ WipperSnapper_I2C_Driver_VEML7700 (TwoWire *i2c, uint16_t sensorAddress)
38
+ : WipperSnapper_I2C_Driver(i2c, sensorAddress) {
39
+ _i2c = i2c;
40
+ _sensorAddress = sensorAddress;
41
+ }
42
+
43
+ /* ******************************************************************************/
44
+ /* !
45
+ @brief Destructor for an VEML7700 sensor.
46
+ */
47
+ /* ******************************************************************************/
48
+ ~WipperSnapper_I2C_Driver_VEML7700 () { delete _veml; }
49
+
50
+ /* ******************************************************************************/
51
+ /* !
52
+ @brief Initializes the VEML7700 sensor and begins I2C.
53
+ @returns True if initialized successfully, False otherwise.
54
+ */
55
+ /* ******************************************************************************/
56
+ bool begin () {
57
+ _veml = new Adafruit_VEML7700 ();
58
+ // Attempt to initialize and configure VEML7700
59
+ return _veml->begin (_i2c);
60
+ }
61
+
62
+ /* ******************************************************************************/
63
+ /* !
64
+ @brief Performs a light sensor read using the Adafruit
65
+ Unified Sensor API. Always uses VEML_LUX_AUTO,
66
+ controlling sensor integration time and gain.
67
+ @param lightEvent
68
+ Light sensor reading, in lux.
69
+ @returns True if the sensor event was obtained successfully, False
70
+ otherwise.
71
+ */
72
+ /* ******************************************************************************/
73
+ bool getEventLight (sensors_event_t *lightEvent) {
74
+ // Get sensor event populated in lux via AUTO integration and gain
75
+ lightEvent->light = _veml->readLux (VEML_LUX_AUTO);
76
+
77
+ return true ;
78
+ }
79
+
80
+ protected:
81
+ Adafruit_VEML7700 *_veml; // /< Pointer to VEML7700 light sensor object
82
+ };
83
+
84
+ #endif // WipperSnapper_I2C_Driver_VEML7700
0 commit comments