Azoteq / IQSDisplayTerminal

Dependents:   IQS624_HelloWorld Nucleo_ACM1602_I2C_DC_Angle

Files at this revision

API Documentation at this revision

Comitter:
AzqDev
Date:
Tue Feb 07 22:36:01 2017 +0000
Parent:
1:1c22cfb8b555
Child:
3:7932615d9349
Commit message:
Tested for Teensy 3.1 and Teensy 3.2; Added USBDevice library for boards with supported USB peripheral (e.g. Teensy)

Changed in this revision

IQSdisplayTerminal.cpp Show annotated file Show diff for this revision Revisions of this file
IQSdisplayTerminal.h Show annotated file Show diff for this revision Revisions of this file
--- a/IQSdisplayTerminal.cpp	Mon Feb 06 05:37:35 2017 +0000
+++ b/IQSdisplayTerminal.cpp	Tue Feb 07 22:36:01 2017 +0000
@@ -3,15 +3,22 @@
 
 #include "IQSdisplayTerminal.h"
 
+// constructor
+#if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL
+IQS62xDisplay::IQS62xDisplay() : USBSerial() // use our own USB device stack
+#else
+IQS62xDisplay::IQS62xDisplay() : Serial(USBTX,USBRX) // use mbed default serial port
+#endif
 
-// constructor
-IQS62xDisplay::IQS62xDisplay() : 
-    pc( USBTX, USBRX ) // first we run the constructor for the Serial port class
-{
+{    
     frameCounter=0;
-    pc.baud(DISPLAY_BAUD_RATE);
+    baud(DISPLAY_BAUD_RATE);
 }    
 
+#if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL
+void IQS62xDisplay::baud(int baudRate){}
+#endif
+
 // display a startup message to serial port
 void IQS62xDisplay::helloMessage(bool waitForUser) {
     puts("\x1b[2J  \x1b[?25l  \x1b[H"); // ANSII/VT100 codes to clear screen, invisible cursor, home cursor
@@ -19,7 +26,7 @@
     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 Nucleo Board.\r\n\r\n");
     printf("Press any key to continue...\r\n");
-    if ( waitForUser ) while( ! pc.readable() ); // wait for keypress to continue
+    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
 }
 
--- a/IQSdisplayTerminal.h	Mon Feb 06 05:37:35 2017 +0000
+++ b/IQSdisplayTerminal.h	Tue Feb 07 22:36:01 2017 +0000
@@ -1,9 +1,20 @@
 // A class library to display Azoteq IQS62x registers on a terminal
 #include "mbed.h"
+
 #define DISPLAY_BAUD_RATE 115200 /* baud rate of serial terminal */
-class IQS62xDisplay { // formatted display of IQS62x registers on a serial terminal
+
+#if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL
+#include "USBSerial.h"
+#endif
+
+#if defined(TARGET_TEENSY3_1) || defined (TARGET_TEENSY3_2) || IQS_USE_USBSERIAL
+class IQS62xDisplay : public USBSerial { // use our own USB serial port (requires USB driver to be installed, see Teensy Website)
+    public: void baud(int baudRate);
+#else
+class IQS62xDisplay : public Serial { // use ARM mbed virtual serial port
+#endif
+
   public:
-    Serial pc; // serial interface
     int frameCounter;
     IQS62xDisplay(); // constructor
     void helloMessage(bool); // show startup message