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/

Committer:
charly
Date:
Sun May 21 20:50:09 2017 +0000
Revision:
35:b8d3f1e68000
Parent:
34:a9648877491f
buitify

Who changed what in which revision?

UserRevisionLine numberNew contents of line
charly 34:a9648877491f 1 #ifndef MBED_ST7920_H
charly 34:a9648877491f 2 #define MBED_ST7920_H
charly 34:a9648877491f 3
charly 34:a9648877491f 4 #include "mbed.h"
charly 34:a9648877491f 5 #include "LCD.h"
charly 34:a9648877491f 6
charly 34:a9648877491f 7 /** Class for ST7920 and similar display controllers
charly 35:b8d3f1e68000 8 * for Controller-details see http://www.alldatasheet.com/datasheet-pdf/pdf/326219/SITRONIX/ST7920.html
charly 34:a9648877491f 9 * to be copypasted and adapted for other controllers
charly 34:a9648877491f 10 */
charly 34:a9648877491f 11 class ST7920 : public LCD
charly 34:a9648877491f 12 {
charly 34:a9648877491f 13
charly 34:a9648877491f 14 public:
charly 34:a9648877491f 15
charly 34:a9648877491f 16 /** Create a PAR display interface
charly 34:a9648877491f 17 * @param displayproto only supports PAR_8
charly 34:a9648877491f 18 * @param port GPIO port name to use
charly 34:a9648877491f 19 * @param CS pin connected to CS of display
charly 34:a9648877491f 20 * @param reset pin connected to RESET of display
charly 34:a9648877491f 21 * @param DC pin connected to data/command of display
charly 34:a9648877491f 22 * @param WR pin connected to SDI of display
charly 34:a9648877491f 23 * @param RD pin connected to RS of display
charly 34:a9648877491f 24 * @param name The name used by the parent class to access the interface
charly 35:b8d3f1e68000 25 * @param LCDSIZE_X x size in pixel
charly 35:b8d3f1e68000 26 * @param LCDSIZE_Y y size in pixel
charly 34:a9648877491f 27 */
charly 34:a9648877491f 28 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);
charly 34:a9648877491f 29
charly 34:a9648877491f 30 /** Create a BUS display interface
charly 34:a9648877491f 31 * @param displayproto only supports BUS_8
charly 34:a9648877491f 32 * @param buspins array of PinName to group as Bus
charly 34:a9648877491f 33 * @param CS pin connected to CS of display
charly 34:a9648877491f 34 * @param reset pin connected to RESET of display
charly 34:a9648877491f 35 * @param DC pin connected to data/command of display
charly 34:a9648877491f 36 * @param WR pin connected to SDI of display
charly 34:a9648877491f 37 * @param RD pin connected to RS of display
charly 34:a9648877491f 38 * @param name The name used by the parent class to access the interface
charly 35:b8d3f1e68000 39 * @param LCDSIZE_X x size in pixel
charly 35:b8d3f1e68000 40 * @param LCDSIZE_Y y size in pixel
charly 34:a9648877491f 41 */
charly 34:a9648877491f 42 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);
charly 34:a9648877491f 43
charly 34:a9648877491f 44 /** Create an SPI display interface
charly 34:a9648877491f 45 * @param displayproto SPI_8 or SPI_16
charly 34:a9648877491f 46 * @param Hz SPI speed in Hz
charly 34:a9648877491f 47 * @param mosi SPI pin
charly 34:a9648877491f 48 * @param miso SPI pin
charly 34:a9648877491f 49 * @param sclk SPI pin
charly 34:a9648877491f 50 * @param CS pin connected to CS of display
charly 34:a9648877491f 51 * @param reset pin connected to RESET of display
charly 34:a9648877491f 52 * @param DC pin connected to data/command of display
charly 34:a9648877491f 53 * @param name The name used by the parent class to access the interface
charly 35:b8d3f1e68000 54 * @param LCDSIZE_X x size in pixel
charly 35:b8d3f1e68000 55 * @param LCDSIZE_Y y size in pixel
charly 34:a9648877491f 56 */
charly 34:a9648877491f 57 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);
charly 34:a9648877491f 58
charly 34:a9648877491f 59
charly 34:a9648877491f 60
charly 34:a9648877491f 61 protected:
charly 34:a9648877491f 62
charly 34:a9648877491f 63 //WriteInstructionRegister IR
charly 34:a9648877491f 64 void wir(unsigned char data);
charly 34:a9648877491f 65
charly 34:a9648877491f 66 //WriteDataRegister DR
charly 34:a9648877491f 67 void wdr(unsigned char data);
charly 34:a9648877491f 68
charly 34:a9648877491f 69 /** Init command sequence
charly 34:a9648877491f 70 */
charly 34:a9648877491f 71 void init();
charly 34:a9648877491f 72
charly 34:a9648877491f 73 public:
charly 34:a9648877491f 74 /** Mirror
charly 35:b8d3f1e68000 75 // not needed, not supported
charly 34:a9648877491f 76 */
charly 34:a9648877491f 77 virtual void mirrorXY(mirror_t mode);
charly 34:a9648877491f 78
charly 35:b8d3f1e68000 79 // Clear Screen
charly 34:a9648877491f 80 virtual void cls(void);
charly 34:a9648877491f 81
charly 35:b8d3f1e68000 82 //Copy screenbuffer to LCD
charly 34:a9648877491f 83 virtual void copy_to_lcd(void);
charly 34:a9648877491f 84
charly 35:b8d3f1e68000 85 //not supported by hardware
charly 34:a9648877491f 86 virtual void set_contrast(int o);
charly 34:a9648877491f 87
charly 35:b8d3f1e68000 88 //not supported by hardware
charly 34:a9648877491f 89 void invert(unsigned char o);
charly 34:a9648877491f 90
charly 35:b8d3f1e68000 91 //not supported by hardware
charly 34:a9648877491f 92 virtual void wr_grambuf(unsigned short* data, unsigned int lenght);
charly 34:a9648877491f 93
charly 35:b8d3f1e68000 94 //not supported by hardware
charly 34:a9648877491f 95 virtual void wr_gram(unsigned short data);
charly 34:a9648877491f 96
charly 35:b8d3f1e68000 97 //not supported by hardware
charly 34:a9648877491f 98 virtual void wr_gram(unsigned short data, unsigned int count);
charly 34:a9648877491f 99
charly 35:b8d3f1e68000 100 //not supported by hardware
charly 34:a9648877491f 101 virtual void wr_data16(unsigned short data);
charly 34:a9648877491f 102
charly 35:b8d3f1e68000 103 //not supported by hardware
charly 34:a9648877491f 104 virtual void wr_cmd16(unsigned short cmd);
charly 34:a9648877491f 105
charly 35:b8d3f1e68000 106 //not supported by hardware
charly 34:a9648877491f 107 virtual void wr_cmd8(unsigned char cmd);
charly 34:a9648877491f 108
charly 35:b8d3f1e68000 109 //not supported by hardware
charly 34:a9648877491f 110 virtual unsigned short rd_gram(bool convert);
charly 34:a9648877491f 111
charly 35:b8d3f1e68000 112 //not supported by hardware
charly 34:a9648877491f 113 virtual unsigned int rd_reg_data32(unsigned char reg);
charly 34:a9648877491f 114
charly 35:b8d3f1e68000 115 //not supported by hardware
charly 34:a9648877491f 116 virtual unsigned int rd_extcreg_data32(unsigned char reg, unsigned char SPIreadenablecmd);
charly 34:a9648877491f 117
charly 34:a9648877491f 118 };
charly 34:a9648877491f 119 #endif