derived from Aidafruit SSD1306 library

Dependents:   Test_SSD1306 L152RE_OLED_SSD1306 EcranZumo

Fork of SSD1306 by Jonathan Gaul

Committer:
Byrn
Date:
Tue Feb 05 09:46:58 2013 +0000
Revision:
0:21cb91208386
Child:
1:1d58d378221c
[mbed] converted /OLED/SSD1306

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Byrn 0:21cb91208386 1 #ifndef __SSD1306_H__
Byrn 0:21cb91208386 2 #define __SSD1306_H__
Byrn 0:21cb91208386 3
Byrn 0:21cb91208386 4 #define FONT_HEIGHT_OFFSET 0 /* Character pixel height (in multiples of 8) at this position */
Byrn 0:21cb91208386 5 #define FONT_SIZE_OFFSET 1 /* Character data size (in bytes) at this position */
Byrn 0:21cb91208386 6 #define FONT_DATA_OFFSET 2 /* Data starts at this position */
Byrn 0:21cb91208386 7 #define FONT_START ' ' /* First character value in the font table */
Byrn 0:21cb91208386 8
Byrn 0:21cb91208386 9 class SSD1306
Byrn 0:21cb91208386 10 {
Byrn 0:21cb91208386 11 public:
Byrn 0:21cb91208386 12 SSD1306(PinName cs, PinName rs, PinName dc, PinName clk, PinName data);
Byrn 0:21cb91208386 13
Byrn 0:21cb91208386 14 void initialise();
Byrn 0:21cb91208386 15 void update();
Byrn 0:21cb91208386 16
Byrn 0:21cb91208386 17 void off();
Byrn 0:21cb91208386 18 void on();
Byrn 0:21cb91208386 19
Byrn 0:21cb91208386 20 void invert(int i);
Byrn 0:21cb91208386 21
Byrn 0:21cb91208386 22 void set_low_column(int value);
Byrn 0:21cb91208386 23 void set_high_column(int value);
Byrn 0:21cb91208386 24 void set_start_line(int value);
Byrn 0:21cb91208386 25
Byrn 0:21cb91208386 26 void set_display_offset(int value);
Byrn 0:21cb91208386 27
Byrn 0:21cb91208386 28 void clear();
Byrn 0:21cb91208386 29 void set_pixel(int x, int y);
Byrn 0:21cb91208386 30 void clear_pixel(int x, int y);
Byrn 0:21cb91208386 31 void line(int x0, int y0, int x1, int y1);
Byrn 0:21cb91208386 32
Byrn 0:21cb91208386 33 void draw_string(char *font, int x, int y, const char *string);
Byrn 0:21cb91208386 34 void draw_char(char *font, int x, int y, char c);
Byrn 0:21cb91208386 35
Byrn 0:21cb91208386 36 private:
Byrn 0:21cb91208386 37 SPI _spi;
Byrn 0:21cb91208386 38 DigitalOut _cs, _reset, _dc;
Byrn 0:21cb91208386 39 char _screen[1024];
Byrn 0:21cb91208386 40
Byrn 0:21cb91208386 41 int _cursor_x, _cursor_y;
Byrn 0:21cb91208386 42
Byrn 0:21cb91208386 43 void _send_command(int code);
Byrn 0:21cb91208386 44 void _send_data(int value);
Byrn 0:21cb91208386 45 };
Byrn 0:21cb91208386 46
Byrn 0:21cb91208386 47 #define SSD1306_LCDWIDTH 128
Byrn 0:21cb91208386 48 #define SSD1306_LCDHEIGHT 64
Byrn 0:21cb91208386 49
Byrn 0:21cb91208386 50 #define SSD1306_SETCONTRAST 0x81
Byrn 0:21cb91208386 51 #define SSD1306_DISPLAYALLON_RESUME 0xA4
Byrn 0:21cb91208386 52 #define SSD1306_DISPLAYALLON 0xA5
Byrn 0:21cb91208386 53 #define SSD1306_NORMALDISPLAY 0xA6
Byrn 0:21cb91208386 54 #define SSD1306_INVERTDISPLAY 0xA7
Byrn 0:21cb91208386 55 #define SSD1306_DISPLAYOFF 0xAE
Byrn 0:21cb91208386 56 #define SSD1306_DISPLAYON 0xAF
Byrn 0:21cb91208386 57
Byrn 0:21cb91208386 58 #define SSD1306_SETDISPLAYOFFSET 0xD3
Byrn 0:21cb91208386 59 #define SSD1306_SETCOMPINS 0xDA
Byrn 0:21cb91208386 60
Byrn 0:21cb91208386 61 #define SSD1306_SETVCOMDETECT 0xDB
Byrn 0:21cb91208386 62
Byrn 0:21cb91208386 63 #define SSD1306_SETDISPLAYCLOCKDIV 0xD5
Byrn 0:21cb91208386 64 #define SSD1306_SETPRECHARGE 0xD9
Byrn 0:21cb91208386 65
Byrn 0:21cb91208386 66 #define SSD1306_SETMULTIPLEX 0xA8
Byrn 0:21cb91208386 67
Byrn 0:21cb91208386 68 #define SSD1306_SETLOWCOLUMN 0x00
Byrn 0:21cb91208386 69 #define SSD1306_SETHIGHCOLUMN 0x10
Byrn 0:21cb91208386 70
Byrn 0:21cb91208386 71 #define SSD1306_SETSTARTLINE 0x40
Byrn 0:21cb91208386 72
Byrn 0:21cb91208386 73 #define SSD1306_MEMORYMODE 0x20
Byrn 0:21cb91208386 74
Byrn 0:21cb91208386 75 #define SSD1306_COMSCANINC 0xC0
Byrn 0:21cb91208386 76 #define SSD1306_COMSCANDEC 0xC8
Byrn 0:21cb91208386 77
Byrn 0:21cb91208386 78 #define SSD1306_SEGREMAP 0xA0
Byrn 0:21cb91208386 79
Byrn 0:21cb91208386 80 #define SSD1306_CHARGEPUMP 0x8D
Byrn 0:21cb91208386 81
Byrn 0:21cb91208386 82 #define SSD1306_EXTERNALVCC 0x1
Byrn 0:21cb91208386 83 #define SSD1306_SWITCHCAPVCC 0x2
Byrn 0:21cb91208386 84
Byrn 0:21cb91208386 85 #endif