oled.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef __OLED_H
  2. #define __OLED_H
  3. #include "stdlib.h"
  4. #include "stm32f10x.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_SDA_PIN GPIO_Pin_13
  16. #define OLED_SCL_PIN GPIO_Pin_12
  17. #define OLED_PORT GPIOB
  18. #define OLED_RCC RCC_APB2Periph_GPIOB
  19. #define OLED_SCLK_Clr() GPIO_ResetBits(OLED_PORT,OLED_SCL_PIN)//SCL
  20. #define OLED_SCLK_Set() GPIO_SetBits(OLED_PORT,OLED_SCL_PIN)
  21. #define OLED_SDIN_Clr() GPIO_ResetBits(OLED_PORT,OLED_SDA_PIN)//SDA
  22. #define OLED_SDIN_Set() GPIO_SetBits(OLED_PORT,OLED_SDA_PIN)
  23. #define OLED_CMD 0 //写命令
  24. #define OLED_DATA 1 //写数据
  25. //OLED控制用函数
  26. void OLED_WR_Byte(unsigned dat,unsigned cmd);
  27. void OLED_Display_On(void);
  28. void OLED_Display_Off(void);
  29. void OLED_Init(void);//初始化SSD1306
  30. void OLED_Clear(void);//清屏函数,清完屏,整个屏幕是黑色的!和没点亮一样!!!
  31. void OLED_DrawPoint(u8 x,u8 y,u8 t);
  32. void OLED_Fill(u8 x1,u8 y1,u8 x2,u8 y2,u8 dot);
  33. void OLED_ShowChar(u8 x,u8 y,u8 chr,u8 Char_Size);//在指定位置显示一个字符,包括部分字符
  34. void OLED_ShowNum(u8 x,u8 y,u32 num,u8 len,u8 size);
  35. void OLED_ShowString(u8 x,u8 y, u8 *p,u8 Char_Size);//显示一个字符串
  36. void OLED_Set_Pos(unsigned char x, unsigned char y);
  37. void OLED_ShowCHinese(u8 x,u8 y,u8 no);//显示汉字
  38. void OLED_DrawBMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[]);
  39. void fill_picture(unsigned char fill_Data);
  40. void OLED_printf(char x,char y,char *format, ...);
  41. void OLED_ShowText(u8 x,u8 y,char* str,u8 flag);
  42. #endif