1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #ifndef __OLED_H
- #define __OLED_H
- #include "stdlib.h"
- #include "OnBoard.h"
- #define OLED_MODE 0
- #define SIZE 8
- #define XLevelL 0x00
- #define XLevelH 0x10
- #define Max_Column 128
- #define Max_Row 64
- #define Brightness 0xFF
- #define X_WIDTH 128
- #define Y_WIDTH 64
- //-----------------OLED IIC端口定义----------------
- #define OLED_SCLK_PIN P2_4 //数据引脚
- #define OLED_SCLK_NUM GPIO_4
- #define OLED_SDIN_PIN P2_3 //数据引脚
- #define OLED_SDIN_NUM GPIO_3
- #define OLED_PORT P2DIR
- //引脚配置为输出;
- #define OLED_SCLK_PIN_OUT() { OLED_PORT |= OLED_SCLK_NUM; asm("NOP"); }
- //引脚配置为输出;
- #define OLED_SDIN_PIN_OUT() { OLED_PORT |= OLED_SDIN_NUM; asm("NOP"); }
- #define OLED_SCLK_Clr() {OLED_SCLK_PIN = 0; asm("NOP"); }//SCL
- #define OLED_SCLK_Set() {OLED_SCLK_PIN = 1; asm("NOP"); }//SCL
- #define OLED_SDIN_Clr() {OLED_SDIN_PIN = 0; asm("NOP"); }//SDA
- #define OLED_SDIN_Set() {OLED_SDIN_PIN = 1; asm("NOP");}
-
- #define OLED_CMD 0 //写命令
- #define OLED_DATA 1 //写数据
- #define u8 unsigned char
- #define u16 unsigned int
- #define u32 unsigned long
- //OLED控制用函数
- void OLED_WR_Byte(unsigned dat,unsigned cmd);
- void OLED_Display_On(void);
- void OLED_Display_Off(void);
- void OLED_Init(void);//初始化SSD1306
- void OLED_Clear(void);//清屏函数,清完屏,整个屏幕是黑色的!和没点亮一样!!!
- void OLED_DrawPoint(u8 x,u8 y,u8 t);
- void OLED_Fill(u8 x1,u8 y1,u8 x2,u8 y2,u8 dot);
- void OLED_ShowChar(u8 x,u8 y,u8 chr,u8 Char_Size);//在指定位置显示一个字符,包括部分字符
- void OLED_ShowNum(u8 x,u8 y,u32 num,u8 len,u8 size);
- void OLED_ShowString(char x,char y,char *chr,char Char_Size);
- void OLED_Set_Pos(unsigned char x, unsigned char y);
- void OLED_ShowCHinese(u8 x,u8 y,u8 no);//显示汉字
- void OLED_DrawBMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[]);
- void Delay_50ms(unsigned int Del_50ms);
- void Delay_1ms(unsigned int Del_1ms);
- void fill_picture(unsigned char fill_Data);
- void Picture();
- void IIC_Start();
- void IIC_Stop();
- void Write_IIC_Command(unsigned char IIC_Command);
- void Write_IIC_Data(unsigned char IIC_Data);
- void Write_IIC_Byte(unsigned char IIC_Byte);
- void oled_printf(char x,char y,char *p,...);
- void IIC_Wait_Ack();
- void OLED_printf(char x,char y,char Char_Size,char *p,...);
- void OLED_ShowText(u8 x,u8 y,u8* str,u8 size);
- void OLED_ShowCHineseWord(u8 x,u8 y,u8* str);
- #endif
-
|