Ulta Low Power I2C Multi-Sensor: Capacitive Touch, Magnetic Field & Inductive Proximity.

Dependencies:   IQS620DisplayTerminal IQS62x mbed

Fork of IQS620_HelloWorld by Azq Dev

Hello World! From Azoteq's IQS620 Ultra Low Power Multi-Sensor

This is an mbed hardware demo program for the Azoteq IQS620 ultra low power multisensor.

More details on the IQS620 (and verified mbed boards) on these component pages:

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.


/media/uploads/AzqDev/iqs620-mbed-lpc1768-azoteq-touch-magnetic-inductive-temperature-sensor.gif
IQS620 Eval Kit board Connected to mbed LPC1768 board.

Committer:
AzqDev
Date:
Thu May 04 22:19:59 2017 +0000
Revision:
0:f1f07b4c5580
IQS620 up and running

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AzqDev 0:f1f07b4c5580 1 // A class library to display Azoteq IQS620 registers on a terminal
AzqDev 0:f1f07b4c5580 2
AzqDev 0:f1f07b4c5580 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:f1f07b4c5580 4
AzqDev 0:f1f07b4c5580 5 // More info on IQS620 sensor IC: http://bit.ly/IQS620-info
AzqDev 0:f1f07b4c5580 6
AzqDev 0:f1f07b4c5580 7 // IQS620 1-minute youtube video: N.A.
AzqDev 0:f1f07b4c5580 8
AzqDev 0:f1f07b4c5580 9 #include "IQS620DisplayTerminal.h"
AzqDev 0:f1f07b4c5580 10
AzqDev 0:f1f07b4c5580 11 // constructor
AzqDev 0:f1f07b4c5580 12 #if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL
AzqDev 0:f1f07b4c5580 13 IQS620Display::IQS620Display() : USBSerial() // use our own USB device stack
AzqDev 0:f1f07b4c5580 14 #else
AzqDev 0:f1f07b4c5580 15 IQS620Display::IQS620Display() : Serial(USBTX,USBRX) // use mbed default serial port
AzqDev 0:f1f07b4c5580 16 #endif
AzqDev 0:f1f07b4c5580 17
AzqDev 0:f1f07b4c5580 18 {
AzqDev 0:f1f07b4c5580 19 frameCounter=0;
AzqDev 0:f1f07b4c5580 20 baud(DISPLAY_BAUD_RATE);
AzqDev 0:f1f07b4c5580 21 }
AzqDev 0:f1f07b4c5580 22
AzqDev 0:f1f07b4c5580 23 #if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL
AzqDev 0:f1f07b4c5580 24 void IQS620Display::baud(int baudRate){}
AzqDev 0:f1f07b4c5580 25 #endif
AzqDev 0:f1f07b4c5580 26
AzqDev 0:f1f07b4c5580 27 // display a startup message to serial port
AzqDev 0:f1f07b4c5580 28 void IQS620Display::helloMessage(bool waitForUser) {
AzqDev 0:f1f07b4c5580 29 puts("\x1b[2J \x1b[?25l \x1b[H"); // ANSII/VT100 codes to clear screen, invisible cursor, home cursor
AzqDev 0:f1f07b4c5580 30 printf(" IQS620 Register Display\r\n\r\n");
AzqDev 0:f1f07b4c5580 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:f1f07b4c5580 32 printf("Handy hint - In many terminal programs, Alt-B (break) will reset your mbed Board.\r\n\r\n");
AzqDev 0:f1f07b4c5580 33 printf("Press any key to continue...\r\n");
AzqDev 0:f1f07b4c5580 34 if ( waitForUser ) while( ! readable() ); // wait for keypress to continue
AzqDev 0:f1f07b4c5580 35 puts("\x1b[2J \x1b[?25l \x1b[H"); // ANSII/VT100 codes to clear screen, invisible cursor, home cursor
AzqDev 0:f1f07b4c5580 36 }
AzqDev 0:f1f07b4c5580 37
AzqDev 0:f1f07b4c5580 38 // show headings and I2C error count
AzqDev 0:f1f07b4c5580 39 void IQS620Display::showStatus(int I2Cspeed, int I2CErrorCount) {
AzqDev 0:f1f07b4c5580 40 frameCounter++;
AzqDev 0:f1f07b4c5580 41 puts("\x1b[H"); // ANSI/VT100 command for cursor home
AzqDev 0:f1f07b4c5580 42 printf("\t\t\t");
AzqDev 0:f1f07b4c5580 43 printf("\t IQS620 Register Display\r\n\r\n"); // heading
AzqDev 0:f1f07b4c5580 44 printf("\t Frame number %06d", frameCounter);
AzqDev 0:f1f07b4c5580 45 printf("\t I2C Speed %dk", I2Cspeed/1000);
AzqDev 0:f1f07b4c5580 46 printf("\t I2C Errors %d", I2CErrorCount);
AzqDev 0:f1f07b4c5580 47 }
AzqDev 0:f1f07b4c5580 48
AzqDev 0:f1f07b4c5580 49 // formatted hex display of IQS620 registers
AzqDev 0:f1f07b4c5580 50 void IQS620Display::showRegisters(char * buffer) {
AzqDev 0:f1f07b4c5580 51 #define ShowLine(FROM,TO) for(int j=(FROM);j<=(TO);j++)printf("%02x ",buffer[j])
AzqDev 0:f1f07b4c5580 52 printf("\r\n\r\n Device ID (41) [00] "); ShowLine(0x00,0x02);
AzqDev 0:f1f07b4c5580 53 printf("\r\n\r\n Events and Flags [10] "); ShowLine(0x10,0x1b);
AzqDev 0:f1f07b4c5580 54 printf("\r\n\r\n Channels 0-5 Raw Values [20] "); ShowLine(0x20,0x2b);
AzqDev 0:f1f07b4c5580 55 printf("\r\n\r\n Long Term Average Data [30] "); ShowLine(0x30,0x35);
AzqDev 0:f1f07b4c5580 56 printf("\r\n\r\n Proxfusion Settings #0 [40] "); ShowLine(0x40,0x4b);
AzqDev 0:f1f07b4c5580 57 printf("\r\n\r\n Proxfusion Settings #1 [50] "); ShowLine(0x50,0x57);
AzqDev 0:f1f07b4c5580 58 printf("\r\n\r\n Proxfusion Thresholds [60] "); ShowLine(0x60,0x66);
AzqDev 0:f1f07b4c5580 59 printf("\r\n\r\n SAR Thresholds [70] "); ShowLine(0x70,0x75);
AzqDev 0:f1f07b4c5580 60 printf("\r\n\r\n Metal Detect Threshold [80] "); ShowLine(0x80,0x83);
AzqDev 0:f1f07b4c5580 61 printf("\r\n\r\n Hall Sensor Settings [90] "); ShowLine(0x90,0x93);
AzqDev 0:f1f07b4c5580 62 printf("\r\n\r\n Hall Switch Thresholds [A0] "); ShowLine(0xa0,0xa5);
AzqDev 0:f1f07b4c5580 63 printf("\r\n\r\n Temperature Cal/Limits [C0] "); ShowLine(0xc0,0xc3);
AzqDev 0:f1f07b4c5580 64 printf("\r\n\r\n Device & Power Settings [D0] "); ShowLine(0xd0,0xd8);
AzqDev 0:f1f07b4c5580 65 printf("\r\n\r\n");
AzqDev 0:f1f07b4c5580 66 }