ssd13x6.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef _SSD13X6_H_
  2. #define _SSD13X6_H_
  3. /* For uint(X)_t */
  4. #include <stdint.h>
  5. /* For booooool */
  6. #include <stdbool.h>
  7. #include "sdkconfig.h"
  8. #include "ssd13x6_err.h"
  9. #define SSD_ALWAYS_INLINE __attribute__( ( always_inline ) )
  10. #if ! defined BIT
  11. #define BIT( n ) ( 1 << n )
  12. #endif
  13. typedef uint8_t SSDCmd;
  14. typedef enum {
  15. AddressMode_Horizontal = 0,
  16. AddressMode_Vertical,
  17. AddressMode_Page,
  18. AddressMode_Invalid
  19. } SSD13x6_AddressMode;
  20. struct SSD13x6_Device;
  21. /*
  22. * These can optionally return a succeed/fail but are as of yet unused in the driver.
  23. */
  24. typedef bool ( *WriteCommandProc ) ( struct SSD13x6_Device* DeviceHandle, SSDCmd Command );
  25. typedef bool ( *WriteDataProc ) ( struct SSD13x6_Device* DeviceHandle, const uint8_t* Data, size_t DataLength );
  26. typedef bool ( *ResetProc ) ( struct SSD13x6_Device* DeviceHandle );
  27. struct spi_device_t;
  28. typedef struct spi_device_t* spi_device_handle_t;
  29. struct SSD13x6_FontDef;
  30. struct SSD13x6_Device {
  31. /* I2C Specific */
  32. int Address;
  33. /* SPI Specific */
  34. spi_device_handle_t SPIHandle;
  35. int RSTPin;
  36. int CSPin;
  37. /* Everything else */
  38. int Width;
  39. int Height;
  40. enum { SSD1306, SSD1326 } Model;
  41. uint8_t ReMap;
  42. uint8_t* Framebuffer;
  43. int FramebufferSize;
  44. WriteCommandProc WriteCommand;
  45. WriteDataProc WriteData;
  46. ResetProc Reset;
  47. const struct SSD13x6_FontDef* Font;
  48. bool FontForceProportional;
  49. bool FontForceMonospace;
  50. };
  51. void SSD13x6_SetMuxRatio( struct SSD13x6_Device* DeviceHandle, uint8_t Ratio );
  52. void SSD13x6_SetDisplayOffset( struct SSD13x6_Device* DeviceHandle, uint8_t Offset );
  53. void SSD13x6_SetDisplayStartLines( struct SSD13x6_Device* DeviceHandle );
  54. void SSD13x6_SetSegmentRemap( struct SSD13x6_Device* DeviceHandle, bool Remap );
  55. void SSD13x6_SetContrast( struct SSD13x6_Device* DeviceHandle, uint8_t Contrast );
  56. void SSD13x6_EnableDisplayRAM( struct SSD13x6_Device* DeviceHandle );
  57. void SSD13x6_DisableDisplayRAM( struct SSD13x6_Device* DeviceHandle );
  58. void SSD13x6_SetInverted( struct SSD13x6_Device* DeviceHandle, bool Inverted );
  59. void SSD13x6_SetHFlip( struct SSD13x6_Device* DeviceHandle, bool On );
  60. void SSD13x6_SetVFlip( struct SSD13x6_Device* DeviceHandle, bool On );
  61. void SSD13x6_DisplayOn( struct SSD13x6_Device* DeviceHandle );
  62. void SSD13x6_DisplayOff( struct SSD13x6_Device* DeviceHandle );
  63. void SSD13x6_SetDisplayAddressMode( struct SSD13x6_Device* DeviceHandle, SSD13x6_AddressMode AddressMode );
  64. void SSD13x6_Update( struct SSD13x6_Device* DeviceHandle );
  65. void SSD13x6_SetDisplayClocks( struct SSD13x6_Device* DeviceHandle, uint32_t DisplayClockDivider, uint32_t OSCFrequency );
  66. void SSD13x6_SetColumnAddress( struct SSD13x6_Device* DeviceHandle, uint8_t Start, uint8_t End );
  67. void SSD13x6_SetPageAddress( struct SSD13x6_Device* DeviceHandle, uint8_t Start, uint8_t End );
  68. bool SSD13x6_HWReset( struct SSD13x6_Device* DeviceHandle );
  69. bool SSD13x6_Init_I2C( struct SSD13x6_Device* DeviceHandle, int Width, int Height, int I2CAddress, int ResetPin, WriteCommandProc WriteCommand, WriteDataProc WriteData, ResetProc Reset );
  70. bool SSD13x6_Init_SPI( struct SSD13x6_Device* DeviceHandle, int Width, int Height, int ResetPin, int CSPin, spi_device_handle_t SPIHandle, WriteCommandProc WriteCommand, WriteDataProc WriteData, ResetProc Reset );
  71. void SSD13x6_WriteRawData( struct SSD13x6_Device* DeviceHandle, uint8_t* Data, size_t DataLength );
  72. #endif