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.

Committer:
AzqDev
Date:
Fri May 12 23:13:19 2017 +0000
Revision:
3:10112b6b8d3c
Parent:
2:f47e3cecd5b0
Child:
4:cfd35dc9976a
Track read and write changes in registers

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AzqDev 0:6a124fa2a919 1 // A class library to display Azoteq IQS621 registers on a terminal
AzqDev 0:6a124fa2a919 2
AzqDev 0:6a124fa2a919 3 // 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.
AzqDev 0:6a124fa2a919 4
AzqDev 0:6a124fa2a919 5 // More info on IQS621 sensor IC: http://bit.ly/IQS621-info
AzqDev 0:6a124fa2a919 6
AzqDev 0:6a124fa2a919 7 // IQS621 1-minute youtube video: N.A.
AzqDev 0:6a124fa2a919 8
AzqDev 0:6a124fa2a919 9 #include "IQS621DisplayTerminal.h"
AzqDev 0:6a124fa2a919 10
AzqDev 0:6a124fa2a919 11 // constructor
AzqDev 0:6a124fa2a919 12 #if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL
AzqDev 0:6a124fa2a919 13 IQS621Display::IQS621Display() : USBSerial() // use our own USB device stack
AzqDev 0:6a124fa2a919 14 #else
AzqDev 0:6a124fa2a919 15 IQS621Display::IQS621Display() : Serial(USBTX,USBRX) // use mbed default serial port
AzqDev 0:6a124fa2a919 16 #endif
AzqDev 0:6a124fa2a919 17
AzqDev 0:6a124fa2a919 18 {
AzqDev 0:6a124fa2a919 19 frameCounter=0;
AzqDev 0:6a124fa2a919 20 baud(DISPLAY_BAUD_RATE);
AzqDev 0:6a124fa2a919 21 }
AzqDev 0:6a124fa2a919 22
AzqDev 0:6a124fa2a919 23 #if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL
AzqDev 0:6a124fa2a919 24 void IQS621Display::baud(int baudRate){}
AzqDev 0:6a124fa2a919 25 #endif
AzqDev 0:6a124fa2a919 26
AzqDev 0:6a124fa2a919 27 // display a startup message to serial port
AzqDev 0:6a124fa2a919 28 void IQS621Display::helloMessage(bool waitForUser) {
AzqDev 0:6a124fa2a919 29 puts("\x1b[2J \x1b[?25l \x1b[H"); // ANSII/VT100 codes to clear screen, invisible cursor, home cursor
AzqDev 0:6a124fa2a919 30 printf(" IQS621 Register Display\r\n\r\n");
AzqDev 0:6a124fa2a919 31 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");
AzqDev 0:6a124fa2a919 32 printf("Handy hint - In many terminal programs, Alt-B (break) will reset your mbed Board.\r\n\r\n");
AzqDev 0:6a124fa2a919 33 printf("Press any key to continue...\r\n");
AzqDev 0:6a124fa2a919 34 if ( waitForUser ) while( ! readable() ); // wait for keypress to continue
AzqDev 0:6a124fa2a919 35 puts("\x1b[2J \x1b[?25l \x1b[H"); // ANSII/VT100 codes to clear screen, invisible cursor, home cursor
AzqDev 0:6a124fa2a919 36 }
AzqDev 0:6a124fa2a919 37
AzqDev 0:6a124fa2a919 38 // show headings and I2C error count
AzqDev 0:6a124fa2a919 39 void IQS621Display::showStatus(int I2Cspeed, int I2CErrorCount) {
AzqDev 0:6a124fa2a919 40 frameCounter++;
AzqDev 0:6a124fa2a919 41 puts("\x1b[H"); // ANSI/VT100 command for cursor home
AzqDev 0:6a124fa2a919 42 printf("\t");
AzqDev 0:6a124fa2a919 43 printf("\t IQS621 Register Display\r\n\r\n"); // heading
AzqDev 0:6a124fa2a919 44 printf("\t Frame number %06d", frameCounter);
AzqDev 0:6a124fa2a919 45 printf("\t I2C Speed %dk", I2Cspeed/1000);
AzqDev 0:6a124fa2a919 46 printf("\t I2C Errors %d", I2CErrorCount);
AzqDev 0:6a124fa2a919 47 }
AzqDev 0:6a124fa2a919 48
AzqDev 3:10112b6b8d3c 49
AzqDev 3:10112b6b8d3c 50 // dump one line of text from the buffer with VT100 color formatting
AzqDev 3:10112b6b8d3c 51 void IQS621Display::showLine(char * buffer, char * color, int startbyte, int endbyte) {
AzqDev 3:10112b6b8d3c 52 for (int i=startbyte; i<=endbyte; i++) {
AzqDev 3:10112b6b8d3c 53 if ( color == NULL || color[i] == 0 )
AzqDev 3:10112b6b8d3c 54 printf("%02x ", buffer[i]);
AzqDev 3:10112b6b8d3c 55 else
AzqDev 3:10112b6b8d3c 56 #define USE_IQS_COLOR_DISPLAY
AzqDev 3:10112b6b8d3c 57 #ifndef DONT_USE_IQS_COLOR_DISPLAY
AzqDev 3:10112b6b8d3c 58 printf("\x1b[32m%02x\x1b[30m ", buffer[i]); // print out in green (ANSI VT100 code)
AzqDev 3:10112b6b8d3c 59 #else
AzqDev 3:10112b6b8d3c 60 printf("%02x ", buffer[i]); // print out in black & white
AzqDev 3:10112b6b8d3c 61 #endif
AzqDev 3:10112b6b8d3c 62 }
AzqDev 3:10112b6b8d3c 63 }
AzqDev 3:10112b6b8d3c 64
AzqDev 3:10112b6b8d3c 65
AzqDev 3:10112b6b8d3c 66 static char checkerBoard [] = { // a byte array with alternate 0's and 1's
AzqDev 3:10112b6b8d3c 67 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,
AzqDev 3:10112b6b8d3c 68 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,
AzqDev 3:10112b6b8d3c 69 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,
AzqDev 3:10112b6b8d3c 70 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,
AzqDev 3:10112b6b8d3c 71 };
AzqDev 3:10112b6b8d3c 72
AzqDev 0:6a124fa2a919 73 // formatted hex display of IQS621 registers
AzqDev 3:10112b6b8d3c 74 void IQS621Display::showRegisters(char * buffer, char * color) {
AzqDev 3:10112b6b8d3c 75
AzqDev 3:10112b6b8d3c 76 printf("\r\n\r\n Device ID & Version (46) [00] "); showLine(buffer,color,0x00,0x02);
AzqDev 3:10112b6b8d3c 77 printf("\r\n\r\n Events and Flags [10] "); showLine(buffer,color,0x10,0x1e);
AzqDev 3:10112b6b8d3c 78 printf("\r\n\r\n Channels 0-6 Raw Values [20] "); showLine(buffer,color,0x20,0x2d);
AzqDev 3:10112b6b8d3c 79 printf("\r\n\r\n Long Term Average Data [30] "); showLine(buffer,color,0x30,0x33);
AzqDev 3:10112b6b8d3c 80 printf("\r\n\r\n Proxfusion Settings [40] "); showLine(buffer,color,0x40,0x4d);
AzqDev 3:10112b6b8d3c 81 printf("\r\n\r\n Proxfusion Thresholds [50] "); showLine(buffer,color,0x50,0x54);
AzqDev 3:10112b6b8d3c 82 printf("\r\n\r\n Metal Detect Threshold [60] "); showLine(buffer,color,0x60,0x63);
AzqDev 3:10112b6b8d3c 83 printf("\r\n\r\n Ambient Light Settings [70] "); showLine(buffer,color,0x70,0x73);
AzqDev 3:10112b6b8d3c 84 printf("\r\n\r\n Ambient Light Thresholds [80] "); showLine(buffer,color,0x80,0x83);
AzqDev 3:10112b6b8d3c 85 printf("\r\n\r\n Hall Sensor Settings [90] "); showLine(buffer,color,0x90,0x93);
AzqDev 3:10112b6b8d3c 86 printf("\r\n\r\n Hall Switch Thresholds [A0] "); showLine(buffer,color,0xa0,0xa2);
AzqDev 3:10112b6b8d3c 87 printf("\r\n\r\n Temperature Cal/Limits [C0] "); showLine(buffer,color,0xc0,0xc3);
AzqDev 3:10112b6b8d3c 88 printf("\r\n\r\n Device & Power Settings [D0] "); showLine(buffer,color,0xd0,0xd7);
AzqDev 0:6a124fa2a919 89 printf("\r\n\r\n");
AzqDev 0:6a124fa2a919 90 }