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.
Inits/SSD1306.h@19:1bdfb971b2c1, 2015-03-02 (annotated)
- Committer:
- Geremia
- Date:
- Mon Mar 02 10:52:26 2015 +0000
- Revision:
- 19:1bdfb971b2c1
- Parent:
- 18:ffa58f1a680a
- Parent:
- 17:1dafb896c6f5
- Child:
- 33:f87f06292637
Added LCD ST7565, the very basic std one, tested also on UC1701
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 | #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 | |
Geremia | 15:b9483ba842c8 | 44 | /** set the contrast of the screen |
Geremia | 15:b9483ba842c8 | 45 | * @note here overrided because of not standard value range |
Geremia | 15:b9483ba842c8 | 46 | * @param o contrast 0-255 |
Geremia | 15:b9483ba842c8 | 47 | */ |
Geremia | 15:b9483ba842c8 | 48 | virtual void set_contrast(int o); |
Geremia | 15:b9483ba842c8 | 49 | |
dreschpe | 17:1dafb896c6f5 | 50 | /** set automatc horizontal scroll mode |
dreschpe | 17:1dafb896c6f5 | 51 | * @param l_r direction - left = 0, right = 1 |
dreschpe | 17:1dafb896c6f5 | 52 | * @param s_page start page |
dreschpe | 17:1dafb896c6f5 | 53 | * @param e_page end page |
dreschpe | 17:1dafb896c6f5 | 54 | * @param speed time between horizontal shift. 0 slow .. 7 fast |
dreschpe | 17:1dafb896c6f5 | 55 | */ |
dreschpe | 17:1dafb896c6f5 | 56 | void horizontal_scroll(int l_r,int s_page,int e_page,int speed); |
dreschpe | 17:1dafb896c6f5 | 57 | |
dreschpe | 17:1dafb896c6f5 | 58 | /** automatic horizontal + vertical scroll mode |
dreschpe | 17:1dafb896c6f5 | 59 | * @param l_r direction - left = 0, right = 1 |
dreschpe | 17:1dafb896c6f5 | 60 | * @param s_page start page |
dreschpe | 17:1dafb896c6f5 | 61 | * @param e_page end page |
dreschpe | 17:1dafb896c6f5 | 62 | * @param v_off vertical offset for scroll |
dreschpe | 17:1dafb896c6f5 | 63 | * @param speed time between horizontal shift. 0 slow .. 7 fast |
dreschpe | 17:1dafb896c6f5 | 64 | */ |
dreschpe | 17:1dafb896c6f5 | 65 | void horiz_vert_scroll(int l_r,int s_page,int e_page,int v_off,int speed); |
dreschpe | 17:1dafb896c6f5 | 66 | |
dreschpe | 17:1dafb896c6f5 | 67 | /** end scroll mode |
dreschpe | 17:1dafb896c6f5 | 68 | * |
dreschpe | 17:1dafb896c6f5 | 69 | */ |
dreschpe | 17:1dafb896c6f5 | 70 | void end_scroll(void); |
dreschpe | 17:1dafb896c6f5 | 71 | protected: |
dreschpe | 12:9c8f3076347c | 72 | |
dreschpe | 12:9c8f3076347c | 73 | |
dreschpe | 12:9c8f3076347c | 74 | /** Init command sequence |
dreschpe | 12:9c8f3076347c | 75 | */ |
dreschpe | 12:9c8f3076347c | 76 | void init(); |
dreschpe | 12:9c8f3076347c | 77 | |
dreschpe | 12:9c8f3076347c | 78 | /** set mirror mode |
dreschpe | 12:9c8f3076347c | 79 | * @note here overriding the LCD class default one because of not standard commands |
dreschpe | 12:9c8f3076347c | 80 | * @param mode NONE, X, Y, XY |
dreschpe | 12:9c8f3076347c | 81 | */ |
dreschpe | 12:9c8f3076347c | 82 | virtual void mirrorXY(mirror_t mode); |
dreschpe | 12:9c8f3076347c | 83 | |
dreschpe | 12:9c8f3076347c | 84 | }; |
dreschpe | 12:9c8f3076347c | 85 | |
dreschpe | 12:9c8f3076347c | 86 | |
dreschpe | 12:9c8f3076347c | 87 | #endif |