oled.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef __OLED_H
  2. #define __OLED_H
  3. #include "stdlib.h"
  4. #include "OnBoard.h"
  5. #define OLED_MODE 0
  6. #define SIZE 8
  7. #define XLevelL 0x00
  8. #define XLevelH 0x10
  9. #define Max_Column 128
  10. #define Max_Row 64
  11. #define Brightness 0xFF
  12. #define X_WIDTH 128
  13. #define Y_WIDTH 64
  14. //-----------------OLED IIC端口定义----------------
  15. #define OLED_SCLK_PIN P2_4 //数据引脚
  16. #define OLED_SCLK_NUM GPIO_4
  17. #define OLED_SDIN_PIN P2_3 //数据引脚
  18. #define OLED_SDIN_NUM GPIO_3
  19. #define OLED_PORT P2DIR
  20. //引脚配置为输出;
  21. #define OLED_SCLK_PIN_OUT() { OLED_PORT |= OLED_SCLK_NUM; asm("NOP"); }
  22. //引脚配置为输出;
  23. #define OLED_SDIN_PIN_OUT() { OLED_PORT |= OLED_SDIN_NUM; asm("NOP"); }
  24. #define OLED_SCLK_Clr() {OLED_SCLK_PIN = 0; asm("NOP"); }//SCL
  25. #define OLED_SCLK_Set() {OLED_SCLK_PIN = 1; asm("NOP"); }//SCL
  26. #define OLED_SDIN_Clr() {OLED_SDIN_PIN = 0; asm("NOP"); }//SDA
  27. #define OLED_SDIN_Set() {OLED_SDIN_PIN = 1; asm("NOP");}
  28. #define OLED_CMD 0 //写命令
  29. #define OLED_DATA 1 //写数据
  30. #define u8 unsigned char
  31. #define u16 unsigned int
  32. #define u32 unsigned long
  33. //OLED控制用函数
  34. void OLED_WR_Byte(unsigned dat,unsigned cmd);
  35. void OLED_Display_On(void);
  36. void OLED_Display_Off(void);
  37. void OLED_Init(void);//初始化SSD1306
  38. void OLED_Clear(void);//清屏函数,清完屏,整个屏幕是黑色的!和没点亮一样!!!
  39. void OLED_DrawPoint(u8 x,u8 y,u8 t);
  40. void OLED_Fill(u8 x1,u8 y1,u8 x2,u8 y2,u8 dot);
  41. void OLED_ShowChar(u8 x,u8 y,u8 chr,u8 Char_Size);//在指定位置显示一个字符,包括部分字符
  42. void OLED_ShowNum(u8 x,u8 y,u32 num,u8 len,u8 size);
  43. void OLED_ShowString(char x,char y,char *chr,char Char_Size);
  44. void OLED_Set_Pos(unsigned char x, unsigned char y);
  45. void OLED_ShowCHinese(u8 x,u8 y,u8 no);//显示汉字
  46. void OLED_DrawBMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[]);
  47. void Delay_50ms(unsigned int Del_50ms);
  48. void Delay_1ms(unsigned int Del_1ms);
  49. void fill_picture(unsigned char fill_Data);
  50. void Picture();
  51. void IIC_Start();
  52. void IIC_Stop();
  53. void Write_IIC_Command(unsigned char IIC_Command);
  54. void Write_IIC_Data(unsigned char IIC_Data);
  55. void Write_IIC_Byte(unsigned char IIC_Byte);
  56. void oled_printf(char x,char y,char *p,...);
  57. void IIC_Wait_Ack();
  58. void OLED_printf(char x,char y,char Char_Size,char *p,...);
  59. void OLED_ShowText(u8 x,u8 y,u8* str,u8 size);
  60. void OLED_ShowCHineseWord(u8 x,u8 y,u8* str);
  61. #endif