oled.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef __OLED_H
  2. #define __OLED_H
  3. #include "STC8XXXX.H"
  4. #define u8 unsigned char
  5. #define u16 unsigned int
  6. #define u32 unsigned int
  7. #define OLED_CMD 0 //写命令
  8. #define OLED_DATA 1 //写数据
  9. sbit OLED_SCL=P3^5;//SCL
  10. sbit OLED_SDA=P3^6;//SDA
  11. sbit OLED_RES =P2^3;//RES
  12. //-----------------OLED端口定义----------------
  13. #define OLED_SCL_Clr() OLED_SCL=0
  14. #define OLED_SCL_Set() OLED_SCL=1
  15. #define OLED_SDA_Clr() OLED_SDA=0
  16. #define OLED_SDA_Set() OLED_SDA=1
  17. #define OLED_RES_Clr() OLED_RES=0
  18. #define OLED_RES_Set() OLED_RES=1
  19. //OLED控制用函数
  20. void delay_ms(unsigned int ms);
  21. void OLED_ColorTurn(u8 i);
  22. void OLED_DisplayTurn(u8 i);
  23. void OLED_WR_Byte(u8 dat,u8 cmd);
  24. void OLED_Set_Pos(u8 x, u8 y);
  25. void OLED_Display_On(void);
  26. void OLED_Display_Off(void);
  27. void OLED_Clear(void);
  28. void OLED_ShowChar(u8 x,u8 y,u8 chr,u8 sizey);
  29. unsigned int oled_pow(u8 m,u8 n);
  30. void OLED_ShowNum(u8 x,u8 y,u32 num,u8 len,u8 sizey);
  31. void OLED_ShowString(u8 x,u8 y,u8 *chr,u8 sizey);
  32. void OLED_ShowChinese(u8 x,u8 y,u8 no,u8 sizey);
  33. void OLED_DrawBMP(int x,int y,unsigned char sizex,unsigned char sizey,unsigned char BMP[]);
  34. void OLED_Init(void);
  35. void OLED_Display(void);
  36. void OLED_Write_Data(unsigned char dat);
  37. void OLED_DrawPixel(unsigned char x,unsigned char y,unsigned char color);
  38. void OLED_display(void);
  39. void _swap_char(unsigned char* a,unsigned char* b);
  40. void OLED_DrawLine(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2,unsigned char color);
  41. void OLED_display_clear();
  42. void OLED_Draw_Byte(unsigned char *pBuf, unsigned char mask, unsigned char offset, bit reserve_hl);
  43. void OLED_DrawChar(u8 x, u8 y, u8 chr);
  44. void OLED_DrawNum(unsigned char digit, unsigned char len);
  45. void OLED_Set_Posi(unsigned char x, unsigned char y);
  46. void OLED_DrawBMP_2(u8 x0, u8 y0, u8 x1, u8 y1, u8 *BMP);
  47. #endif