UniGraphic-Fork for ST7920-LCD-controller and SH1106. Tested with 128x64 LCD with SPI and 128x64-OLED with IIC

Dependents:   UniGraphic-St7920-Test AfficheurUTILECO

Fork of UniGraphic by GraphicsDisplay

Fork of the UniGraphic-Library for monochrome LCDs with ST7920 controller and 128x64-IIC-OLED-Display with SH1106-Controller

/media/uploads/charly/20170522_210344.jpg

/media/uploads/charly/20180425_230623.jpg

Had to adapt LCD for following reasons:

  • Give access to screenbuffer buffer[] to parent class
  • pixel() and pixel_read() as they are hardware-dependent
  • added reset-pin to IIC-Interface

GraphicDisplay:: sends buffer to LCD when auto_update is set to true.

Testprogram for ST7920 can be found here:

https://developer.mbed.org/users/charly/code/UniGraphic-St7920-Test/

Files at this revision

API Documentation at this revision

Comitter:
dreschpe
Date:
Tue Feb 17 22:35:07 2015 +0000
Parent:
8:26757296c79d
Child:
10:668cf78ff93a
Commit message:
Add param LCDSIZE_x, LCDSIZE_Y to constructor. They are optional.

Changed in this revision

Inits/ILI9341.cpp Show annotated file Show diff for this revision Revisions of this file
Inits/ILI9341.h Show annotated file Show diff for this revision Revisions of this file
Inits/ILI9486.cpp Show annotated file Show diff for this revision Revisions of this file
Inits/ILI9486.h Show annotated file Show diff for this revision Revisions of this file
Inits/IST3020.cpp Show annotated file Show diff for this revision Revisions of this file
Inits/IST3020.h Show annotated file Show diff for this revision Revisions of this file
Inits/TFT_MIPI.cpp Show annotated file Show diff for this revision Revisions of this file
Inits/TFT_MIPI.h Show annotated file Show diff for this revision Revisions of this file
Inits/UC1608.cpp Show annotated file Show diff for this revision Revisions of this file
Inits/UC1608.h Show annotated file Show diff for this revision Revisions of this file
--- a/Inits/ILI9341.cpp	Tue Feb 17 17:54:14 2015 +0000
+++ b/Inits/ILI9341.cpp	Tue Feb 17 22:35:07 2015 +0000
@@ -10,12 +10,13 @@
 // display settings ///////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////
 
-#define LCDSIZE_X       240 // display X pixels, TFTs are usually portrait view
-#define LCDSIZE_Y       320  // display Y pixels
+// put in constructor
+//#define LCDSIZE_X       240 // display X pixels, TFTs are usually portrait view
+//#define LCDSIZE_Y       320  // display Y pixels 
 
 
 
-ILI9341::ILI9341(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name)
+ILI9341::ILI9341(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name, unsigned int LCDSIZE_X, unsigned  int LCDSIZE_Y)
     : TFT(displayproto, port, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name)
 {
     hw_reset();
@@ -26,7 +27,7 @@
     cls();
     locate(0,0); 
 }
