A simple library for SSH1106 controlled GLCDs

Dependents:   SSH1106_OLED

Committer:
Anaesthetix
Date:
Mon Dec 19 15:02:30 2016 +0000
Revision:
0:3cd0a11a2f91
Child:
1:ac9efaadd666
-

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Anaesthetix 0:3cd0a11a2f91 1 /**
Anaesthetix 0:3cd0a11a2f91 2 * This is a simple library for SSH1106 controlled graphic LCD's.
Anaesthetix 0:3cd0a11a2f91 3 * Written for a 1.3" OLED GLCD
Anaesthetix 0:3cd0a11a2f91 4 * See http://www.banggood.com/1_3-Inch-7Pin-White-OLED-12864-SPI-Interface-LCD-Display-Module-For-Arduino-p-1067872.html
Anaesthetix 0:3cd0a11a2f91 5 *
Anaesthetix 0:3cd0a11a2f91 6 * Written by: Erik van de Coevering
Anaesthetix 0:3cd0a11a2f91 7 * With thanks to Tim Barr from whom I've reused some code
Anaesthetix 0:3cd0a11a2f91 8 * Use this code in whatever way you like, as long as it stays free of charge!
Anaesthetix 0:3cd0a11a2f91 9 */
Anaesthetix 0:3cd0a11a2f91 10
Anaesthetix 0:3cd0a11a2f91 11 #ifndef SSH1106_H
Anaesthetix 0:3cd0a11a2f91 12 #define SSH1106_H
Anaesthetix 0:3cd0a11a2f91 13
Anaesthetix 0:3cd0a11a2f91 14 #include "mbed.h"
Anaesthetix 0:3cd0a11a2f91 15 #include "font_4x5.h"
Anaesthetix 0:3cd0a11a2f91 16 #include "font_5x8.h"
Anaesthetix 0:3cd0a11a2f91 17 #include "font_6x6.h"
Anaesthetix 0:3cd0a11a2f91 18 #include "font_6x8.h"
Anaesthetix 0:3cd0a11a2f91 19 #include "font_7x7.h"
Anaesthetix 0:3cd0a11a2f91 20 #include "font_8x8.h"
Anaesthetix 0:3cd0a11a2f91 21 #include "font_8x8_1.h"
Anaesthetix 0:3cd0a11a2f91 22 #include "bold_font.h"
Anaesthetix 0:3cd0a11a2f91 23 #include "font2d_hunter.h"
Anaesthetix 0:3cd0a11a2f91 24 #include "font2d_formplex12.h"
Anaesthetix 0:3cd0a11a2f91 25 #include "biohazard.h"
Anaesthetix 0:3cd0a11a2f91 26 #include "highvoltage.h"
Anaesthetix 0:3cd0a11a2f91 27 #include "einstein.h"
Anaesthetix 0:3cd0a11a2f91 28 #include "test.h"
Anaesthetix 0:3cd0a11a2f91 29 #include "copter.h"
Anaesthetix 0:3cd0a11a2f91 30
Anaesthetix 0:3cd0a11a2f91 31 #define LCDWIDTH 128
Anaesthetix 0:3cd0a11a2f91 32 #define LCDHEIGHT 64
Anaesthetix 0:3cd0a11a2f91 33 #define LCDPAGES 8
Anaesthetix 0:3cd0a11a2f91 34
Anaesthetix 0:3cd0a11a2f91 35 class SSH1106
Anaesthetix 0:3cd0a11a2f91 36 {
Anaesthetix 0:3cd0a11a2f91 37 public:
Anaesthetix 0:3cd0a11a2f91 38
Anaesthetix 0:3cd0a11a2f91 39 // Constructor
Anaesthetix 0:3cd0a11a2f91 40 SSH1106(SPI &spi, DigitalOut &lcd_cs, DigitalOut &cd, DigitalOut &rst);
Anaesthetix 0:3cd0a11a2f91 41
Anaesthetix 0:3cd0a11a2f91 42 // Initialize LCD
Anaesthetix 0:3cd0a11a2f91 43 void init(void);
Anaesthetix 0:3cd0a11a2f91 44
Anaesthetix 0:3cd0a11a2f91 45 // Set contrast (0 - 63), initialized to 40
Anaesthetix 0:3cd0a11a2f91 46 void setContrast(char contrast);
Anaesthetix 0:3cd0a11a2f91 47
Anaesthetix 0:3cd0a11a2f91 48 // Place cursor at position
Anaesthetix 0:3cd0a11a2f91 49 void setCursor(char column, char line);
Anaesthetix 0:3cd0a11a2f91 50
Anaesthetix 0:3cd0a11a2f91 51 // Clear screen
Anaesthetix 0:3cd0a11a2f91 52 void clear(void);
Anaesthetix 0:3cd0a11a2f91 53
Anaesthetix 0:3cd0a11a2f91 54 // Write text to LCD where font format is a 2-dimensional array (only 96x8, 8x8 pixel fonts supported)
Anaesthetix 0:3cd0a11a2f91 55 void writeText2d(char column, char page, const char font_address[96][8], const char *text, int size);
Anaesthetix 0:3cd0a11a2f91 56
Anaesthetix 0:3cd0a11a2f91 57 // Write text to LCD where font format is a 1-dimensional array. Fonts bigger than 8 pix high should work but isn't tested
Anaesthetix 0:3cd0a11a2f91 58 void writeText(char column, char page, const char *font_address, const char *str, const uint8_t size);
Anaesthetix 0:3cd0a11a2f91 59
Anaesthetix 0:3cd0a11a2f91 60 // Draw a 128x64 pixel bitmap
Anaesthetix 0:3cd0a11a2f91 61 void drawBitmap(const char *data);
Anaesthetix 0:3cd0a11a2f91 62
Anaesthetix 0:3cd0a11a2f91 63 private:
Anaesthetix 0:3cd0a11a2f91 64
Anaesthetix 0:3cd0a11a2f91 65 SPI *_lcd;
Anaesthetix 0:3cd0a11a2f91 66 DigitalOut *_lcd_cs;
Anaesthetix 0:3cd0a11a2f91 67 DigitalOut *_lcd_cd;
Anaesthetix 0:3cd0a11a2f91 68 DigitalOut *_lcd_rst;
Anaesthetix 0:3cd0a11a2f91 69 uint8_t _lcdbuffer[LCDWIDTH*LCDPAGES];
Anaesthetix 0:3cd0a11a2f91 70
Anaesthetix 0:3cd0a11a2f91 71 };
Anaesthetix 0:3cd0a11a2f91 72
Anaesthetix 0:3cd0a11a2f91 73 #endif