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
SH1106.h
00001 #ifndef MBED_SH1106_H 00002 #define MBED_SH1106_H 00003 00004 #include "mbed.h" 00005 #include "LCD.h" 00006 00007 /** Class for SH1106 display controller 00008 * to be copypasted and adapted for other controllers 00009 */ 00010 class SH1106 : public LCD 00011 { 00012 00013 public: 00014 00015 /** Create a PAR display interface 00016 * @param displayproto only supports PAR_8 00017 * @param port GPIO port name to use 00018 * @param CS pin connected to CS of display 00019 * @param reset pin connected to RESET of display 00020 * @param DC pin connected to data/command of display 00021 * @param WR pin connected to SDI of display 00022 * @param RD pin connected to RS of display 00023 * @param name The name used by the parent class to access the interface 00024 * @param LCDSIZE_X x size in pixel - optional 00025 * @param LCDSIZE_Y y size in pixel - optional 00026 */ 00027 SH1106(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name, unsigned int LCDSIZE_X = 128, unsigned int LCDSIZE_Y = 64); 00028 00029 /** Create an SPI display interface 00030 * @param displayproto SPI_8 or SPI_16 00031 * @param Hz SPI speed in Hz 00032 * @param mosi SPI pin 00033 * @param miso SPI pin 00034 * @param sclk SPI pin 00035 * @param CS pin connected to CS of display 00036 * @param reset pin connected to RESET of display 00037 * @param DC pin connected to data/command of display 00038 * @param name The name used by the parent class to access the interface 00039 * @param LCDSIZE_X x size in pixel - optional 00040 * @param LCDSIZE_Y y size in pixel - optional 00041 */ 00042 SH1106(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name , unsigned int LCDSIZE_X = 128, unsigned int LCDSIZE_Y = 64); 00043 00044 /** Create an I2C display interface 00045 * @param displayproto I2C_ 00046 * @param Hz I2C speed in Hz 00047 * @param address I2C address 00048 * @param sda I2C pin 00049 * @param scl I2C pin 00050 * @param reset pin connected to RESET of display 00051 * @param name The name used by the parent class to access the interface 00052 * @param LCDSIZE_X x size in pixel - optional 00053 * @param LCDSIZE_Y y size in pixel - optional 00054 */ 00055 SH1106(proto_t displayproto, int Hz, int address, PinName sda, PinName scl, PinName reset, const char* name , unsigned int LCDSIZE_X = 128, unsigned int LCDSIZE_Y = 64); 00056 00057 00058 00059 /** set the contrast of the screen 00060 * @note here overrided because of not standard value range 00061 * @param o contrast 0-255 00062 */ 00063 virtual void set_contrast(int o); 00064 00065 /** set automatc horizontal scroll mode 00066 * @param l_r direction - left = 0, right = 1 00067 * @param s_page start page 00068 * @param e_page end page 00069 * @param speed time between horizontal shift. 0 slow .. 7 fast 00070 */ 00071 00072 /** Framebuffer is used, it needs to be sent to LCD from time to time 00073 */ 00074 virtual void copy_to_lcd(); 00075 00076 /** clear the entire screen 00077 */ 00078 virtual void cls(); 00079 00080 /** Draw a pixel in the specified color. 00081 * @param x is the horizontal offset to this pixel. 00082 * @param y is the vertical offset to this pixel. 00083 * @param color defines the color for the pixel. 00084 */ 00085 virtual void pixel(int x, int y, unsigned short color); 00086 00087 /** Read pixel color at location 00088 * @param x is the horizontal offset to this pixel. 00089 * @param y is the vertical offset to this pixel. 00090 * @returns 16bit color, 0000=Black(pixel set), FFFF=White(pixel clear). 00091 */ 00092 virtual unsigned short pixelread(int x, int y); 00093 protected: 00094 00095 00096 /** Init command sequence 00097 */ 00098 void init(); 00099 00100 /** set mirror mode 00101 * @note here overriding the LCD class default one because of not standard commands 00102 * @param mode NONE, X, Y, XY 00103 */ 00104 virtual void mirrorXY(mirror_t mode); 00105 00106 }; 00107 00108 00109 #endif
Generated on Tue Jul 12 2022 18:00:35 by 1.7.2