OLED_SSD1327.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * OLED_SSD1327.h
  3. *
  4. * The MIT License.
  5. * Created on: 16.07.2020
  6. * Author: Mateusz Salamon
  7. * www.msalamon.pl
  8. * mateusz@msalamon.pl
  9. */
  10. #ifndef OLED_SSD1327_H_
  11. #define OLED_SSD1327_H_
  12. /*
  13. *
  14. * SETTINGS
  15. *
  16. * Please set only one interface. It won't work with both one time.
  17. *
  18. */
  19. //#define SSD1327_SPI_CONTROL
  20. #define SSD1327_I2C_CONTROL
  21. #ifdef SSD1327_I2C_CONTROL
  22. //#define SSD1327_I2C_DMA_ENABLE
  23. #define SSD1327_I2C_ADDRESS 0x78
  24. #endif
  25. #ifdef SSD1327_SPI_CONTROL
  26. #define SSD1327_RESET_USE
  27. #define SSD1327_SPI_DMA_ENABLE
  28. #define SPI_CS_HARDWARE_CONTROL
  29. #endif
  30. //
  31. // Resolution
  32. //
  33. #define SSD1327_LCDWIDTH 128
  34. #define SSD1327_LCDHEIGHT 96
  35. /*
  36. * Please set what functionality you want to use.
  37. * Some functions need other functionalities. It should works automatically.
  38. *
  39. * 1 - will be compiled
  40. * 0 - won't be compiled
  41. */
  42. #define GRAPHIC_ACCELERATION_COMMANDS 0
  43. /****************************************************************/
  44. //
  45. // Commands
  46. //
  47. #define SSD1327_SETCOLUMNADDRESS 0x15
  48. #define SSD1327_SETROWADDRESS 0x75
  49. #define SSD1327_SETCONTRASTCURRENT 0x81
  50. #define SSD1327_NOP 0x84
  51. #define SSD1327_SEGREMAP 0xA0
  52. #define SSD1327_SETDISPLAYSTARTLINE 0xA1
  53. #define SSD1327_SETDISPLAYOFFSET 0xA2
  54. #define SSD1327_DISPLAYALLON_RESUME 0xA4
  55. #define SSD1327_DISPLAYALLON 0xA5
  56. #define SSD1327_NORMALDISPLAY 0xA6
  57. #define SSD1327_INVERTDISPLAY 0xA7
  58. #define SSD1327_SETMULTIPLEX 0xA8
  59. #define SSD1327_FUNCTIONSELECTIONA 0xAB
  60. #define SSD1327_DISPLAYOFF 0xAE
  61. #define SSD1327_DISPLAYON 0xAF
  62. #define SSD1327_SETPHASELENGTH 0xB1
  63. #define SSD1327_SETFRONTCLOCKDIVIDER_OSCILLATORFREQUENCY 0xB3
  64. #define SSD1327_SETGPIO 0xB5
  65. #define SSD1327_SETSECONDPRECHARGEPERTIOD 0xB6
  66. #define SSD1327_SETGRAYSCALETABLE 0xB8
  67. #define SSD1327_SELECTDEFAULTLINEARGRAYSCALETABLE 0xB9
  68. #define SSD1327_SETPRECHARGEVOLTAGE 0xBC
  69. #define SSD1327_SETSETVCOMVOLTAGE 0xBE
  70. #define SSD1327_FUNCTIONSELECTIONB 0xD5
  71. #define SSD1327_SETCOMMANDLOCK 0xFD
  72. //
  73. // Scrolling #defines
  74. //
  75. #define SSD1327_ACTIVATE_SCROLL 0x2F
  76. #define SSD1327_DEACTIVATE_SCROLL 0x2E
  77. #define SSD1327_RIGHT_HORIZONTAL_SCROLL 0x26
  78. #define SSD1327_LEFT_HORIZONTAL_SCROLL 0x27
  79. //
  80. // Colors
  81. //
  82. #define BLACK 0
  83. // Grays between
  84. #define WHITE 15
  85. //
  86. // Scrolling enums
  87. //
  88. typedef enum
  89. {
  90. SCROLL_EVERY_5_FRAMES,
  91. SCROLL_EVERY_64_FRAMES,
  92. SCROLL_EVERY_128_FRAMES,
  93. SCROLL_EVERY_256_FRAMES,
  94. SCROLL_EVERY_3_FRAMES,
  95. SCROLL_EVERY_4_FRAMES,
  96. SCROLL_EVERY_25_FRAMES,
  97. SCROLL_EVERY_2_FRAMES,
  98. } scroll_horizontal_speed;
  99. //
  100. // Functions
  101. //
  102. #ifdef SSD1327_I2C_CONTROL
  103. void SSD1327_I2cInit(I2C_HandleTypeDef *i2c);
  104. #endif
  105. #if defined(SSD1327_SPI_CONTROL) && !defined(SSD1327_SPI_DMA_ENABLE)
  106. void SSD1327_DmaEndCallback(SPI_HandleTypeDef *hspi);
  107. #endif
  108. //
  109. // Configuration
  110. //
  111. void SSD1327_DisplayON(uint8_t On);
  112. void SSD1327_InvertColors(uint8_t Invert);
  113. void SSD1327_RotateDisplay(uint8_t Rotate);
  114. void SSD1327_SetContrast(uint8_t Contrast);
  115. //
  116. // Drawing
  117. //
  118. void SSD1327_DrawPixel(int16_t x, int16_t y, uint8_t Color);
  119. void SSD1327_Clear(uint8_t Color);
  120. void SSD1327_Display(void);
  121. void SSD1327_Bitmap(uint8_t *bitmap);
  122. #if GRAPHIC_ACCELERATION_COMMANDS == 1
  123. //
  124. // Graphic Acceleration Commands
  125. //
  126. void SSD1327_StartScrollRight(uint8_t StartPage, uint8_t EndPage, scroll_horizontal_speed Speed);
  127. void SSD1327_StartScrollLeft(uint8_t StartPage, uint8_t EndPage, scroll_horizontal_speed Speed);
  128. void SSD1327_StopScroll(void);
  129. #endif
  130. #endif /* OLED_SSD1327_H_ */