A C12832 LCD with generic interface

Dependents:   mbed_blinky HTTPClient_HelloWorld websocketandnode xbeerx ... more

Fork of C12832 by Chris Styles

Files at this revision

API Documentation at this revision

Comitter:
chris
Date:
Wed Feb 05 14:25:16 2014 +0000
Parent:
15:67dfa5550b73
Child:
17:1c3011afe95d
Commit message:
removed unused code, removed MCU specific code

Changed in this revision

C12832.cpp Show annotated file Show diff for this revision Revisions of this file
C12832.h Show annotated file Show diff for this revision Revisions of this file
--- a/C12832.cpp	Thu Jan 30 17:16:04 2014 +0000
+++ b/C12832.cpp	Wed Feb 05 14:25:16 2014 +0000
@@ -28,7 +28,7 @@
 #define BPP    1       // Bits per pixel
 
 
-C12832_LCD::C12832_LCD(PinName mosi, PinName sck, PinName reset, PinName a0, PinName ncs, const char* name)
+C12832::C12832(PinName mosi, PinName sck, PinName reset, PinName a0, PinName ncs, const char* name)
     : _spi(mosi,NC,sck),_reset(reset),_A0(a0),_CS(ncs),GraphicsDisplay(name)
 {
     orientation = 1;
@@ -38,59 +38,34 @@
 }
 
 
-int C12832_LCD::width()
+int C12832::width()
 {
     if (orientation == 0 || orientation == 2) return 32;
     else return 128;
 }
 
-int C12832_LCD::height()
+int C12832::height()
 {
     if (orientation == 0 || orientation == 2) return 128;
     else return 32;
 }
 
 
-/*void C12832_LCD::set_orientation(unsigned int o)
-{
-    orientation = o;
-    switch (o) {
-        case (0):
-            wr_cmd(0xA0);
-            wr_cmd(0xC0);
-            break;
-        case (1):
-            wr_cmd(0xA0);
-            wr_cmd(0xC8);
-            break;
-        case (2):
-            wr_cmd(0xA1);
-            wr_cmd(0xC8);
-            break;
-        case (3):
-            wr_cmd(0xA1);
-            wr_cmd(0xC0);
-            break;
-    }
-}
-
-*/
-
-void C12832_LCD::invert(unsigned int o)
+void C12832::invert(unsigned int o)
 {
     if(o == 0) wr_cmd(0xA6);
     else wr_cmd(0xA7);
 }
 
 
-void C12832_LCD::set_contrast(unsigned int o)
+void C12832::set_contrast(unsigned int o)
 {
     contrast = o;
     wr_cmd(0x81);      //  set volume
     wr_cmd(o & 0x3F);
 }
 
-unsigned int C12832_LCD::get_contrast(void)
+unsigned int C12832::get_contrast(void)
 {
     return(contrast);
 }
@@ -98,7 +73,7 @@
 
 // write command to lcd controller
 
