derived from Aidafruit SSD1306 library

Dependents:   Test_SSD1306 L152RE_OLED_SSD1306 EcranZumo

Fork of SSD1306 by Jonathan Gaul

Revision:
0:21cb91208386
Child:
1:1d58d378221c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ssd1306.h	Tue Feb 05 09:46:58 2013 +0000
@@ -0,0 +1,85 @@
+#ifndef __SSD1306_H__
+#define __SSD1306_H__
+
+#define FONT_HEIGHT_OFFSET  0    /* Character pixel height (in multiples of 8) at this position */
+#define FONT_SIZE_OFFSET    1    /* Character data size (in bytes) at this position */
+#define FONT_DATA_OFFSET    2    /* Data starts at this position */
+#define FONT_START          ' '  /* First character value in the font table */
+
+class SSD1306
+{
+public:
+    SSD1306(PinName cs, PinName rs, PinName dc, PinName clk, PinName data);
+
+    void initialise();
+    void update();
+
+    void off();
+    void on();
+    
+    void invert(int i);
+
+    void set_low_column(int value);
+    void set_high_column(int value);
+    void set_start_line(int value);
+
+    void set_display_offset(int value);
+
+    void clear();
+    void set_pixel(int x, int y);
+    void clear_pixel(int x, int y);
+    void line(int x0, int y0, int x1, int y1);
+    
+    void draw_string(char *font, int x, int y, const char *string);
+    void draw_char(char *font, int x, int y, char c);
+
+private:
+    SPI _spi;
+    DigitalOut _cs, _reset, _dc;
+    char _screen[1024];
+
+    int _cursor_x, _cursor_y;
+
+    void _send_command(int code);
+    void _send_data(int value);
+};
+
+#define SSD1306_LCDWIDTH 128
+#define SSD1306_LCDHEIGHT 64
+
+#define SSD1306_SETCONTRAST 0x81
+#define SSD1306_DISPLAYALLON_RESUME 0xA4
+#define SSD1306_DISPLAYALLON 0xA5
+#define SSD1306_NORMALDISPLAY 0xA6
+#define SSD1306_INVERTDISPLAY 0xA7
+#define SSD1306_DISPLAYOFF 0xAE
+#define SSD1306_DISPLAYON 0xAF
+
+#define SSD1306_SETDISPLAYOFFSET 0xD3
+#define SSD1306_SETCOMPINS 0xDA
+
+#define SSD1306_SETVCOMDETECT 0xDB
+
+#define SSD1306_SETDISPLAYCLOCKDIV 0xD5
+#define SSD1306_SETPRECHARGE 0xD9
+
+#define SSD1306_SETMULTIPLEX 0xA8
+
+#define SSD1306_SETLOWCOLUMN 0x00
+#define SSD1306_SETHIGHCOLUMN 0x10
+
+#define SSD1306_SETSTARTLINE 0x40
+
+#define SSD1306_MEMORYMODE 0x20
+
+#define SSD1306_COMSCANINC 0xC0
+#define SSD1306_COMSCANDEC 0xC8
+
+#define SSD1306_SEGREMAP 0xA0
+
+#define SSD1306_CHARGEPUMP 0x8D
+
+#define SSD1306_EXTERNALVCC 0x1
+#define SSD1306_SWITCHCAPVCC 0x2
+
+#endif