Basically i glued Peter Drescher and Simon Ford libs in a GraphicsDisplay class, then derived TFT or LCD class (which inherits Protocols class), then the most derived ones (Inits), which are per-display and are the only part needed to be adapted to diff hw.

Dependents:   Brew

Committer:
dreschpe
Date:
Mon Feb 06 12:29:33 2017 +0000
Revision:
33:f87f06292637
Parent:
19:1bdfb971b2c1
Add I2C protocol. ; Add SSD1306 i2C modus

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dreschpe 12:9c8f3076347c 1 #ifndef MBED_SSD1306_H
dreschpe 12:9c8f3076347c 2 #define MBED_SSD1306_H
dreschpe 12:9c8f3076347c 3
dreschpe 12:9c8f3076347c 4 #include "mbed.h"
dreschpe 12:9c8f3076347c 5 #include "LCD.h"
dreschpe 12:9c8f3076347c 6
dreschpe 14:29bab588ba75 7 /** Class for SSD1306 display controller
dreschpe 12:9c8f3076347c 8 * to be copypasted and adapted for other controllers
dreschpe 12:9c8f3076347c 9 */
dreschpe 12:9c8f3076347c 10 class SSD1306 : public LCD
dreschpe 12:9c8f3076347c 11 {
dreschpe 12:9c8f3076347c 12
dreschpe 12:9c8f3076347c 13 public:
dreschpe 12:9c8f3076347c 14
dreschpe 12:9c8f3076347c 15 /** Create a PAR display interface
dreschpe 12:9c8f3076347c 16 * @param displayproto only supports PAR_8
dreschpe 12:9c8f3076347c 17 * @param port GPIO port name to use
dreschpe 12:9c8f3076347c 18 * @param CS pin connected to CS of display
dreschpe 12:9c8f3076347c 19 * @param reset pin connected to RESET of display
dreschpe 12:9c8f3076347c 20 * @param DC pin connected to data/command of display
dreschpe 12:9c8f3076347c 21 * @param WR pin connected to SDI of display
dreschpe 12:9c8f3076347c 22 * @param RD pin connected to RS of display
dreschpe 12:9c8f3076347c 23 * @param name The name used by the parent class to access the interface
dreschpe 12:9c8f3076347c 24 * @param LCDSIZE_X x size in pixel - optional
dreschpe 12:9c8f3076347c 25 * @param LCDSIZE_Y y size in pixel - optional
dreschpe 12:9c8f3076347c 26 */
dreschpe 12:9c8f3076347c 27 SSD1306(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);
dreschpe 12:9c8f3076347c 28
dreschpe 12:9c8f3076347c 29 /** Create an SPI display interface
Geremia 18:ffa58f1a680a 30 * @param displayproto SPI_8 or SPI_16
dreschpe 12:9c8f3076347c 31 * @param Hz SPI speed in Hz
dreschpe 12:9c8f3076347c 32 * @param mosi SPI pin
dreschpe 12:9c8f3076347c 33 * @param miso SPI pin
dreschpe 12:9c8f3076347c 34 * @param sclk SPI pin
dreschpe 12:9c8f3076347c 35 * @param CS pin connected to CS of display
dreschpe 12:9c8f3076347c 36 * @param reset pin connected to RESET of display
dreschpe 12:9c8f3076347c 37 * @param DC pin connected to data/command of display
dreschpe 12:9c8f3076347c 38 * @param name The name used by the parent class to access the interface
dreschpe 12:9c8f3076347c 39 * @param LCDSIZE_X x size in pixel - optional
dreschpe 12:9c8f3076347c 40 * @param LCDSIZE_Y y size in pixel - optional
dreschpe 12:9c8f3076347c 41 */
dreschpe 12:9c8f3076347c 42 SSD1306(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);
Geremia 15:b9483ba842c8 43
dreschpe 33:f87f06292637 44 /** Create an I2C display interface
dreschpe 33:f87f06292637 45 * @param displayproto I2C_
dreschpe 33:f87f06292637 46 * @param Hz I2C speed in Hz
dreschpe 33:f87f06292637 47 * @param address I2C address
dreschpe 33:f87f06292637 48 * @param sda I2C pin
dreschpe 33:f87f06292637 49 * @param scl I2C pin
dreschpe 33:f87f06292637 50 * @param name The name used by the parent class to access the interface
dreschpe 33:f87f06292637 51 * @param LCDSIZE_X x size in pixel - optional
dreschpe 33:f87f06292637 52 * @param LCDSIZE_Y y size in pixel - optional
dreschpe 33:f87f06292637 53 */
dreschpe 33:f87f06292637 54 SSD1306(proto_t displayproto, int Hz, int address, PinName sda, PinName scl, const char* name , unsigned int LCDSIZE_X = 128, unsigned int LCDSIZE_Y = 64);
dreschpe 33:f87f06292637 55
dreschpe 33:f87f06292637 56
dreschpe 33:f87f06292637 57
Geremia 15:b9483ba842c8 58 /** set the contrast of the screen
Geremia 15:b9483ba842c8 59 * @note here overrided because of not standard value range
Geremia 15:b9483ba842c8 60 * @param o contrast 0-255
Geremia 15:b9483ba842c8 61 */
Geremia 15:b9483ba842c8 62 virtual void set_contrast(int o);
Geremia 15:b9483ba842c8 63
dreschpe 17:1dafb896c6f5 64 /** set automatc horizontal scroll mode
dreschpe 17:1dafb896c6f5 65 * @param l_r direction - left = 0, right = 1
dreschpe 17:1dafb896c6f5 66 * @param s_page start page
dreschpe 17:1dafb896c6f5 67 * @param e_page end page
dreschpe 17:1dafb896c6f5 68 * @param speed time between horizontal shift. 0 slow .. 7 fast
dreschpe 17:1dafb896c6f5 69 */
dreschpe 17:1dafb896c6f5 70 void horizontal_scroll(int l_r,int s_page,int e_page,int speed);
dreschpe 17:1dafb896c6f5 71
dreschpe 17:1dafb896c6f5 72 /** automatic horizontal + vertical scroll mode
dreschpe 17:1dafb896c6f5 73 * @param l_r direction - left = 0, right = 1
dreschpe 17:1dafb896c6f5 74 * @param s_page start page
dreschpe 17:1dafb896c6f5 75 * @param e_page end page
dreschpe 17:1dafb896c6f5 76 * @param v_off vertical offset for scroll
dreschpe 17:1dafb896c6f5 77 * @param speed time between horizontal shift. 0 slow .. 7 fast
dreschpe 17:1dafb896c6f5 78 */
dreschpe 17:1dafb896c6f5 79 void horiz_vert_scroll(int l_r,int s_page,int e_page,int v_off,int speed);
dreschpe 17:1dafb896c6f5 80
dreschpe 17:1dafb896c6f5 81 /** end scroll mode
dreschpe 17:1dafb896c6f5 82 *
dreschpe 17:1dafb896c6f5 83 */
dreschpe 17:1dafb896c6f5 84 void end_scroll(void);
dreschpe 17:1dafb896c6f5 85 protected:
dreschpe 12:9c8f3076347c 86
dreschpe 12:9c8f3076347c 87
dreschpe 12:9c8f3076347c 88 /** Init command sequence
dreschpe 12:9c8f3076347c 89 */
dreschpe 12:9c8f3076347c 90 void init();
dreschpe 12:9c8f3076347c 91
dreschpe 12:9c8f3076347c 92 /** set mirror mode
dreschpe 12:9c8f3076347c 93 * @note here overriding the LCD class default one because of not standard commands
dreschpe 12:9c8f3076347c 94 * @param mode NONE, X, Y, XY
dreschpe 12:9c8f3076347c 95 */
dreschpe 12:9c8f3076347c 96 virtual void mirrorXY(mirror_t mode);
dreschpe 12:9c8f3076347c 97
dreschpe 12:9c8f3076347c 98 };
dreschpe 12:9c8f3076347c 99
dreschpe 12:9c8f3076347c 100
dreschpe 12:9c8f3076347c 101 #endif