A simple library for SSH1106 controlled GLCDs
Embed:
(wiki syntax)
Show/hide line numbers
SSH1106.h
00001 /** 00002 * This is a simple library for SSH1106 controlled graphic LCD's. 00003 * Written for a 1.3" OLED GLCD 00004 * See http://www.banggood.com/1_3-Inch-7Pin-White-OLED-12864-SPI-Interface-LCD-Display-Module-For-Arduino-p-1067872.html 00005 * 00006 * Written by: Erik van de Coevering 00007 * With thanks to Tim Barr from whom I've reused some code 00008 * Use this code in whatever way you like, as long as it stays free of charge! 00009 */ 00010 00011 #ifndef SSH1106_H 00012 #define SSH1106_H 00013 00014 #include "mbed.h" 00015 #include "font_4x5.h" 00016 #include "font_5x8.h" 00017 #include "font_6x6.h" 00018 #include "font_6x8.h" 00019 #include "font_7x7.h" 00020 #include "font_8x8.h" 00021 #include "font_8x8_1.h" 00022 #include "bold_font.h" 00023 #include "font2d_hunter.h" 00024 #include "font2d_formplex12.h" 00025 #include "biohazard.h" 00026 #include "highvoltage.h" 00027 #include "einstein.h" 00028 #include "test.h" 00029 #include "copter.h" 00030 00031 #define LCDWIDTH 128 00032 #define LCDHEIGHT 64 00033 #define LCDPAGES 8 00034 00035 class SSH1106 00036 { 00037 public: 00038 00039 // Constructor 00040 SSH1106(SPI &spi, DigitalOut &lcd_cs, DigitalOut &cd, DigitalOut &rst); 00041 00042 // Initialize LCD 00043 void init(void); 00044 00045 // Set contrast (0 - 63), initialized to 40 00046 void setContrast(char contrast); 00047 00048 // Place cursor at position 00049 void setCursor(char column, char line); 00050 00051 // Clear screen 00052 void clear(void); 00053 00054 // Write text to LCD where font format is a 2-dimensional array (only 96x8 byte, 8x8 pixel fonts supported) 00055 void writeText2d(char column, char page, const char font_address[96][8], const char *text, int size); 00056 00057 // Write text to LCD where font format is a 1-dimensional array. >8 pixel fonts are not working yet, will update soon 00058 void writeText(char column, char page, const char *font_address, const char *str, const uint8_t size); 00059 00060 // Draw a 128x64 pixel bitmap 00061 void drawBitmap(const char *data); 00062 00063 // Draw a horizontal line, start positions / height / width in pixels 00064 void drawLineHor(char posx, char posy, char height, char width); 00065 00066 // Draw a vertical line, start positions / height / width in pixels 00067 void drawLineVert(char posx, char posy, char height, char width); 00068 00069 //----------------------------------------------------------------------------------------------------------------------------- 00070 // Functions below are buffered versions; possible to write things on top of each other without clearing pixels (ORs all data). 00071 // Use update() to write buffer to LCD. 00072 // Clear buffer before writing 1st time (initialize all values) 00073 // writetext / drawbitmap will be added soon 00074 //----------------------------------------------------------------------------------------------------------------------------- 00075 00076 // Clear buffer 00077 void clearBuffer(void); 00078 00079 // Write buffer to LCD 00080 void update(void); 00081 00082 // Draw a horizontal line, start positions / height / width in pixels. Buffered version; possible to write things on top of each other 00083 // without clearing pixels (ORs all data). Use update() to write buffer to LCD 00084 void drawbufferLineHor(char posx, char posy, char height, char width); 00085 00086 // Draw a vertical line, start positions / height / width in pixels. Buffered version. 00087 void drawbufferLineVert(char posx, char posy, char height, char width); 00088 00089 private: 00090 00091 SPI *_lcd; 00092 DigitalOut *_lcd_cs; 00093 DigitalOut *_lcd_cd; 00094 DigitalOut *_lcd_rst; 00095 uint8_t _lcdbuffer[LCDWIDTH*LCDPAGES]; 00096 char buff[LCDWIDTH*LCDPAGES]; 00097 00098 }; 00099 00100 #endif
Generated on Wed Jul 20 2022 17:31:59 by 1.7.2