Register display for Azoteq IQS621 ultra low power I2C multi-function sensor.

Dependents:   IQS621_HelloWorld

A library that performs a register dump of the Azoteq IQS621 ultra low power multisensor registers.

More information on the IQS621 here:

Components / IQS621
Azoteq IQS621 ultra low power sensor for ambient light, magnetic field, capacitance and inductive proximity. Empowers next-generation user interfaces.


Low Cost Evaluation Board For Azoteq IQS621ultra low power I2C sensor for ambient light, magnetic field, capacitance, inductive proximity and temperature.


Serial Terminal Output

/media/uploads/AzqDev/iqs621-1-display-i2c-ultra-low-power-sensor-for-ambient-light-capacitive-touch-magnetic-field.gif
IQS621 Register display as performed by mbed LPC1768.
Note the frame number - over half a million register dumps were performed with zero I2C errors.

Files at this revision

API Documentation at this revision

Comitter:
AzqDev
Date:
Fri May 12 23:13:19 2017 +0000
Parent:
2:f47e3cecd5b0
Child:
4:cfd35dc9976a
Commit message:
Track read and write changes in registers

Changed in this revision

IQS621DisplayTerminal.cpp Show annotated file Show diff for this revision Revisions of this file
IQS621DisplayTerminal.h Show annotated file Show diff for this revision Revisions of this file
--- a/IQS621DisplayTerminal.cpp	Sat May 06 10:30:57 2017 +0000
+++ b/IQS621DisplayTerminal.cpp	Fri May 12 23:13:19 2017 +0000
@@ -46,21 +46,45 @@
     printf("\t I2C Errors %d", I2CErrorCount);
 }
 
+    
+// dump one line of text from the buffer with VT100 color formatting    
+void IQS621Display::showLine(char * buffer, char * color, int startbyte, int endbyte) {
+  for (int i=startbyte; i<=endbyte; i++) {
+        if ( color == NULL || color[i] == 0 )
+          printf("%02x ", buffer[i]);
+        else
+        #define USE_IQS_COLOR_DISPLAY
+        #ifndef DONT_USE_IQS_COLOR_DISPLAY        
+          printf("\x1b[32m%02x\x1b[30m ", buffer[i]); // print out in green (ANSI VT100 code)
+        #else
+          printf("%02x ", buffer[i]); // print out in black & white
+        #endif
+      }
+ }
+
+
+static char checkerBoard [] = { // a byte array with alternate 0's and 1's
+0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, 
+0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, 
+0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, 
+0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, 
+};
+
 // formatted hex display of IQS621 registers
-void IQS621Display::showRegisters(char * buffer) {
-    #define ShowLine(FROM,TO) for(int j=(FROM);j<=(TO);j++)printf("%02x ",buffer[j])
-    printf("\r\n\r\n Device ID & Version (46) [00] "); ShowLine(0x00,0x02);
-    printf("\r\n\r\n         Events and Flags [10] "); ShowLine(0x10,0x1e);
-    printf("\r\n\r\n  Channels 0-6 Raw Values [20] "); ShowLine(0x20,0x2d);
-    printf("\r\n\r\n   Long Term Average Data [30] "); ShowLine(0x30,0x33);
-    printf("\r\n\r\n      Proxfusion Settings [40] "); ShowLine(0x40,0x4d);
-    printf("\r\n\r\n    Proxfusion Thresholds [50] "); ShowLine(0x50,0x54);
-    printf("\r\n\r\n   Metal Detect Threshold [60] "); ShowLine(0x60,0x63);
-    printf("\r\n\r\n   Ambient Light Settings [70] "); ShowLine(0x70,0x73);
-    printf("\r\n\r\n Ambient Light Thresholds [80] "); ShowLine(0x80,0x83);
-    printf("\r\n\r\n     Hall Sensor Settings [90] "); ShowLine(0x90,0x93);
-    printf("\r\n\r\n   Hall Switch Thresholds [A0] "); ShowLine(0xa0,0xa2);
-    printf("\r\n\r\n   Temperature Cal/Limits [C0] "); ShowLine(0xc0,0xc3);
-    printf("\r\n\r\n  Device & Power Settings [D0] "); ShowLine(0xd0,0xd7);
+void IQS621Display::showRegisters(char * buffer, char * color) {
+    
+    printf("\r\n\r\n Device ID & Version (46) [00] "); showLine(buffer,color,0x00,0x02);
+    printf("\r\n\r\n         Events and Flags [10] "); showLine(buffer,color,0x10,0x1e);
+    printf("\r\n\r\n  Channels 0-6 Raw Values [20] "); showLine(buffer,color,0x20,0x2d);
+    printf("\r\n\r\n   Long Term Average Data [30] "); showLine(buffer,color,0x30,0x33);
+    printf("\r\n\r\n      Proxfusion Settings [40] "); showLine(buffer,color,0x40,0x4d);
+    printf("\r\n\r\n    Proxfusion Thresholds [50] "); showLine(buffer,color,0x50,0x54);
+    printf("\r\n\r\n   Metal Detect Threshold [60] "); showLine(buffer,color,0x60,0x63);
+    printf("\r\n\r\n   Ambient Light Settings [70] "); showLine(buffer,color,0x70,0x73);
+    printf("\r\n\r\n Ambient Light Thresholds [80] "); showLine(buffer,color,0x80,0x83);
+    printf("\r\n\r\n     Hall Sensor Settings [90] "); showLine(buffer,color,0x90,0x93);
+    printf("\r\n\r\n   Hall Switch Thresholds [A0] "); showLine(buffer,color,0xa0,0xa2);
+    printf("\r\n\r\n   Temperature Cal/Limits [C0] "); showLine(buffer,color,0xc0,0xc3);
+    printf("\r\n\r\n  Device & Power Settings [D0] "); showLine(buffer,color,0xd0,0xd7); 
     printf("\r\n\r\n");
 }
\ No newline at end of file
--- a/IQS621DisplayTerminal.h	Sat May 06 10:30:57 2017 +0000
+++ b/IQS621DisplayTerminal.h	Fri May 12 23:13:19 2017 +0000
@@ -28,5 +28,6 @@
     IQS621Display(); // constructor
     void helloMessage(bool); // show startup message
     void showStatus(int,int); // show headings and I2C Error Count
-    void showRegisters(char *); // show IQS62x registers
+    void showLine(char *,char *,int,int); // dump a formatted line
+    void showRegisters(char * registers, char * colorArray); // dump IQS624 registers
 };
\ No newline at end of file