-ILI9341::ILI9341(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name)
+ILI9341::ILI9341(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name, unsigned int LCDSIZE_X , unsigned  int LCDSIZE_Y)
     : TFT(displayproto, Hz, mosi, miso, sclk, CS, reset, DC, LCDSIZE_X, LCDSIZE_Y, name)
 {
     hw_reset(); //TFT class forwards to Protocol class
--- a/Inits/ILI9341.h	Tue Feb 17 17:54:14 2015 +0000
+++ b/Inits/ILI9341.h	Tue Feb 17 22:35:07 2015 +0000
@@ -23,8 +23,11 @@
     * @param WR pin connected to SDI of display
     * @param RD pin connected to RS of display
     * @param name The name used by the parent class to access the interface
+    * @param LCDSIZE_X x size in pixel - optional
+    * @param LCDSIZE_Y y size in pixel - optional
     */ 
-    ILI9341(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name);
+    //ILI9341(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name);
+    ILI9341(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name ,const unsigned int LCDSIZE_X = 240, unsigned  int LCDSIZE_Y = 320);
   
     /** Create an SPI display interface
     * @param displayproto only supports SPI_8
@@ -36,8 +39,11 @@
     * @param reset pin connected to RESET of display
     * @param DC pin connected to data/command of display
     * @param name The name used by the parent class to access the interface
+    * @param LCDSIZE_X x size in pixel - optional
+    * @param LCDSIZE_Y y size in pixel - optional
     */ 
-    ILI9341(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name);
+    //ILI9341(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name);
+    ILI9341(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name ,unsigned int LCDSIZE_X = 240, unsigned  int LCDSIZE_Y = 320);
   
 
   
--- a/Inits/ILI9486.cpp	Tue Feb 17 17:54:14 2015 +0000
+++ b/Inits/ILI9486.cpp	Tue Feb 17 22:35:07 2015 +0000
@@ -9,12 +9,13 @@
 // display settings ///////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////
 
-#define LCDSIZE_X       320 // display X pixels, TFTs are usually portrait view
-#define LCDSIZE_Y       480  // display Y pixels
+// put in constructor
+//#define LCDSIZE_X       320 // display X pixels, TFTs are usually portrait view
+//#define LCDSIZE_Y       480  // display Y pixels
 
 
 
-ILI9486::ILI9486(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name)
+ILI9486::ILI9486(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name , unsigned int LCDSIZE_X, unsigned  int LCDSIZE_Y)
     : TFT(displayproto, port, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name)
 {
     hw_reset();
@@ -25,7 +26,7 @@
     cls();
     locate(0,0); 
 }
-ILI9486::ILI9486(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name)
+ILI9486::ILI9486(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name, unsigned int LCDSIZE_X, unsigned  int LCDSIZE_Y)
     : TFT(displayproto, Hz, mosi, miso, sclk, CS, reset, DC, LCDSIZE_X, LCDSIZE_Y, name)
 {
     hw_reset(); //TFT class forwards to Protocol class
--- a/Inits/ILI9486.h	Tue Feb 17 17:54:14 2015 +0000
+++ b/Inits/ILI9486.h	Tue Feb 17 22:35:07 2015 +0000
@@ -23,8 +23,10 @@
     * @param WR pin connected to SDI of display
     * @param RD pin connected to RS of display
     * @param name The name used by the parent class to access the interface
+    * @param LCDSIZE_X x size in pixel - optional
+    * @param LCDSIZE_Y y size in pixel - optional
     */ 
-    ILI9486(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name);
+    ILI9486(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name, unsigned int LCDSIZE_X = 320, unsigned  int LCDSIZE_Y = 480);
   
     /** Create an SPI display interface
     * @param displayproto only supports SPI_8
@@ -36,8 +38,10 @@
     * @param reset pin connected to RESET of display
     * @param DC pin connected to data/command of display
     * @param name The name used by the parent class to access the interface
+    * @param LCDSIZE_X x size in pixel - optional
+    * @param LCDSIZE_Y y size in pixel - optional
     */ 
-    ILI9486(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name);
+    ILI9486(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name, unsigned int LCDSIZE_X = 320, unsigned  int LCDSIZE_Y= 480);
   
 
   
--- a/Inits/IST3020.cpp	Tue Feb 17 17:54:14 2015 +0000
+++ b/Inits/IST3020.cpp	Tue Feb 17 22:35:07 2015 +0000
@@ -12,12 +12,13 @@
 /////////////////////////////////////////////////////////////////////////
 #define IC_X_SEGS    256 // IST3020 SEG has range 0-255 (255-0 if ADC=1), check your datasheet, important for the orientation
 #define IC_Y_COMS    64  // IST3020 COM has range 0-63 (63-0 if SHL=1), check your datasheet, important for the orientation
-#define LCDSIZE_X       192 // display X pixels, IST3020 is advertised as 224x65 but display size could be smaller
-#define LCDSIZE_Y       64  // display Y pixels, the 65th is for accessing "icons"
+// put in constructor
+//#define LCDSIZE_X       192 // display X pixels, IST3020 is advertised as 224x65 but display size could be smaller
+//#define LCDSIZE_Y       64  // display Y pixels, the 65th is for accessing "icons"
 
 
 
-IST3020::IST3020(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name)
+IST3020::IST3020(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name, unsigned int LCDSIZE_X, unsigned  int LCDSIZE_Y)
     : LCD(displayproto, port, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, IC_X_SEGS, IC_Y_COMS, name)
 {
     hw_reset();
@@ -27,7 +28,7 @@
     set_orientation(1);
     locate(0,0);
 }
-IST3020::IST3020(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name)
+IST3020::IST3020(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name, unsigned int LCDSIZE_X, unsigned  int LCDSIZE_Y)
     : LCD(displayproto, Hz, mosi, miso, sclk, CS, reset, DC, LCDSIZE_X, LCDSIZE_Y, IC_X_SEGS, IC_Y_COMS, name)
 {
     hw_reset();
--- a/Inits/IST3020.h	Tue Feb 17 17:54:14 2015 +0000
+++ b/Inits/IST3020.h	Tue Feb 17 22:35:07 2015 +0000
@@ -23,8 +23,10 @@
     * @param WR pin connected to SDI of display
     * @param RD pin connected to RS of display
     * @param name The name used by the parent class to access the interface
+    * @param LCDSIZE_X x size in pixel - optional
+    * @param LCDSIZE_Y y size in pixel - optional
     */ 
-    IST3020(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name);
+    IST3020(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name, unsigned int LCDSIZE_X = 192, unsigned  int LCDSIZE_Y = 64);
   
     /** Create an SPI display interface
     * @param displayproto only supports SPI_8
@@ -36,8 +38,10 @@
     * @param reset pin connected to RESET of display
     * @param DC pin connected to data/command of display
     * @param name The name used by the parent class to access the interface
+    * @param LCDSIZE_X x size in pixel - optional
+    * @param LCDSIZE_Y y size in pixel - optional
     */ 
-    IST3020(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name);
+    IST3020(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name, unsigned int LCDSIZE_X = 192, unsigned  int LCDSIZE_Y = 64);
   
 
   
--- a/Inits/TFT_MIPI.cpp	Tue Feb 17 17:54:14 2015 +0000
+++ b/Inits/TFT_MIPI.cpp	Tue Feb 17 22:35:07 2015 +0000
@@ -9,12 +9,13 @@
 // display settings ///////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////
 
-#define LCDSIZE_X       320 // display X pixels, TFTs are usually portrait view
-#define LCDSIZE_Y       480  // display Y pixels
+// put in constructor
+//#define LCDSIZE_X       320 // display X pixels, TFTs are usually portrait view
+//#define LCDSIZE_Y       480  // display Y pixels
 
 
 
-TFT_MIPI::TFT_MIPI(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name)
+TFT_MIPI::TFT_MIPI(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name , unsigned int LCDSIZE_X, unsigned  int LCDSIZE_Y)
     : TFT(displayproto, port, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name)
 {
     hw_reset();
@@ -26,7 +27,7 @@
     cls();
     locate(0,0); 
 }
-TFT_MIPI::TFT_MIPI(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name)
+TFT_MIPI::TFT_MIPI(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name , unsigned int LCDSIZE_X , unsigned  int LCDSIZE_Y )
     : TFT(displayproto, Hz, mosi, miso, sclk, CS, reset, DC, LCDSIZE_X, LCDSIZE_Y, name)
 {
     hw_reset(); //TFT class forwards to Protocol class
--- a/Inits/TFT_MIPI.h	Tue Feb 17 17:54:14 2015 +0000
+++ b/Inits/TFT_MIPI.h	Tue Feb 17 22:35:07 2015 +0000
@@ -24,8 +24,10 @@
     * @param WR pin connected to SDI of display
     * @param RD pin connected to RS of display
     * @param name The name used by the parent class to access the interface
+    * @param LCDSIZE_X x size in pixel - optional
+    * @param LCDSIZE_Y y size in pixel - optional
     */ 
-    TFT_MIPI(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name);
+    TFT_MIPI(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name , unsigned int LCDSIZE_X = 320, unsigned  int LCDSIZE_Y = 480);
   
     /** Create an SPI display interface
     * @param displayproto only supports SPI_8
@@ -37,8 +39,10 @@
     * @param reset pin connected to RESET of display
     * @param DC pin connected to data/command of display
     * @param name The name used by the parent class to access the interface
+    * @param LCDSIZE_X x size in pixel - optional
+    * @param LCDSIZE_Y y size in pixel - optional
     */ 
-    TFT_MIPI(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name);
+    TFT_MIPI(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name , unsigned int LCDSIZE_X = 320, unsigned  int LCDSIZE_Y = 480);
   
 
   
--- a/Inits/UC1608.cpp	Tue Feb 17 17:54:14 2015 +0000
+++ b/Inits/UC1608.cpp	Tue Feb 17 22:35:07 2015 +0000
@@ -10,12 +10,12 @@
 /////////////////////////////////////////////////////////////////////////
 #define IC_X_SEGS    240 // UC1608 SEG has range 0-239 (239-0 if MX=1), check your datasheet, important for the orientation
 #define IC_Y_COMS    128  // UC1608 COM has range 0-127 (127-0 if MY=1), check your datasheet, important for the orientation
-#define LCDSIZE_X       240 // display X pixels
-#define LCDSIZE_Y       120  // display Y pixels, UC1608 is advertised as 240x128 but display size could be smaller
+//#define LCDSIZE_X       240 // display X pixels
+//#define LCDSIZE_Y       120  // display Y pixels, UC1608 is advertised as 240x128 but display size could be smaller
 
 
 
-UC1608::UC1608(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name)
+UC1608::UC1608(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name , unsigned int LCDSIZE_X, unsigned  int LCDSIZE_Y)
     : LCD(displayproto, port, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, IC_X_SEGS, IC_Y_COMS, name)
 {
     hw_reset();
@@ -25,7 +25,7 @@
     set_orientation(1);
     locate(0,0);
 }
-UC1608::UC1608(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name)
+UC1608::UC1608(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name, unsigned int LCDSIZE_X, unsigned  int LCDSIZE_Y)
     : LCD(displayproto, Hz, mosi, miso, sclk, CS, reset, DC, LCDSIZE_X, LCDSIZE_Y, IC_X_SEGS, IC_Y_COMS, name)
 {
     hw_reset();
--- a/Inits/UC1608.h	Tue Feb 17 17:54:14 2015 +0000
+++ b/Inits/UC1608.h	Tue Feb 17 22:35:07 2015 +0000
@@ -23,8 +23,10 @@
     * @param WR pin connected to SDI of display
     * @param RD pin connected to RS of display
     * @param name The name used by the parent class to access the interface
+    * @param LCDSIZE_X x size in pixel - optional
+    * @param LCDSIZE_Y y size in pixel - optional
     */ 
-    UC1608(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name);
+    UC1608(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name, unsigned int LCDSIZE_X = 240, unsigned  int LCDSIZE_Y = 120);
   
     /** Create an SPI display interface
     * @param displayproto only supports SPI_8
@@ -36,8 +38,10 @@
     * @param reset pin connected to RESET of display
     * @param DC pin connected to data/command of display
     * @param name The name used by the parent class to access the interface
+    * @param LCDSIZE_X x size in pixel - optional
+    * @param LCDSIZE_Y y size in pixel - optional
     */ 
-    UC1608(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name);
+    UC1608(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name , unsigned int LCDSIZE_X = 240, unsigned  int LCDSIZE_Y = 120);
   
     /** set the contrast of the screen
       * @note here overrided because of not standard command