Merge pull request #8264 from Theosakamg/debug_symbol

APDS-9960 - Add Debug Chip ID And Fifo
This commit is contained in:
Theo Arends 2020-04-24 11:33:10 +02:00 committed by GitHub
commit 1ebdc818c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1425,6 +1425,10 @@ int16_t readGesture(void) {
/* Read the current FIFO level */
fifo_level = I2cRead8(APDS9960_I2C_ADDR, APDS9960_GFLVL);
#ifdef USE_DEBUG_DRIVER
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DRV: FIFO Level : %d"), fifo_level);
#endif // USE_DEBUG_DRIVER
/* If there's stuff in the FIFO, read it into our data block */
if (fifo_level > 0) {
bytes_read = wireReadDataBlock(APDS9960_GFIFO_U, (uint8_t*)fifo_data, (fifo_level * 4));
@ -1432,6 +1436,16 @@ int16_t readGesture(void) {
return APDS9960_ERROR;
}
#ifdef USE_DEBUG_DRIVER
char output[(bytes_read * 2) + 1];
char *ptr = &output[0];
for ( i = 0; i < bytes_read; i++ ) {
ptr += sprintf(ptr, "%02X", fifo_data[i]);
}
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DRV: FIFO Dump : %s"), output);
#endif // USE_DEBUG_DRIVER
/* If at least 1 set of data, sort the data into U/D/L/R */
if (bytes_read >= 4) {
for (i = 0; i < bytes_read; i += 4) {
@ -1763,6 +1777,12 @@ void APDS9960_detect(void) {
if (APDS9960type || I2cActive(APDS9960_I2C_ADDR)) { return; }
APDS9960type = I2cRead8(APDS9960_I2C_ADDR, APDS9960_ID);
#ifdef USE_DEBUG_DRIVER
// Debug new chip
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DRV: %s Chip %X"), APDS9960stype, APDS9960type);
#endif // USE_DEBUG_DRIVER
if (APDS9960type == APDS9960_CHIPID_1 || APDS9960type == APDS9960_CHIPID_2 || APDS9960type == APDS9960_CHIPID_3) {
if (APDS9960_init()) {
I2cSetActiveFound(APDS9960_I2C_ADDR, APDS9960stype);