Library to read and write Azoteq IQS6xx device registers via I2C.
Dependents: IQS620_HelloWorld IQS622_HelloWorld IQS624_HelloWorld IQS621_HelloWorld ... more
Library: IQS62x
Library to read and write Azoteq IQS6xx device registers via I2C.
Supported Devices
Handy Table of ProxFusion Device Features
ALS = Ambient Light Sensor PIR = Passive Infrared
Diff: IQS62x.cpp
- Revision:
- 19:f0675a3150c7
- Parent:
- 18:b85048ec91d2
- Child:
- 20:7eb08a52b954
diff -r b85048ec91d2 -r f0675a3150c7 IQS62x.cpp
--- a/IQS62x.cpp Tue May 16 14:23:28 2017 +0000
+++ b/IQS62x.cpp Thu May 18 15:23:40 2017 +0000
@@ -24,7 +24,7 @@
memset(lastRead, 0, I2CBufferSize); // a table to remmber what we read the previous read cycle
memset(readChanges, 0, I2CBufferSize); // a table to mark up any registers that changed since the previous read
memset(readChangesEver, 0, I2CBufferSize); // a table to mark up any registers that changed BUT never forget
- memset(writeChanges, 0, I2CBufferSize); // a table to mark up any registers that differs from what was written to it
+ memset(writeChanges, 0, I2CBufferSize); // a table to mark up any registers that differ from what was written to it
}
// write a single byte to an IQS62x register
@@ -72,11 +72,15 @@
#define PLEASE_CHECK_FOR_IQS_CHANGES 1
#ifndef DONT_CHECK_FOR_IQS_CHANGES
// this is optional but handy diagnostics
- // we build two tables:
- // writeChanges[i] is set to 1 if the register content differs from what we wrote to it
- // readChanges[i] is set to 1 if the register value differs from the previously read value
+ // we build six tables:
+ //writeFlag - a table to remmber if we wrote to a register
+ //lastWrite - a table to remember what we wrote to a register
+ //lastRead - a table to remmber what we read the previous read cycle
+ //readChanges - a table to mark up any registers that changed since the previous read
+ //readChangesEver - a table to mark up any registers that changed BUT never forget
+ //writeChanges - a table to mark up any registers that differ from what was written to it
+ if (IQSframes == 1) memcpy(lastRead, I2CBuffer,I2CBufferSize); // if this is the first frame init the history buffer
if (IQSframes < 20) memset(readChangesEver,0,I2CBufferSize); // clear this until we have had 20 full reads
- if (IQSframes == 1) memcpy(lastRead, I2CBuffer,I2CBufferSize); // if this is the first frame init the history buffer
for(int i=0; i<I2CBufferSize; i++) {
if (writeFlag[i] == 1) { // only if we previously wrote to this register we check it
if( I2CBuffer[i] != lastWrite[i] )
@@ -89,7 +93,7 @@
if (readChanges[i] > 0) readChanges[i]--; // bring it closer to zero
}
}
- memcpy(lastRead, I2CBuffer, I2CBufferSize); // preserve data for next round
+ memcpy(lastRead, I2CBuffer, I2CBufferSize); // preserve history for next round
#endif
}
IQS624
IQS620A
IQS620A-EVAL-1
IQS621
IQS621-EVAL-1
IQS622
IQS622-EVAL-1
IQS624-EVAL-1