A simple library for SSH1106 controlled GLCDs

Dependents:   SSH1106_OLED

Revision:
0:3cd0a11a2f91
Child:
1:ac9efaadd666
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSH1106.h	Mon Dec 19 15:02:30 2016 +0000
@@ -0,0 +1,73 @@
+/**
+ * This is a simple library for SSH1106 controlled graphic LCD's. 
+ * Written for a 1.3" OLED GLCD
+ * See      http://www.banggood.com/1_3-Inch-7Pin-White-OLED-12864-SPI-Interface-LCD-Display-Module-For-Arduino-p-1067872.html
+ *
+ * Written by:  Erik van de Coevering
+ * With thanks to Tim Barr from whom I've reused some code
+ * Use this code in whatever way you like, as long as it stays free of charge!
+ */
+
+#ifndef SSH1106_H
+#define SSH1106_H
+
+#include "mbed.h"
+#include "font_4x5.h"
+#include "font_5x8.h"
+#include "font_6x6.h"
+#include "font_6x8.h"
+#include "font_7x7.h"
+#include "font_8x8.h"
+#include "font_8x8_1.h"
+#include "bold_font.h"
+#include "font2d_hunter.h"
+#include "font2d_formplex12.h"
+#include "biohazard.h"
+#include "highvoltage.h"
+#include "einstein.h"
+#include "test.h"
+#include "copter.h"
+
+#define LCDWIDTH 128
+#define LCDHEIGHT 64
+#define LCDPAGES 8
+
+class SSH1106
+{
+public:
+
+    // Constructor
+    SSH1106(SPI &spi, DigitalOut &lcd_cs, DigitalOut &cd, DigitalOut &rst);
+
+    // Initialize LCD
+    void init(void);
+    
+    // Set contrast (0 - 63), initialized to 40
+    void setContrast(char contrast);
+
+    // Place cursor at position
+    void setCursor(char column, char line);
+
+    // Clear screen
+    void clear(void);
+
+    // Write text to LCD where font format is a 2-dimensional array (only 96x8, 8x8 pixel fonts supported)
+    void writeText2d(char column, char page, const char font_address[96][8], const char *text, int size);
+
+    // Write text to LCD where font format is a 1-dimensional array. Fonts bigger than 8 pix high should work but isn't tested
+    void writeText(char column, char page, const char *font_address, const char *str, const uint8_t size);
+
+    // Draw a 128x64 pixel bitmap
+    void drawBitmap(const char *data);
+
+private:
+
+    SPI         *_lcd;
+    DigitalOut  *_lcd_cs;
+    DigitalOut  *_lcd_cd;
+    DigitalOut   *_lcd_rst;
+    uint8_t     _lcdbuffer[LCDWIDTH*LCDPAGES];
+
+};
+
+#endif