Register Display of Azoteq IQS620 Magnetic/Touch/Inductive sensor
A library that performs a register dump of the Azoteq IQS620 ultra low power multisensor registers.
More information on the IQS620 here:
Serial Terminal Output
Diff: IQS620DisplayTerminal.cpp
- Revision:
- 3:945b99d8bb87
- Parent:
- 2:da8082c7476a
- Child:
- 5:2f4f4db0e46b
diff -r da8082c7476a -r 945b99d8bb87 IQS620DisplayTerminal.cpp
--- a/IQS620DisplayTerminal.cpp Sat May 13 00:12:38 2017 +0000
+++ b/IQS620DisplayTerminal.cpp Sun May 14 19:32:03 2017 +0000
@@ -15,19 +15,20 @@
IQS620Display::IQS620Display() : 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 IQS620Display::baud(int baudRate){}
+void IQS620Display::baud(int baudRate) {}
#endif
// display a startup message to serial port
-void IQS620Display::helloMessage(bool waitForUser) {
+void IQS620Display::helloMessage(bool waitForUser)
+{
puts("\x1b[2J \x1b[?25l \x1b[H"); // ANSII/VT100 codes to clear screen, invisible cursor, home cursor
- printf(" IQS620 Register Display\r\n\r\n");
+ printf(" IQS620 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");
@@ -36,49 +37,53 @@
}
// show headings and I2C error count
-void IQS620Display::showStatus(int I2Cspeed, int I2CErrorCount) {
+void IQS620Display::showStatus(int I2Cspeed, int I2CErrorCount)
+{
frameCounter++;
puts("\x1b[H"); // ANSI/VT100 command for cursor home
- printf("\t");
+ printf("\t");
printf("\t IQS620 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 IQS620Display::showLine(char * buffer, char * color, int startbyte, int endbyte) {
- for (int i=startbyte; i<=endbyte; i++) {
+// dump one line of text from the buffer with VT100 color formatting
+void IQS620Display::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]);
+ 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
- }
- }
+#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
+ }
+}
// formatted hex display of IQS620 registers
// with color highlighting
-void IQS620Display::showRegisters(char * buffer,char * color) {
- printf("\r\n\r\n Device ID (41) [00] "); showLine(buffer,color,0x00,0x02);
- printf("\r\n\r\n Events and Flags [10] "); showLine(buffer,color,0x10,0x1b);
- printf("\r\n\r\n Channels 0-5 Raw Values [20] "); showLine(buffer,color,0x20,0x2b);
- printf("\r\n\r\n Long Term Average Data [30] "); showLine(buffer,color,0x30,0x35);
- printf("\r\n\r\n Proxfusion Settings #0 [40] "); showLine(buffer,color,0x40,0x4b);
- printf("\r\n\r\n Proxfusion Settings #1 [50] "); showLine(buffer,color,0x50,0x57);
- printf("\r\n\r\n Proxfusion Thresholds [60] "); showLine(buffer,color,0x60,0x66);
- printf("\r\n\r\n SAR Thresholds [70] "); showLine(buffer,color,0x70,0x75);
- printf("\r\n\r\n Metal Detect Threshold [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,0xa5);
- 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,0xd8);
+void IQS620Display::showRegisters(char * buffer,char * color, bool showAllRegisters)
+{
+ bool d = showAllRegisters; // if true show all 16 registers per line - for debugging
+ printf("\r\n\r\n Device ID (41) [00] "); showLine(buffer,color,0x00,d?0x02:0x0f);
+ printf("\r\n\r\n Events and Flags [10] "); showLine(buffer,color,0x10,d?0x1b:0x1f);
+ printf("\r\n\r\n Channels 0-5 Raw Values [20] "); showLine(buffer,color,0x20,d?0x2b:0x2f);
+ printf("\r\n\r\n Long Term Average Data [30] "); showLine(buffer,color,0x30,d?0x35:0x3f);
+ printf("\r\n\r\n Proxfusion Settings #0 [40] "); showLine(buffer,color,0x40,d?0x4b:0x4f);
+ printf("\r\n\r\n Proxfusion Settings #1 [50] "); showLine(buffer,color,0x50,d?0x57:0x5f);
+ printf("\r\n\r\n Proxfusion Thresholds [60] "); showLine(buffer,color,0x60,d?0x66:0x6f);
+ printf("\r\n\r\n SAR Thresholds [70] "); showLine(buffer,color,0x70,d?0x75:0x7f);
+ printf("\r\n\r\n Metal Detect Threshold [80] "); showLine(buffer,color,0x80,d?0x83:0x8f);
+ printf("\r\n\r\n Hall Sensor Settings [90] "); showLine(buffer,color,0x90,d?0x93:0x9f);
+ printf("\r\n\r\n Hall Switch Thresholds [A0] "); showLine(buffer,color,0xa0,d?0xa5:0xaf);
+ printf("\r\n\r\n Temperature Cal/Limits [C0] "); showLine(buffer,color,0xc0,d?0xc3:0xcf);
+ printf("\r\n\r\n Device & Power Settings [D0] "); showLine(buffer,color,0xd0,d?0xd8:0xdf);
printf("\r\n\r\n");
}
\ No newline at end of file