Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: drive drive1 drive213 drive123213
SSD1327.h
00001 #ifndef SSD1327_H 00002 #define SSD1327_H 00003 00004 #include "mbed.h" 00005 00006 /** 96x96 pixel SSD1327 SeeedStudio 1.12" OLED display 00007 00008 based on https://github.com/blitz/mbed-arch-pro 00009 00010 Example: 00011 @code 00012 #include "mbed.h" 00013 #include "SSD1327.h" 00014 #include "defaultfont.h" 00015 00016 //Pin Defines for I2C Bus 00017 #define D_SDA D3 00018 #define D_SCL D6 00019 I2C i2c(D_SDA, D_SCL); 00020 00021 // Instantiate OLED 00022 static SSD1327 oled { i2c }; 00023 00024 00025 int main() { 00026 oled.set_font(default_font,8,8); 00027 oled.set_text_rc(0,0); 00028 oled.puts("Hello world!"); 00029 while (1) {wait(0.1);} 00030 } 00031 @endcode 00032 */ 00033 00034 class SSD1327 { 00035 I2C &i2c; 00036 00037 00038 public: 00039 /* Create SSD1327 object 00040 */ 00041 SSD1327(I2C &i2c); 00042 00043 const static uint8_t address = 0x3c << 1; 00044 const static uint8_t cmd_mode = 0x80; 00045 const static uint8_t data_mode = 0x40; 00046 00047 const static uint8_t PIXELS = 96; 00048 const static uint8_t PIXEL_PER_CHAR = 8; // if default font used 00049 00050 const static uint8_t ROWS = PIXELS / PIXEL_PER_CHAR; 00051 const static uint8_t COLS = PIXELS / PIXEL_PER_CHAR; 00052 00053 /** Set Gray Level 00054 * @param level - new gray level (0..0xF) 00055 */ 00056 void set_gray_level(unsigned char level); 00057 00058 /** Set text font 00059 * @param Font - font array 00060 * @param width - font width (only 8, 16, 24 or 32) 00061 * @param height - font height 00062 */ 00063 void set_font(const uint8_t *Font, int width, int height); 00064 00065 /** Set new Row and Column 00066 * @param row - new row (0..95) 00067 * @param column - new column (0..95) 00068 */ 00069 void set_rc(unsigned char row, unsigned char column); 00070 00071 /** Set new text Row and Column 00072 * Used after set_font 00073 * @param row - new row (0..96/font_height-1) 00074 * @param column - new column (0..96/font_width-1) 00075 */ 00076 void set_text_rc(unsigned char row, unsigned char column); 00077 00078 /** Put char into display using current font 00079 * @param C - printed char 00080 */ 00081 void putc(unsigned char C); 00082 00083 /** Put string into display using current font 00084 * @param str - printed string 00085 */ 00086 void puts(const char *str); 00087 00088 /** Clear display 00089 */ 00090 void clear(); 00091 00092 // Service low-level functions 00093 00094 bool send(char mode, const char data[], size_t len); 00095 00096 void tribyte_cmd(uint8_t a, uint8_t b, uint8_t c); 00097 00098 void set_column_address(uint8_t start, uint8_t end); 00099 00100 void set_row_address(uint8_t start, uint8_t end); 00101 00102 //bool sendf(char mode, char data[], size_t len); 00103 00104 bool sendx(char mode, char data[], size_t len); 00105 00106 00107 }; 00108 00109 #endif // SSD1327_H 00110 00111 // EOF
Generated on Wed Jul 13 2022 15:02:31 by