-void C12832_LCD::wr_cmd(unsigned char cmd)
+void C12832::wr_cmd(unsigned char cmd)
 {
     _A0 = 0;
     _CS = 0;
@@ -108,7 +83,7 @@
 
 // write data to lcd controller
 
-void C12832_LCD::wr_dat(unsigned char dat)
+void C12832::wr_dat(unsigned char dat)
 {
     _A0 = 1;
     _CS = 0;
@@ -118,7 +93,7 @@
 
 // reset and init the lcd controller
 
-void C12832_LCD::lcd_reset()
+void C12832::lcd_reset()
 {
 
     _spi.format(8,3);                 // 8 bit spi mode 3
@@ -162,7 +137,7 @@
 
 // set one pixel in buffer
 
-void C12832_LCD::pixel(int x, int y, int color)
+void C12832::pixel(int x, int y, int color)
 {
     // first check parameter
     if(x > 128 || y > 32 || x < 0 || y < 0) return;
@@ -180,7 +155,7 @@
 
 // update lcd
 
-void C12832_LCD::copy_to_lcd(void)
+void C12832::copy_to_lcd(void)
 {
     
     int i=0;
@@ -226,14 +201,14 @@
 
 }
 
-void C12832_LCD::cls(void)
+void C12832::cls(void)
 {
     memset(buffer,0x00,512);  // clear display buffer
     copy_to_lcd();
 }
 
 
-void C12832_LCD::line(int x0, int y0, int x1, int y1, int color)
+void C12832::line(int x0, int y0, int x1, int y1, int color)
 {
     int   dx = 0, dy = 0;
     int   dx_sym = 0, dy_sym = 0;
@@ -303,7 +278,7 @@
     if(auto_up) copy_to_lcd();
 }
 
-void C12832_LCD::rect(int x0, int y0, int x1, int y1, int color)
+void C12832::rect(int x0, int y0, int x1, int y1, int color)
 {
 
     if (x1 > x0) line(x0,y0,x1,y0,color);
@@ -321,7 +296,7 @@
     if(auto_up) copy_to_lcd();
 }
 
-void C12832_LCD::fillrect(int x0, int y0, int x1, int y1, int color)
+void C12832::fillrect(int x0, int y0, int x1, int y1, int color)
 {
     int l,c,i;
     if(x0 > x1) {
@@ -346,7 +321,7 @@
 
 
 
-void C12832_LCD::circle(int x0, int y0, int r, int color)
+void C12832::circle(int x0, int y0, int r, int color)
 {
 
     int draw_x0, draw_y0;
@@ -454,7 +429,7 @@
     if(auto_up) copy_to_lcd();
 }
 
-void C12832_LCD::fillcircle(int x, int y, int r, int color)
+void C12832::fillcircle(int x, int y, int r, int color)
 {
     int i,up;
     up = auto_up;
@@ -465,12 +440,12 @@
     if(auto_up) copy_to_lcd();
 }
 
-void C12832_LCD::setmode(int mode)
+void C12832::setmode(int mode)
 {
     draw_mode = mode;
 }
 
-void C12832_LCD::locate(int x, int y)
+void C12832::locate(int x, int y)
 {
     char_x = x;
     char_y = y;
@@ -478,21 +453,21 @@
 
 
 
-int C12832_LCD::columns()
+int C12832::columns()
 {
     return width() / font[1];
 }
 
 
 
-int C12832_LCD::rows()
+int C12832::rows()
 {
     return height() / font[2];
 }
 
 
 
-int C12832_LCD::_putc(int value)
+int C12832::_putc(int value)
 {
     if (value == '\n') {    // new line
         char_x = 0;
@@ -507,7 +482,7 @@
     return value;
 }
 
-void C12832_LCD::character(int x, int y, int c)
+void C12832::character(int x, int y, int c)
 {
     unsigned int hor,vert,offset,bpl,j,i,b;
     unsigned char* zeichen;
@@ -549,23 +524,23 @@
 }
 
 
-void C12832_LCD::set_font(unsigned char* f)
+void C12832::set_font(unsigned char* f)
 {
     font = f;
 }
 
-void C12832_LCD::set_auto_up(unsigned int up)
+void C12832::set_auto_up(unsigned int up)
 {
     if(up ) auto_up = 1;
     else auto_up = 0;
 }
 
-unsigned int C12832_LCD::get_auto_up(void)
+unsigned int C12832::get_auto_up(void)
 {
     return (auto_up);
 }
 
-void C12832_LCD::print_bm(Bitmap bm, int x, int y)
+void C12832::print_bm(Bitmap bm, int x, int y)
 {
     int h,v,b;
     char d;
--- a/C12832.h	Thu Jan 30 17:16:04 2014 +0000
+++ b/C12832.h	Wed Feb 05 14:25:16 2014 +0000
@@ -50,14 +50,14 @@
     char* data;
     };
 
-class C12832_LCD : public GraphicsDisplay
+class C12832 : public GraphicsDisplay
 {
 public:
-    /** Create a C12832_LCD object connected to SPI1
+    /** Create a C12832 object connected to SPI1
       *
       */
 
-    C12832_LCD(PinName mosi, PinName sck, PinName reset, PinName a0, PinName ncs, const char* name = "LCD");
+    C12832(PinName mosi, PinName sck, PinName reset, PinName a0, PinName ncs, const char* name = "LCD");
 
 
     /** Get the width of the screen in pixel
@@ -140,12 +140,6 @@
       *
       */
 
-    //void set_orientation(unsigned int o);
-
-    /** set the contrast of the screen
-      *
-      * @param o contrast 0-63
-      */
 
     void set_contrast(unsigned int o);
 
@@ -155,7 +149,6 @@
     unsigned int get_contrast(void);
 
 
-
     /** invert the screen
       *
       * @param o = 0 normal, 1 invert