Register Display of Azoteq IQS620 Magnetic/Touch/Inductive sensor

Dependents:   IQS620_HelloWorld

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

More information on the IQS620 here:

Components / IQS620A
Ultra low power sensor for magnetic field, capacitive touch and inductive proximity. Empowers next-generation user interfaces.

Low Cost Evaluation Board For Azoteq IQS620A ultra low power sensor for magnetic field, capacitance, inductive proximity and temperature. Empowers next-generation user interfaces.

Serial Terminal Output

/media/uploads/AzqDev/iqs620-azoteq-multi-function-sensor-mbed-library-register-display.gif

Committer:
AzqDev
Date:
Mon May 15 19:53:08 2017 +0000
Revision:
7:ce337c044c1d
Parent:
6:40277a240fb5
weblinks

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AzqDev 0:39828a1d036f 1 // A class library to display Azoteq IQS620 registers on a terminal
AzqDev 0:39828a1d036f 2
AzqDev 0:39828a1d036f 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:39828a1d036f 4
AzqDev 7:ce337c044c1d 5 // More info on IQS620 sensor IC: http://www.azoteq.com/products/proxfusion/iqs620?mbed
AzqDev 0:39828a1d036f 6
AzqDev 7:ce337c044c1d 7 // ProxFusion 5-minute YouTube video: https://youtu.be/l7tO2ra5y74
AzqDev 0:39828a1d036f 8
AzqDev 0:39828a1d036f 9 #include "IQS620DisplayTerminal.h"
AzqDev 0:39828a1d036f 10
AzqDev 0:39828a1d036f 11 // constructor
AzqDev 0:39828a1d036f 12 #if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL
AzqDev 0:39828a1d036f 13 IQS620Display::IQS620Display() : USBSerial() // use our own USB device stack
AzqDev 0:39828a1d036f 14 #else
AzqDev 0:39828a1d036f 15 IQS620Display::IQS620Display() : Serial(USBTX,USBRX) // use mbed default serial port
AzqDev 0:39828a1d036f 16 #endif
AzqDev 0:39828a1d036f 17
AzqDev 3:945b99d8bb87 18 {
AzqDev 0:39828a1d036f 19 frameCounter=0;
AzqDev 0:39828a1d036f 20 baud(DISPLAY_BAUD_RATE);
AzqDev 3:945b99d8bb87 21 }
AzqDev 0:39828a1d036f 22
AzqDev 0:39828a1d036f 23 #if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL
AzqDev 3:945b99d8bb87 24 void IQS620Display::baud(int baudRate) {}
AzqDev 0:39828a1d036f 25 #endif
AzqDev 0:39828a1d036f 26
AzqDev 0:39828a1d036f 27 // display a startup message to serial port
AzqDev 3:945b99d8bb87 28 void IQS620Display::helloMessage(bool waitForUser)
AzqDev 3:945b99d8bb87 29 {
AzqDev 0:39828a1d036f 30 puts("\x1b[2J \x1b[?25l \x1b[H"); // ANSII/VT100 codes to clear screen, invisible cursor, home cursor
AzqDev 3:945b99d8bb87 31 printf(" IQS620 Register Display\r\n\r\n");
AzqDev 0:39828a1d036f 32 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:39828a1d036f 33 printf("Handy hint - In many terminal programs, Alt-B (break) will reset your mbed Board.\r\n\r\n");
AzqDev 0:39828a1d036f 34 printf("Press any key to continue...\r\n");
AzqDev 0:39828a1d036f 35 if ( waitForUser ) while( ! readable() ); // wait for keypress to continue
AzqDev 0:39828a1d036f 36 puts("\x1b[2J \x1b[?25l \x1b[H"); // ANSII/VT100 codes to clear screen, invisible cursor, home cursor
AzqDev 0:39828a1d036f 37 }
AzqDev 0:39828a1d036f 38
AzqDev 0:39828a1d036f 39 // show headings and I2C error count
AzqDev 3:945b99d8bb87 40 void IQS620Display::showStatus(int I2Cspeed, int I2CErrorCount)
AzqDev 3:945b99d8bb87 41 {
AzqDev 0:39828a1d036f 42 frameCounter++;
AzqDev 0:39828a1d036f 43 puts("\x1b[H"); // ANSI/VT100 command for cursor home
AzqDev 3:945b99d8bb87 44 printf("\t");
AzqDev 0:39828a1d036f 45 printf("\t IQS620 Register Display\r\n\r\n"); // heading
AzqDev 0:39828a1d036f 46 printf("\t Frame number %06d", frameCounter);
AzqDev 0:39828a1d036f 47 printf("\t I2C Speed %dk", I2Cspeed/1000);
AzqDev 0:39828a1d036f 48 printf("\t I2C Errors %d", I2CErrorCount);
AzqDev 0:39828a1d036f 49 }
AzqDev 0:39828a1d036f 50
AzqDev 3:945b99d8bb87 51 // dump one line of text from the buffer with VT100 color formatting
AzqDev 3:945b99d8bb87 52 void IQS620Display::showLine(char * buffer, char * color, int startbyte, int endbyte)
AzqDev 3:945b99d8bb87 53 {
AzqDev 3:945b99d8bb87 54 for (int i=startbyte; i<=endbyte; i++) {
AzqDev 2:da8082c7476a 55 if ( color == NULL || color[i] == 0 )
AzqDev 3:945b99d8bb87 56 printf("%02x ", buffer[i]);
AzqDev 2:da8082c7476a 57 else
AzqDev 3:945b99d8bb87 58 #define USE_IQS_COLOR_DISPLAY
AzqDev 3:945b99d8bb87 59 #ifndef DONT_USE_IQS_COLOR_DISPLAY
AzqDev 3:945b99d8bb87 60 printf("\x1b[32m%02x\x1b[30m ", buffer[i]); // print out in green (ANSI VT100 code)
AzqDev 3:945b99d8bb87 61 #else
AzqDev 3:945b99d8bb87 62 printf("%02x ", buffer[i]); // print out in black & white
AzqDev 3:945b99d8bb87 63 #endif
AzqDev 3:945b99d8bb87 64 }
AzqDev 3:945b99d8bb87 65 }
AzqDev 2:da8082c7476a 66
AzqDev 2:da8082c7476a 67
AzqDev 2:da8082c7476a 68
AzqDev 2:da8082c7476a 69
AzqDev 0:39828a1d036f 70 // formatted hex display of IQS620 registers
AzqDev 2:da8082c7476a 71 // with color highlighting
AzqDev 3:945b99d8bb87 72 void IQS620Display::showRegisters(char * buffer,char * color, bool showAllRegisters)
AzqDev 3:945b99d8bb87 73 {
AzqDev 3:945b99d8bb87 74 bool d = showAllRegisters; // if true show all 16 registers per line - for debugging
AzqDev 5:2f4f4db0e46b 75 printf("\r\n\r\n Device ID (41) [00] "); showLine(buffer,color,0x00,d?0x0f:0x02);
AzqDev 5:2f4f4db0e46b 76 printf("\r\n\r\n Events and Flags [10] "); showLine(buffer,color,0x10,d?0x1f:0x1b);
AzqDev 5:2f4f4db0e46b 77 printf("\r\n\r\n Channels 0-5 Raw Values [20] "); showLine(buffer,color,0x20,d?0x2f:0x2b);
AzqDev 5:2f4f4db0e46b 78 printf("\r\n\r\n Long Term Average Data [30] "); showLine(buffer,color,0x30,d?0x3f:0x35);
AzqDev 5:2f4f4db0e46b 79 printf("\r\n\r\n Proxfusion Settings #0 [40] "); showLine(buffer,color,0x40,d?0x4f:0x4b);
AzqDev 5:2f4f4db0e46b 80 printf("\r\n\r\n Proxfusion Settings #1 [50] "); showLine(buffer,color,0x50,d?0x5f:0x57);
AzqDev 5:2f4f4db0e46b 81 printf("\r\n\r\n Proxfusion Thresholds [60] "); showLine(buffer,color,0x60,d?0x6f:0x66);
AzqDev 5:2f4f4db0e46b 82 printf("\r\n\r\n SAR Thresholds [70] "); showLine(buffer,color,0x70,d?0x7f:0x75);
AzqDev 5:2f4f4db0e46b 83 printf("\r\n\r\n Metal Detect Threshold [80] "); showLine(buffer,color,0x80,d?0x8f:0x83);
AzqDev 5:2f4f4db0e46b 84 printf("\r\n\r\n Hall Sensor Settings [90] "); showLine(buffer,color,0x90,d?0x9f:0x93);
AzqDev 6:40277a240fb5 85 printf("\r\n\r\n Hall Switch Thresholds [A0] "); showLine(buffer,color,0xa0,d?0xaf:0xa2);
AzqDev 5:2f4f4db0e46b 86 printf("\r\n\r\n Temperature Cal/Limits [C0] "); showLine(buffer,color,0xc0,d?0xcf:0xc3);
AzqDev 5:2f4f4db0e46b 87 printf("\r\n\r\n Device & Power Settings [D0] "); showLine(buffer,color,0xd0,d?0xdf:0xd8);
AzqDev 0:39828a1d036f 88 printf("\r\n\r\n");
AzqDev 0:39828a1d036f 89 }