Initial version for Modtronix LCD2S I2C and SPI serial LCD displays. For details, see http://modtronix.com/products-serial-lcd-board/

Revision:
2:fe0c1e27f362
Parent:
1:429b7d3f7b95
--- a/lcd2s.cpp	Tue Aug 04 18:54:37 2015 +1000
+++ b/lcd2s.cpp	Fri Aug 07 18:27:11 2015 +1000
@@ -21,6 +21,7 @@
 #include "mbed.h"
 #include "lcd2s.h"
 
+
 // DEFINES ////////////////////////////////////////////////////////////////////
 
 
@@ -33,6 +34,30 @@
 // Function Prototypes ////////////////////////////////////////////////////////
 
 
+// DEBUG ////////////////////////////////////////////////////////////////////
+//IMPORTANT, when enabling debugging, it is very important to note the following:
+//- If (MX_DEBUG_IS_POINTER==1), ensure there is global Stream pointer defined somewhere in code to override "pMxDebug = NULL" below!
+//- If (MX_DEBUG_IS_POINTER==0), define a mxDebug() function somewhere in code to handel debug output
+#define DEBUG_ENABLE            1
+#if (DEBUG_ENABLE==1) && !defined(NDEBUG)
+//Alternative method in stead of using NULL below. This requires to create derived Stream class in each file we want to use debugging
+//    class modtronixDebugStream : public Stream {int _putc(int value) {return 0;}int _getc() {return 0;}};
+//    static modtronixDebugStream modtronixDebug;
+//    WEAK Stream* pMxDebug = &modtronixDebug;
+    #if (MX_DEBUG_IS_POINTER==1)        //More efficient, but only works if pMxDebug is defined in code. Disabled by default!
+        WEAK Stream* pMxDebug = NULL;
+        #define MX_DEBUG  pMxDebug->printf
+    #else
+        WEAK void mxDebug(const char *format, ...) {}
+        #define MX_DEBUG mxDebug
+    #endif
+#else
+    //GCC's CPP has extensions; it allows for macros with a variable number of arguments. We use this extension here to preprocess pmesg away.
+    #define MX_DEBUG(format, args...) ((void)0)
+#endif
+
+
+
 LCD2S::LCD2S(uint8_t rows/* = 4*/, uint8_t columns/* = 20*/) {
     contrast = 200;
     brightness = 200;
@@ -41,6 +66,8 @@
     bufSize = rows * columns;
     cursor_row = cursor_col = 0;
 
+    //MX_DEBUG("\r\nLCD2S()");
+
 #if (LCD2S_USE_MALLOC == 1)
     buf = new uint8_t[bufSize)];
     dirtyRows = new uint32_t(rows);