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
Revision 19:f0675a3150c7, committed 2017-05-18
- Comitter:
- AzqDev
- Date:
- Thu May 18 15:23:40 2017 +0000
- Parent:
- 18:b85048ec91d2
- Child:
- 20:7eb08a52b954
- Commit message:
- comments
Changed in this revision
IQS62x.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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 }