A library for AQM0802A I2C connecting LCD module.

Files at this revision

API Documentation at this revision

Comitter:
kunichiko
Date:
Wed Aug 13 13:14:21 2014 +0000
Parent:
0:414db8b8aaad
Commit message:
Replace print() with Stream's printf() method.

Changed in this revision

KuAQM0802A.cpp Show annotated file Show diff for this revision Revisions of this file
KuAQM0802A.h Show annotated file Show diff for this revision Revisions of this file
--- a/KuAQM0802A.cpp	Sun Jul 20 14:28:45 2014 +0000
+++ b/KuAQM0802A.cpp	Wed Aug 13 13:14:21 2014 +0000
@@ -50,19 +50,10 @@
 }
 
 /**
- * Print a string
+ * Print a character
  */
-void KuAQM0802A::print(const char *str) {
-    while(*str) {
-        bool last;
-        if(*(str + 1)) {
-            last = false;
-        } else {
-            last = true;
-        }
-        send(!last, true, *str);
-        str++;
-    }
+void KuAQM0802A::print_char(const int character) {
+    send(false, true, character);
 }
 
 /**
--- a/KuAQM0802A.h	Sun Jul 20 14:28:45 2014 +0000
+++ b/KuAQM0802A.h	Wed Aug 13 13:14:21 2014 +0000
@@ -6,7 +6,7 @@
 /**
  * A library for AQM0802A I2C connecting LCD.
  */
-class KuAQM0802A {
+class KuAQM0802A : public Stream {
 private:
     I2C &i2c;
 
@@ -36,10 +36,10 @@
     void locate(unsigned int x, unsigned int y);
 
     /**
-     * Print a string
-     * @param str A character string to print
+     * Print a character
+     * @param character A character to print
      */
-    void print(const char *str);
+    void print_char(const int character);
 
     /**
      * Change LCD contrast
@@ -47,6 +47,10 @@
      */
     void set_contrast(unsigned int contrast);
 
+    // for Stream implementation
+    virtual int _putc(int value) { print_char(value); return 1; };
+    virtual int _getc() { return -1; };
+    
 private:
     void send_cmd(char cmd);