A C12832 LCD with generic interface

Dependents:   mbed_blinky HTTPClient_HelloWorld websocketandnode xbeerx ... more

Fork of C12832 by Chris Styles

Revision:
3:468cdccff7af
Parent:
2:bdc53502af17
Child:
7:0f5a3b0f3cab
Child:
11:1d68011a277c
--- a/C12832_lcd.cpp	Thu Oct 18 20:54:09 2012 +0000
+++ b/C12832_lcd.cpp	Thu Oct 25 17:34:34 2012 +0000
@@ -13,12 +13,16 @@
  */
 
 // 13.10.12    initial design
+// 25.10.12    add autorefresh of screen
+// 25.10.12    add standart font 
+
 // optional defines :
-#define debug_lcd  1
+// #define debug_lcd  1
 
 #include "C12832_lcd.h"
 #include "mbed.h"
 #include "stdio.h"
+#include "Small_7.h"
 
 #define BPP    1       // Bits per pixel
 
@@ -166,6 +170,10 @@
     // clear and update LCD
     memset(buffer,0x00,512);  // clear display buffer
     copy_to_lcd();
+    auto_up = 1;              // switch on auto update
+    claim(stdout);           // redirekt printf to lcd
+    locate(0,0);
+    set_font((unsigned char*)Small_7);  // standart font 
 }
 
 // set one pixel in buffer
@@ -371,7 +379,7 @@
         }
         pixel(x0, y0, color);
     }
-    return;
+    if(auto_up) copy_to_lcd();
 }
 
 void C12832_LCD::rect(int x0, int y0, int x1, int y1, int color)
@@ -389,7 +397,7 @@
     if (y1 > y0) line(x1,y0,x1,y1,color);
     else line(x1,y1,x1,y0,color);
 
-    return;
+    if(auto_up) copy_to_lcd();
 }
 
 void C12832_LCD::fillrect(int x0, int y0, int x1, int y1, int color)
@@ -412,6 +420,7 @@
             pixel(l,c,color);
         }
     }
+    if(auto_up) copy_to_lcd();
 }
 
 
@@ -521,14 +530,18 @@
             pixel(draw_x7, draw_y7, color);
         }
     }
-    return;
+    if(auto_up) copy_to_lcd();
 }
 
 void C12832_LCD::fillcircle(int x, int y, int r, int color)
 {
-    int i;
+    int i,up;
+    up = auto_up;
+    auto_up = 0;   // off
     for (i = 0; i <= r; i++)
         circle(x,y,i,color);
+    auto_up = up;
+    if(auto_up) copy_to_lcd();  
 }
 
 void C12832_LCD::setmode(int mode)
@@ -568,6 +581,7 @@
         }
     } else {
         character(char_x, char_y, value);
+        if(auto_up) copy_to_lcd();
     }
     return value;
 }
@@ -619,5 +633,13 @@
     font = f;
 }
 
+void C12832_LCD::set_auto_up(unsigned int up)
+{
+    if(up ) auto_up = 1;
+}
+
+unsigned int C12832_LCD::get_auto_up(void){
+    return (auto_up);
+}