You can output chars to AQM1602 with printf(). ex. lcd.printf("iter: %5.5d.\r\n", iter);

Dependents:   aqm1602 FCAS-M101V1

Revision:
3:4a1be7924c30
Parent:
2:9233e977ee6e
Child:
4:43f874a2b8e9
--- a/AQM1602.cpp	Fri Nov 06 06:29:22 2015 +0000
+++ b/AQM1602.cpp	Wed Aug 31 01:49:19 2016 +0000
@@ -32,9 +32,10 @@
 
 int AQM1602::_putc(int val)     // for printf()
 {
-    if (val == '\n') {
-        col = 0;
-        row = (row + 1) % 2;
+    if (val == '\r') {
+        this->cr();
+    } else if (val == '\n') {
+        this->lf();
     } else {
         locate(col, row);
         buf[0]= 0x40;
@@ -43,8 +44,8 @@
 
         col++;
         if (col >= 16) {
-            col = 0;
-            row = (row + 1) % 2;
+            this->cr();
+            this->lf();
         }
     }
     wait_ms(1);
@@ -157,6 +158,29 @@
     return;
 }
 
+
+void AQM1602::cr()
+{
+    row++;
+    row &= 1;
+    int _col= col;
+    for(int i= 0; i < 16; i++) {
+        locate(i, row);
+        buf[0]= 0x40;
+        buf[1]= ' ';
+        i2c.write(addr, buf, 2);
+    }
+    locate(_col, row);
+    return;
+}
+
+void AQM1602::lf()
+{
+    col = 0;
+    locate(col, row);
+    return;
+}
+
 void AQM1602::setDispFlag(bool disp, bool cursor, bool blink)
 {
     // set On/Off. b3=1, b2:Disp, b1:Cursor, b0:blink.