derived from Aidafruit SSD1306 library

Dependents:   Test_SSD1306 L152RE_OLED_SSD1306 EcranZumo

Fork of SSD1306 by Jonathan Gaul

Revision:
3:1d9df877c90a
Parent:
2:e479b0296757
Child:
4:ec5add86f335
--- a/ssd1306.h	Tue Feb 05 21:21:22 2013 +0000
+++ b/ssd1306.h	Sat Feb 09 16:43:49 2013 +0000
@@ -1,16 +1,22 @@
 #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 */
 
 /** SSD1306 Controller Driver
- *
- * Information taken from the datasheet at:
- *   http://www.adafruit.com/datasheets/SSD1306.pdf
- */
+  *
+  * This class provides a buffered display for the SSD1306 OLED controller.
+  * 
+  * TODO: 
+  *   - At the moment, the driver assumes a 128x64 pixel display.
+  *   - Only fonts of 8 pixel height are supported (different widths can be used).
+  *   - Pretty much no drawing functions are provided as yet.
+  *   - Possible "auto-update", automatically calling update() after a printf etc.
+  *
+  * Information taken from the datasheet at:
+  *   http://www.adafruit.com/datasheets/SSD1306.pdf
+  *
+  */
 class SSD1306
 {
 public:
@@ -180,8 +186,34 @@
     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);
+    /** Set the current console font.
+      * @param font Font data, layed out vertically!
+      * @param width Width of the font characters in pixels.
+      * Fonts are always (at present) 8 pixels in height.
+      */
+    void set_font(unsigned char *font, unsigned int width);
+    
+    /** Set double height text output.
+      * @param double_height If 1, calls to putc(), printf() etc will
+      * result in text taking up 2 lines instead of 1.
+      */
+    void set_double_height_text(unsigned int double_height);
+    
+    /** Put a single character to the screen buffer.
+      * Repeated calls to putc() will cause the cursor to move across and
+      * then down as needed, with scrolling.
+      * @param c The character to write.
+      */
+    void putc(unsigned char c);
+    
+    /** Print to the screen buffer.
+      * printf() will wrap and scroll the screen as needed to display the text given.
+      * @param format Format specifier, same as printf() in normal C.
+      */
+    void printf(const char *format, ...);
+
+    /** Scroll the screen buffer up by one line. */
+    void scroll_up();
 
 private:
     SPI _spi;
@@ -192,6 +224,10 @@
 
     void _send_command(unsigned char code);
     void _send_data(unsigned char value);
+    
+    unsigned char *_console_font_data;  
+    unsigned int _console_font_width;
+    unsigned int _double_height_text;
 };
 
 #define SSD1306_LCDWIDTH 128