This is the OLED library for 128x64 display
Embed:
(wiki syntax)
Show/hide line numbers
oled.h
00001 #ifndef __OLED_H 00002 #define __OLED_H 00003 00004 00005 //-----------------OLEDport defination---------------- 00006 #define OLED_CMD 0 //Send commend 00007 #define OLED_DATA 1 //Send data 00008 00009 #define FONT12 12 00010 #define FONT16 16 00011 #define LINE_1_FONT12 0 00012 #define LINE_2_FONT12 12 00013 #define LINE_3_FONT12 24 00014 #define LINE_4_FONT12 36 00015 #define LINE_5_FONT12 48 00016 #define LINE_6_FONT12 52 00017 00018 00019 #define LINE_1_FONT16 0 00020 #define LINE_2_FONT16 16 00021 #define LINE_3_FONT16 32 00022 #define LINE_4_FONT16 48 00023 00024 00025 class oled 00026 { 00027 public: 00028 00029 /** Create a oled control interface 00030 * 00031 * @param oled_SCL A DigitalOut, Clock pin 00032 * @param oled_SDA A DigitalOut, Data pin 00033 * @param oled_RES A DigitalOut, Reset pin 00034 * @param oled_DC A DigitalOut, Command Pin 00035 */ 00036 oled(PinName oled_SCL, PinName oled_SDA, PinName oled_RES, PinName oled_DC); 00037 00038 /** Draw a point on screen at specific co-ordinate 00039 * 00040 * @param x An unisgned integer byte, X co-ordinate of the point to be draw on screen (Range from 0~127) 00041 * @param y An unisgned integer byte, Y co-ordinate of the point to be draw on screen (Range from 0~63) 00042 * @param t A boolean, 1 = Fill, 0=Clear 00043 */ 00044 void OLED_DrawPoint(uint8_t x,uint8_t y,bool t); 00045 00046 /** Display a charcter at specific position 00047 * 00048 * @param x An unisgned integer byte, X co-ordinate of the point to be draw on screen (Range from 0~127) 00049 * @param y An unisgned integer byte, Y co-ordinate of the point to be draw on screen (Range from 0~63) 00050 * @param chr An unisgned integer byte, the character to be display 00051 * @param size An unisgned integer byte, the font size of the character (12pt or 16pt) 00052 * @param mode A boolean, 0 = inverted display, 1 = normal display 00053 */ 00054 void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t size,bool mode); 00055 00056 /** Display a number at specific position 00057 * 00058 * @param x An unisgned integer byte, X co-ordinate of the point to be draw on screen (Range from 0~127) 00059 * @param y An unisgned integer byte, Y co-ordinate of the point to be draw on screen (Range from 0~63) 00060 * @param size An unisgned integer byte, the font size of the character (12pt or 16pt) 00061 * @param num An unisgned integer 32bit, value of the number to be display 00062 */ 00063 void OLED_ShowNumber(uint8_t x,uint8_t y,uint8_t size, uint32_t num ); 00064 00065 /** Display a string at specific position with 16 x 8 font size 00066 * 00067 * @param x An unisgned integer byte, X co-ordinate of the point to be draw on screen (Range from 0~127) 00068 * @param y An unisgned integer byte, Y co-ordinate of the point to be draw on screen (Range from 0~63) 00069 * @param size An unisgned integer byte, the font size of the character (12pt or 16pt) 00070 * @param *p A string pointer, the address of the string to be display on screen (Maximium 16 characters for a line) 00071 */ 00072 void OLED_ShowString(uint8_t x,uint8_t y,uint8_t size,const uint8_t *p); 00073 00074 00075 void OLED_Display_On(void); 00076 void OLED_Display_Off(void); 00077 void OLED_Refresh(void); 00078 void OLED_Clear(void); 00079 00080 00081 private: 00082 DigitalOut _oled_SCL; 00083 DigitalOut _oled_SDA; 00084 DigitalOut _oled_RES; 00085 DigitalOut _oled_DC; 00086 uint8_t _OLED_GRAM[128][8]; 00087 uint32_t oled_pow(uint8_t m,uint8_t n); 00088 void OLED_WR_Byte(uint8_t dat,uint8_t cmd); 00089 void OLED_RST_Clr(void); 00090 void OLED_RST_Set(void); 00091 void OLED_RS_Clr(void); 00092 void OLED_RS_Set(void); 00093 void OLED_SCLK_Clr(void); 00094 void OLED_SCLK_Set(void); 00095 void OLED_SDIN_Clr(void); 00096 void OLED_SDIN_Set(void); 00097 00098 00099 }; 00100 00101 #endif 00102
Generated on Fri Jul 22 2022 07:29:45 by
1.7.2