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.
Fork of UniGraphic by
Inits/SSD1306.h@12:9c8f3076347c, 2015-02-22 (annotated)
- Committer:
- dreschpe
- Date:
- Sun Feb 22 00:05:34 2015 +0000
- Revision:
- 12:9c8f3076347c
- Child:
- 14:29bab588ba75
Add SSD1306 OLED Driver
Who changed what in which revision?
User | Revision | Line number | New 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 | |
dreschpe | 12:9c8f3076347c | 5 | |
dreschpe | 12:9c8f3076347c | 6 | #include "mbed.h" |
dreschpe | 12:9c8f3076347c | 7 | #include "LCD.h" |
dreschpe | 12:9c8f3076347c | 8 | |
dreschpe | 12:9c8f3076347c | 9 | /** Class for UC1608 display controller |
dreschpe | 12:9c8f3076347c | 10 | * to be copypasted and adapted for other controllers |
dreschpe | 12:9c8f3076347c | 11 | */ |
dreschpe | 12:9c8f3076347c | 12 | class SSD1306 : public LCD |
dreschpe | 12:9c8f3076347c | 13 | { |
dreschpe | 12:9c8f3076347c | 14 | |
dreschpe | 12:9c8f3076347c | 15 | public: |
dreschpe | 12:9c8f3076347c | 16 | |
dreschpe | 12:9c8f3076347c | 17 | /** Create a PAR display interface |
dreschpe | 12:9c8f3076347c | 18 | * @param displayproto only supports PAR_8 |
dreschpe | 12:9c8f3076347c | 19 | * @param port GPIO port name to use |
dreschpe | 12:9c8f3076347c | 20 | * @param CS pin connected to CS of display |
dreschpe | 12:9c8f3076347c | 21 | * @param reset pin connected to RESET of display |
dreschpe | 12:9c8f3076347c | 22 | * @param DC pin connected to data/command of display |
dreschpe | 12:9c8f3076347c | 23 | * @param WR pin connected to SDI of display |
dreschpe | 12:9c8f3076347c | 24 | * @param RD pin connected to RS of display |
dreschpe | 12:9c8f3076347c | 25 | * @param name The name used by the parent class to access the interface |
dreschpe | 12:9c8f3076347c | 26 | * @param LCDSIZE_X x size in pixel - optional |
dreschpe | 12:9c8f3076347c | 27 | * @param LCDSIZE_Y y size in pixel - optional |
dreschpe | 12:9c8f3076347c | 28 | */ |
dreschpe | 12:9c8f3076347c | 29 | 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 | 30 | |
dreschpe | 12:9c8f3076347c | 31 | /** Create an SPI display interface |
dreschpe | 12:9c8f3076347c | 32 | * @param displayproto only supports SPI_8 |
dreschpe | 12:9c8f3076347c | 33 | * @param Hz SPI speed in Hz |
dreschpe | 12:9c8f3076347c | 34 | * @param mosi SPI pin |
dreschpe | 12:9c8f3076347c | 35 | * @param miso SPI pin |
dreschpe | 12:9c8f3076347c | 36 | * @param sclk SPI pin |
dreschpe | 12:9c8f3076347c | 37 | * @param CS pin connected to CS of display |
dreschpe | 12:9c8f3076347c | 38 | * @param reset pin connected to RESET of display |
dreschpe | 12:9c8f3076347c | 39 | * @param DC pin connected to data/command of display |
dreschpe | 12:9c8f3076347c | 40 | * @param name The name used by the parent class to access the interface |
dreschpe | 12:9c8f3076347c | 41 | * @param LCDSIZE_X x size in pixel - optional |
dreschpe | 12:9c8f3076347c | 42 | * @param LCDSIZE_Y y size in pixel - optional |
dreschpe | 12:9c8f3076347c | 43 | */ |
dreschpe | 12:9c8f3076347c | 44 | 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); |
dreschpe | 12:9c8f3076347c | 45 | |
dreschpe | 12:9c8f3076347c | 46 | /** set the contrast of the screen |
dreschpe | 12:9c8f3076347c | 47 | * @note here overrided because of not standard command |
dreschpe | 12:9c8f3076347c | 48 | * @param o contrast 0-63 |
dreschpe | 12:9c8f3076347c | 49 | */ |
dreschpe | 12:9c8f3076347c | 50 | virtual void set_contrast(int o); |
dreschpe | 12:9c8f3076347c | 51 | |
dreschpe | 12:9c8f3076347c | 52 | |
dreschpe | 12:9c8f3076347c | 53 | protected: |
dreschpe | 12:9c8f3076347c | 54 | |
dreschpe | 12:9c8f3076347c | 55 | |
dreschpe | 12:9c8f3076347c | 56 | /** Init command sequence |
dreschpe | 12:9c8f3076347c | 57 | */ |
dreschpe | 12:9c8f3076347c | 58 | void init(); |
dreschpe | 12:9c8f3076347c | 59 | |
dreschpe | 12:9c8f3076347c | 60 | /** set mirror mode |
dreschpe | 12:9c8f3076347c | 61 | * @note here overriding the LCD class default one because of not standard commands |
dreschpe | 12:9c8f3076347c | 62 | * @param mode NONE, X, Y, XY |
dreschpe | 12:9c8f3076347c | 63 | */ |
dreschpe | 12:9c8f3076347c | 64 | virtual void mirrorXY(mirror_t mode); |
dreschpe | 12:9c8f3076347c | 65 | |
dreschpe | 12:9c8f3076347c | 66 | }; |
dreschpe | 12:9c8f3076347c | 67 | |
dreschpe | 12:9c8f3076347c | 68 | |
dreschpe | 12:9c8f3076347c | 69 | #endif |