Azoteq IQS624 Serial Terminal Display Class

Dependents:   IQS624_HelloWorld Nucleo_ACM1602_I2C_DC_Angle

Library: IQSDisplayTerminal

Library for formatted display of IQS624 registers on a serial terminal

Screen Capture

Below is a screen capture of formatted output on a serial terminal program.
Note that over a million frames were captured with zero I2C errors. /media/uploads/AzqDev/iqs624-display-screencap-1m.gif

IQS624 Summary

Ultra low power I2C sensor for 2D Magnetic Angle, Capacitive touch and Inductive Proximity

IQS624 mbed Component Link

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


IQS624 Pinout

/media/uploads/AzqDev/iqs624-pinout-s3.gif

/media/uploads/AzqDev/iqs624-and-lpc1768-tiny.gif

IQS624 Connected to mbed LPC1768 board. The five wires are power(2), I2C(2) and RDY(1).

IQS624 Data Sheet

Azoteq IQS624 Data sheet & Evaluation Kit Information: http://bit.ly/IQS624_ds



IQS624 YouTube Link

IQS624 1-minute YouTube video: http://bit.ly/IQS624Video

Committer:
AzqDev
Date:
Mon May 15 19:35:05 2017 +0000
Revision:
15:a68c51f5d364
Parent:
14:0d885125ab78
Updated weblink

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AzqDev 0:77730e5a870b 1 // A class library to display Azoteq IQS62x registers on a terminal
AzqDev 3:7932615d9349 2
AzqDev 1:1c22cfb8b555 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 1:1c22cfb8b555 4
AzqDev 14:0d885125ab78 5 // More info on IQS624 sensor IC: http://www.azoteq.com/products/proxfusion/iqs624?mbed
AzqDev 3:7932615d9349 6
AzqDev 6:9814a972e4bf 7 // IQS624 1-minute youtube video: http://bit.ly/IQS624Video
AzqDev 5:9d903309117c 8
AzqDev 0:77730e5a870b 9 #include "IQSdisplayTerminal.h"
AzqDev 0:77730e5a870b 10
AzqDev 2:1403d6a6af7b 11 // constructor
AzqDev 2:1403d6a6af7b 12 #if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL
AzqDev 2:1403d6a6af7b 13 IQS62xDisplay::IQS62xDisplay() : USBSerial() // use our own USB device stack
AzqDev 2:1403d6a6af7b 14 #else
AzqDev 2:1403d6a6af7b 15 IQS62xDisplay::IQS62xDisplay() : Serial(USBTX,USBRX) // use mbed default serial port
AzqDev 2:1403d6a6af7b 16 #endif
AzqDev 1:1c22cfb8b555 17
AzqDev 12:75f1d9e5bf01 18 {
AzqDev 0:77730e5a870b 19 frameCounter=0;
AzqDev 2:1403d6a6af7b 20 baud(DISPLAY_BAUD_RATE);
AzqDev 12:75f1d9e5bf01 21 }
AzqDev 0:77730e5a870b 22
AzqDev 2:1403d6a6af7b 23 #if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL
AzqDev 12:75f1d9e5bf01 24 void IQS62xDisplay::baud(int baudRate) {}
AzqDev 2:1403d6a6af7b 25 #endif
AzqDev 2:1403d6a6af7b 26
AzqDev 0:77730e5a870b 27 // display a startup message to serial port
AzqDev 12:75f1d9e5bf01 28 void IQS62xDisplay::helloMessage(bool waitForUser)
AzqDev 12:75f1d9e5bf01 29 {
AzqDev 0:77730e5a870b 30 puts("\x1b[2J \x1b[?25l \x1b[H"); // ANSII/VT100 codes to clear screen, invisible cursor, home cursor
AzqDev 12:75f1d9e5bf01 31 printf(" IQS624 Register Display\r\n\r\n");
AzqDev 0:77730e5a870b 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:77730e5a870b 33 printf("Handy hint - In many terminal programs, Alt-B (break) will reset your Nucleo Board.\r\n\r\n");
AzqDev 0:77730e5a870b 34 printf("Press any key to continue...\r\n");
AzqDev 2:1403d6a6af7b 35 if ( waitForUser ) while( ! readable() ); // wait for keypress to continue
AzqDev 0:77730e5a870b 36 puts("\x1b[2J \x1b[?25l \x1b[H"); // ANSII/VT100 codes to clear screen, invisible cursor, home cursor
AzqDev 0:77730e5a870b 37 }
AzqDev 0:77730e5a870b 38
AzqDev 0:77730e5a870b 39 // show headings and I2C error count
AzqDev 12:75f1d9e5bf01 40 void IQS62xDisplay::showStatus(int I2Cspeed, int I2CErrorCount)
AzqDev 12:75f1d9e5bf01 41 {
AzqDev 0:77730e5a870b 42 frameCounter++;
AzqDev 0:77730e5a870b 43 puts("\x1b[H"); // ANSI/VT100 command for cursor home
AzqDev 13:e5cbff2da2e7 44 printf("\t");
AzqDev 9:9fed1ba5abab 45 printf("\t IQS624 Register Display\r\n\r\n"); // heading
AzqDev 0:77730e5a870b 46 printf("\t Frame number %06d", frameCounter);
AzqDev 0:77730e5a870b 47 printf("\t I2C Speed %dk", I2Cspeed/1000);
AzqDev 0:77730e5a870b 48 printf("\t I2C Errors %d", I2CErrorCount);
AzqDev 0:77730e5a870b 49 }
AzqDev 0:77730e5a870b 50
AzqDev 12:75f1d9e5bf01 51 // dump one line of text from the buffer with VT100 color formatting
AzqDev 12:75f1d9e5bf01 52 void IQS62xDisplay::showLine(char * buffer, char * color, int startbyte, int endbyte)
AzqDev 12:75f1d9e5bf01 53 {
AzqDev 12:75f1d9e5bf01 54 for (int i=startbyte; i<=endbyte; i++) {
AzqDev 10:d4f2c7c2bd82 55 if ( color == NULL || color[i] == 0 )
AzqDev 12:75f1d9e5bf01 56 printf("%02x ", buffer[i]);
AzqDev 10:d4f2c7c2bd82 57 else
AzqDev 12:75f1d9e5bf01 58 #define USE_IQS_COLOR_DISPLAY
AzqDev 12:75f1d9e5bf01 59 #ifndef DONT_USE_IQS_COLOR_DISPLAY
AzqDev 12:75f1d9e5bf01 60 printf("\x1b[32m%02x\x1b[30m ", buffer[i]); // print out in green (ANSI VT100 code)
AzqDev 12:75f1d9e5bf01 61 #else
AzqDev 12:75f1d9e5bf01 62 printf("%02x ", buffer[i]); // print out in black & white
AzqDev 12:75f1d9e5bf01 63 #endif
AzqDev 12:75f1d9e5bf01 64 }
AzqDev 12:75f1d9e5bf01 65 }
AzqDev 10:d4f2c7c2bd82 66
AzqDev 0:77730e5a870b 67 // formatted hex display of IQS62x registers
AzqDev 12:75f1d9e5bf01 68 void IQS62xDisplay::showRegisters(char * buffer, char* color, bool showAllRegisters)
AzqDev 12:75f1d9e5bf01 69 {
AzqDev 12:75f1d9e5bf01 70 bool d = showAllRegisters; // if true show all 16 registers per line
AzqDev 12:75f1d9e5bf01 71 printf("\r\n\r\n Device ID (43) [00] "); showLine(buffer,color,0x00,d?0x0f:0x02);
AzqDev 12:75f1d9e5bf01 72 printf("\r\n\r\n System Flags [10] "); showLine(buffer,color,0x10,d?0x1f:0x15);
AzqDev 12:75f1d9e5bf01 73 printf("\r\n\r\n Raw Channels 0-5 [20] "); showLine(buffer,color,0x20,d?0x2f:0x2b);
AzqDev 12:75f1d9e5bf01 74 printf("\r\n\r\n Averages [30] "); showLine(buffer,color,0x30,d?0x3f:0x33);
AzqDev 12:75f1d9e5bf01 75 printf("\r\n\r\n Touch Setup [40] "); showLine(buffer,color,0x40,d?0x4f:0x49);
AzqDev 12:75f1d9e5bf01 76 printf("\r\n\r\n Touch Thresholds [50] "); showLine(buffer,color,0x50,d?0x5f:0x54);
AzqDev 12:75f1d9e5bf01 77 printf("\r\n\r\n Hall Settings [70] "); showLine(buffer,color,0x70,d?0x7f:0x7a);
AzqDev 12:75f1d9e5bf01 78 printf("\r\n\r\n Wheel Outputs [80] "); showLine(buffer,color,0x80,d?0x8f:0x8f);
AzqDev 12:75f1d9e5bf01 79 printf("\r\n\r\n System Setup [d0] "); showLine(buffer,color,0xd0,d?0xdf:0xd6);
AzqDev 0:77730e5a870b 80 printf("\r\n\r\n");
AzqDev 0:77730e5a870b 81 }