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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ST7920.h Source File

ST7920.h

00001 #ifndef MBED_ST7920_H
00002 #define MBED_ST7920_H
00003 
00004 #include "mbed.h"
00005 #include "LCD.h"
00006 
00007 /** Class for ST7920 and similar display controllers
00008 * for Controller-details see http://www.alldatasheet.com/datasheet-pdf/pdf/326219/SITRONIX/ST7920.html
00009 * to be copypasted and adapted for other controllers
00010 */
00011 class ST7920 : public LCD
00012 {
00013 
00014 public:
00015 
00016     /** Create a PAR display interface
00017     * @param displayproto only supports PAR_8
00018     * @param port GPIO port name to use
00019     * @param CS pin connected to CS of display
00020     * @param reset pin connected to RESET of display
00021     * @param DC pin connected to data/command of display
00022     * @param WR pin connected to SDI of display
00023     * @param RD pin connected to RS of display
00024     * @param name The name used by the parent class to access the interface
00025     * @param LCDSIZE_X x size in pixel 
00026     * @param LCDSIZE_Y y size in pixel 
00027     */
00028     ST7920(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name, unsigned int LCDSIZE_X = 132, unsigned  int LCDSIZE_Y = 64);
00029 
00030     /** Create a BUS display interface
00031     * @param displayproto only supports BUS_8
00032     * @param buspins array of PinName to group as Bus
00033     * @param CS pin connected to CS of display
00034     * @param reset pin connected to RESET of display
00035     * @param DC pin connected to data/command of display
00036     * @param WR pin connected to SDI of display
00037     * @param RD pin connected to RS of display
00038     * @param name The name used by the parent class to access the interface
00039     * @param LCDSIZE_X x size in pixel 
00040     * @param LCDSIZE_Y y size in pixel 
00041     */
00042     ST7920(proto_t displayproto, PinName* buspins, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name, unsigned int LCDSIZE_X = 132, unsigned  int LCDSIZE_Y = 64);
00043 
00044     /** Create an SPI display interface
00045     * @param displayproto SPI_8 or SPI_16
00046     * @param Hz SPI speed in Hz
00047     * @param mosi SPI pin
00048     * @param miso SPI pin
00049     * @param sclk SPI pin
00050     * @param CS pin connected to CS of display
00051     * @param reset pin connected to RESET of display
00052     * @param DC pin connected to data/command of display
00053     * @param name The name used by the parent class to access the interface
00054     * @param LCDSIZE_X x size in pixel 
00055     * @param LCDSIZE_Y y size in pixel 
00056     */
00057     ST7920(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name, unsigned int LCDSIZE_X = 132, unsigned  int LCDSIZE_Y = 64);
00058 
00059 
00060 
00061 protected:
00062 
00063     //WriteInstructionRegister IR
00064     void wir(unsigned char data);
00065 
00066     //WriteDataRegister DR
00067     void wdr(unsigned char data);
00068 
00069     /** Init command sequence
00070     */
00071     void init();
00072 
00073 public:
00074     /** Mirror
00075     // not needed, not supported
00076     */
00077     virtual void mirrorXY(mirror_t mode);
00078 
00079     // Clear Screen
00080     virtual void cls(void);
00081 
00082     //Copy screenbuffer to LCD
00083     virtual void copy_to_lcd(void);
00084     
00085     //not supported by hardware
00086     virtual void set_contrast(int o);
00087     
00088     //not supported by hardware
00089     void invert(unsigned char o);
00090     
00091     //not supported by hardware
00092     virtual void wr_grambuf(unsigned short* data, unsigned int lenght);
00093     
00094     //not supported by hardware
00095     virtual void wr_gram(unsigned short data);
00096     
00097     //not supported by hardware
00098     virtual void wr_gram(unsigned short data, unsigned int count);
00099     
00100     //not supported by hardware
00101     virtual void wr_data16(unsigned short data);
00102     
00103     //not supported by hardware
00104     virtual void wr_cmd16(unsigned short cmd);
00105     
00106     //not supported by hardware
00107     virtual void wr_cmd8(unsigned char cmd);
00108     
00109     //not supported by hardware
00110     virtual unsigned short rd_gram(bool convert);
00111     
00112     //not supported by hardware
00113     virtual unsigned int rd_reg_data32(unsigned char reg);
00114     
00115     //not supported by hardware
00116     virtual unsigned int rd_extcreg_data32(unsigned char reg, unsigned char SPIreadenablecmd);
00117 
00118 };
00119 #endif