Skip to content

Commit 6a88573

Browse files
committed
Allow reading status register
Allow reading the status register. This register is important in determining if the value of the ALS and proximity sensor is valid. Not changing the read funcionts since I assume there was a reason that the status register was not checked (performance?).
1 parent 347a7d5 commit 6a88573

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/SparkFun_APDS9960.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,23 @@ bool SparkFun_APDS9960::init()
198198
* Public methods for controlling the APDS-9960
199199
******************************************************************************/
200200

201+
/**
202+
* @brief Reads and returns the contents of the STATUS register
203+
*
204+
* @return Contents of the STATUS register. 0xFF if error.
205+
*/
206+
uint8_t SparkFun_APDS9960::getStatusRegister()
207+
{
208+
uint8_t status_value;
209+
210+
/* Read current ENABLE register */
211+
if(!wireReadDataByte(APDS9960_STATUS, status_value) ) {
212+
return ERROR;
213+
}
214+
215+
return status_value;
216+
}
217+
201218
/**
202219
* @brief Reads and returns the contents of the ENABLE register
203220
*

src/SparkFun_APDS9960.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@
9898
#define APDS9960_GEN 0b01000000
9999
#define APDS9960_GVALID 0b00000001
100100

101+
/* Status bit fields */
102+
#define APDS9960_AVALID 0b0000001
103+
#define APDS9960_PVALID 0b0000010
104+
#define APDS9960_GINT 0b0000100
105+
#define APDS9960_AINT 0b0010000
106+
#define APDS9960_PGSAT 0b0100000
107+
#define APDS9960_CPSAT 0b1000000
108+
101109
/* On/Off definitions */
102110
#define OFF 0
103111
#define ON 1

0 commit comments

Comments
 (0)