Register display for Azoteq IQS621 ultra low power I2C multi-function sensor.
A library that performs a register dump of the Azoteq IQS621 ultra low power multisensor registers.
More information on the IQS621 here:
Serial Terminal Output
IQS621 Register display as performed by mbed LPC1768.
Note the frame number - over half a million register dumps were performed with zero I2C errors.
IQS621DisplayTerminal.cpp
- Committer:
- AzqDev
- Date:
- 2017-05-12
- Revision:
- 3:10112b6b8d3c
- Parent:
- 2:f47e3cecd5b0
- Child:
- 4:cfd35dc9976a
File content as of revision 3:10112b6b8d3c:
// A class library to display Azoteq IQS621 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 IQS621 sensor IC: http://bit.ly/IQS621-info // IQS621 1-minute youtube video: N.A. #include "IQS621DisplayTerminal.h" // constructor #if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL IQS621Display::IQS621Display() : USBSerial() // use our own USB device stack #else IQS621Display::IQS621Display() : Serial(USBTX,USBRX) // use mbed default serial port #endif { frameCounter=0; baud(DISPLAY_BAUD_RATE); } #if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL void IQS621Display::baud(int baudRate){} #endif // display a startup message to serial port void IQS621Display::helloMessage(bool waitForUser) { puts("\x1b[2J \x1b[?25l \x1b[H"); // ANSII/VT100 codes to clear screen, invisible cursor, home cursor printf(" IQS621 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 IQS621Display::showStatus(int I2Cspeed, int I2CErrorCount) { frameCounter++; puts("\x1b[H"); // ANSI/VT100 command for cursor home printf("\t"); printf("\t IQS621 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); } // 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, 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"); }