Register Display On Serial Terminal For Azoteq IQS622 Ultra Low Power (5uA) I2C Multi-Function Sensor with Light Sensor + Active (Reflective) IR + Touch + Hall Effect Sensor

Dependents:   IQS622_HelloWorld

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

More information on the IQS622 here:

Components / IQS622
Azoteq IQS622 ultra low power sensor for ambient light, active (reflective) IR, magnetic field, capacitance and inductive proximity. Empowers next-generation user interfaces.

Low Cost Evaluation Board for Azoteq IQS622 Ultra Low Power (5uA) I2C Multi-Function Sensor with Light Sensor, Active (Reflective) IR, Touch and Hall Effect Sensor

--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IQS622DisplayTerminal.cpp	Tue May 09 04:55:29 2017 +0000
@@ -0,0 +1,65 @@
+// A class library to display Azoteq IQS622 registers on a terminal
+// Copyright 2017 Azoteq. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// More info on IQS622 sensor IC:
+// IQS622 1-minute youtube video: N.A.
+#include "IQS622DisplayTerminal.h"
+// constructor
+#if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL
+IQS622Display::IQS622Display() : USBSerial() // use our own USB device stack
+IQS622Display::IQS622Display() : Serial(USBTX,USBRX) // use mbed default serial port
+    frameCounter=0;
+#if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL
+void IQS622Display::baud(int baudRate){}
+// display a startup message to serial port
+void IQS622Display::helloMessage(bool waitForUser) {
+    puts("\x1b[2J  \x1b[?25l  \x1b[H"); // ANSII/VT100 codes to clear screen, invisible cursor, home cursor
+    printf("           IQS622 Register Display\r\n\r\n"); 
+    printf("To get a smooth screen refresh effect, use a terminal program that supports ANSI/VT100 escape codes such as Tera Term.\r\n\r\n");
+    printf("Handy hint - In many terminal programs, Alt-B (break) will reset your mbed Board.\r\n\r\n");
+    printf("Press any key to continue...\r\n");
+    if ( waitForUser ) while( ! readable() ); // wait for keypress to continue
+    puts("\x1b[2J  \x1b[?25l  \x1b[H"); // ANSII/VT100 codes to clear screen, invisible cursor, home cursor
+// show headings and I2C error count
+void IQS622Display::showStatus(int I2Cspeed, int I2CErrorCount) {
+    frameCounter++;
+    puts("\x1b[H"); // ANSI/VT100 command for cursor home
+    printf("\t"); 
+    printf("\t IQS622 Register Display\r\n\r\n"); // heading
+    printf("\t Frame number %06d", frameCounter);
+    printf("\t I2C Speed %dk", I2Cspeed/1000);
+    printf("\t I2C Errors %d", I2CErrorCount);
+// formatted hex display of IQS622 registers
+void IQS622Display::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 (42) [00] "); ShowLine(0x00,0x02);
+    printf("\r\n\r\n         Events and Flags [10] "); ShowLine(0x10,0x1a);
+    printf("\r\n\r\n   Channel 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           SAR Thresholds [60] "); ShowLine(0x60,0x65);
+    printf("\r\n\r\n Light/IR Sensor Settings [70] "); ShowLine(0x70,0x74);
+    printf("\r\n\r\n     Active IR Thresholds [90] "); ShowLine(0x90,0x92);
+    printf("\r\n\r\n     Hall Sensor Settings [A0] "); ShowLine(0xa0,0xa3);
+    printf("\r\n\r\n   Hall Switch Thresholds [B0] "); ShowLine(0xb0,0xb2);
+    printf("\r\n\r\n  Device & Power Settings [D0] "); ShowLine(0xd0,0xd6);
+    printf("\r\n\r\n");
\ No newline at end of file