OLED_SSD1306_ATY.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * @file OLED_SSD1306_ATY.h
  3. *
  4. * @param Project DEVICE_GENERAL_ATY_LIB
  5. *
  6. * @author ATY
  7. *
  8. * @copyright
  9. * - Copyright 2017 - 2026 MZ-ATY
  10. * - This code follows:
  11. * - MZ-ATY Various Contents Joint Statement -
  12. * <a href="https://mengze.top/MZ-ATY_VCJS">
  13. * https://mengze.top/MZ-ATY_VCJS</a>
  14. * - CC 4.0 BY-NC-SA -
  15. * <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  16. * https://creativecommons.org/licenses/by-nc-sa/4.0/</a>
  17. * - Your use will be deemed to have accepted the terms of this statement.
  18. *
  19. * @brief Dev-style interface for SSD1306 OLED display (I2C)
  20. *
  21. * @version
  22. * - 2_00_251112 > ATY
  23. * -# Refactor to Dev-style interface with platform-agnostic callbacks
  24. ********************************************************************************
  25. */
  26. #ifndef __OLED_SSD1306_ATY_H
  27. #define __OLED_SSD1306_ATY_H
  28. /* Dev 风格头文件不耦合具体硬件头,仅保留字体声明 */
  29. #include "OLED_FONT_ATY.h"
  30. /* 可选 DEBUG 宏占位:
  31. // #define __DEBUG_OLED_SSD1306_ATY
  32. */
  33. /******************************************************************************/
  34. #define BRIGHTNESS 0xCF
  35. #define X_WIDTH 128
  36. #define Y_WIDTH 32
  37. #define MENU_IN 0
  38. #define MENU_OUT 1
  39. /* Dev 风格设备结构体与接口 */
  40. typedef struct {
  41. uint8_t addr; /* I2C 地址,例如 0x78 */
  42. uint8_t channel; /* 可选 I2C 通道(如需) */
  43. int (*i2c_write)(uint8_t addr, const uint8_t* data, uint16_t len, uint8_t channel);
  44. void (*delay_ms)(uint32_t ms);
  45. void (*lock)(uint8_t lock);
  46. uint8_t debugEnable;
  47. void (*LOG)(const char* fmt, ...);
  48. } OLED_SSD1306_ATY_Dev;
  49. /* Dev 风格函数原型 */
  50. void OLED_SSD1306_InitDev(OLED_SSD1306_ATY_Dev* dev, uint8_t addr, uint8_t channel);
  51. int OLED_SSD1306_WriteCmdDev(OLED_SSD1306_ATY_Dev* dev, uint8_t cmd);
  52. int OLED_SSD1306_WriteDataDev(OLED_SSD1306_ATY_Dev* dev, const uint8_t* data, uint16_t len);
  53. void OLED_SSD1306_SetPosDev(OLED_SSD1306_ATY_Dev* dev, uint8_t x, uint8_t y);
  54. void OLED_SSD1306_FillScreenDev(OLED_SSD1306_ATY_Dev* dev, uint8_t fillData);
  55. void OLED_SSD1306_DrawChar8x16Dev(OLED_SSD1306_ATY_Dev* dev, uint8_t x, uint8_t y, const uint8_t symbol[]);
  56. void OLED_SSD1306_DrawChar16x16Dev(OLED_SSD1306_ATY_Dev* dev, uint8_t x, uint8_t y, const uint8_t symbol[]);
  57. void OLED_SSD1306_DrawString8x16Dev(OLED_SSD1306_ATY_Dev* dev, uint8_t x, uint8_t y, const char* str, const uint8_t* font);
  58. #endif /* __OLED_SSD1306_ATY_H */