Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: IQS624_HelloWorld Nucleo_ACM1602_I2C_DC_Angle
IQSdisplayTerminal.cpp@4:4eecf56886b9, 2017-02-08 (annotated)
- Committer:
- AzqDev
- Date:
- Wed Feb 08 00:35:53 2017 +0000
- Revision:
- 4:4eecf56886b9
- Parent:
- 3:7932615d9349
- Child:
- 5:9d903309117c
USBSerial Warning
Who changed what in which revision?
| User | Revision | Line number | New 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 | 3:7932615d9349 | 5 | // More info on IQS624 sensor IC: http://bit.ly/IQS624_info |
| AzqDev | 3:7932615d9349 | 6 | |
| AzqDev | 0:77730e5a870b | 7 | #include "IQSdisplayTerminal.h" |
| AzqDev | 0:77730e5a870b | 8 | |
| AzqDev | 2:1403d6a6af7b | 9 | // constructor |
| AzqDev | 2:1403d6a6af7b | 10 | #if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL |
| AzqDev | 2:1403d6a6af7b | 11 | IQS62xDisplay::IQS62xDisplay() : USBSerial() // use our own USB device stack |
| AzqDev | 2:1403d6a6af7b | 12 | #else |
| AzqDev | 2:1403d6a6af7b | 13 | IQS62xDisplay::IQS62xDisplay() : Serial(USBTX,USBRX) // use mbed default serial port |
| AzqDev | 2:1403d6a6af7b | 14 | #endif |
| AzqDev | 1:1c22cfb8b555 | 15 | |
| AzqDev | 2:1403d6a6af7b | 16 | { |
| AzqDev | 0:77730e5a870b | 17 | frameCounter=0; |
| AzqDev | 2:1403d6a6af7b | 18 | baud(DISPLAY_BAUD_RATE); |
| AzqDev | 0:77730e5a870b | 19 | } |
| AzqDev | 0:77730e5a870b | 20 | |
| AzqDev | 2:1403d6a6af7b | 21 | #if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL |
| AzqDev | 2:1403d6a6af7b | 22 | void IQS62xDisplay::baud(int baudRate){} |
| AzqDev | 2:1403d6a6af7b | 23 | #endif |
| AzqDev | 2:1403d6a6af7b | 24 | |
| AzqDev | 0:77730e5a870b | 25 | // display a startup message to serial port |
| AzqDev | 0:77730e5a870b | 26 | void IQS62xDisplay::helloMessage(bool waitForUser) { |
| AzqDev | 0:77730e5a870b | 27 | puts("\x1b[2J \x1b[?25l \x1b[H"); // ANSII/VT100 codes to clear screen, invisible cursor, home cursor |
| AzqDev | 0:77730e5a870b | 28 | printf(" IQS62x Register Display\r\n\r\n"); |
| AzqDev | 0:77730e5a870b | 29 | 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 | 30 | printf("Handy hint - In many terminal programs, Alt-B (break) will reset your Nucleo Board.\r\n\r\n"); |
| AzqDev | 0:77730e5a870b | 31 | printf("Press any key to continue...\r\n"); |
| AzqDev | 2:1403d6a6af7b | 32 | if ( waitForUser ) while( ! readable() ); // wait for keypress to continue |
| AzqDev | 0:77730e5a870b | 33 | puts("\x1b[2J \x1b[?25l \x1b[H"); // ANSII/VT100 codes to clear screen, invisible cursor, home cursor |
| AzqDev | 0:77730e5a870b | 34 | } |
| AzqDev | 0:77730e5a870b | 35 | |
| AzqDev | 0:77730e5a870b | 36 | // show headings and I2C error count |
| AzqDev | 0:77730e5a870b | 37 | void IQS62xDisplay::showStatus(int I2Cspeed, int I2CErrorCount) { |
| AzqDev | 0:77730e5a870b | 38 | frameCounter++; |
| AzqDev | 0:77730e5a870b | 39 | puts("\x1b[H"); // ANSI/VT100 command for cursor home |
| AzqDev | 0:77730e5a870b | 40 | printf("\t\t\t"); |
| AzqDev | 0:77730e5a870b | 41 | printf("\t IQS62x Register Display\r\n\r\n"); // heading |
| AzqDev | 0:77730e5a870b | 42 | printf("\t Frame number %06d", frameCounter); |
| AzqDev | 0:77730e5a870b | 43 | printf("\t I2C Speed %dk", I2Cspeed/1000); |
| AzqDev | 0:77730e5a870b | 44 | printf("\t I2C Errors %d", I2CErrorCount); |
| AzqDev | 0:77730e5a870b | 45 | } |
| AzqDev | 0:77730e5a870b | 46 | |
| AzqDev | 0:77730e5a870b | 47 | // formatted hex display of IQS62x registers |
| AzqDev | 0:77730e5a870b | 48 | void IQS62xDisplay::showRegisters(char * buffer) { |
| AzqDev | 0:77730e5a870b | 49 | #define ShowLine(FROM,TO) for(int j=(FROM);j<=(TO);j++)printf("%02x ",buffer[j]) |
| AzqDev | 0:77730e5a870b | 50 | printf("\r\n\r\n Device ID [00] "); ShowLine(0x00,0x0f); |
| AzqDev | 0:77730e5a870b | 51 | printf("\r\n\r\n System Flags [10] "); ShowLine(0x10,0x1f); |
| AzqDev | 0:77730e5a870b | 52 | printf("\r\n\r\n Counters [20] "); ShowLine(0x20,0x2f); |
| AzqDev | 0:77730e5a870b | 53 | printf("\r\n\r\n Averages [30] "); ShowLine(0x30,0x3f); |
| AzqDev | 0:77730e5a870b | 54 | printf("\r\n\r\n Touch Setup [40] "); ShowLine(0x40,0x4f); |
| AzqDev | 0:77730e5a870b | 55 | printf("\r\n\r\n Touch Threshold [50] "); ShowLine(0x50,0x5f); |
| AzqDev | 0:77730e5a870b | 56 | printf("\r\n\r\n Small Usr Setup [60] "); ShowLine(0x60,0x6f); |
| AzqDev | 0:77730e5a870b | 57 | printf("\r\n\r\n Hall Settings [70] "); ShowLine(0x70,0x7f); |
| AzqDev | 0:77730e5a870b | 58 | printf("\r\n\r\n Wheel Values [80] "); ShowLine(0x80,0x8f); |
| AzqDev | 0:77730e5a870b | 59 | printf("\r\n\r\n System Setup [d0] "); ShowLine(0xd0,0xdf); |
| AzqDev | 0:77730e5a870b | 60 | printf("\r\n\r\n"); |
| AzqDev | 0:77730e5a870b | 61 | } |