ssd1306.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* ---------------------------------------------
  2. *ad0x0, 2020
  3. * ----------------------------------------------
  4. */
  5. #ifndef __SSD1306_H
  6. #define __SSD1306_H
  7. #include "stdint.h"
  8. #include "../i2c/ad0x0_i2c.h"
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. #define SSD1306_I2C_ADDRESS ( 0x78 )
  13. /* size */
  14. #define SSD1306_LCDWIDTH 128
  15. #define SSD1306_LCDHEIGHT 32
  16. #define SSD1306_DEFAULT_SPACE 5
  17. /* Commands */
  18. #define SSD1306_SETCONTRAST 0x81
  19. #define SSD1306_DISPLAYALLON_RESUME 0xA4
  20. #define SSD1306_DISPLAYALLON 0xA5
  21. #define SSD1306_NORMALDISPLAY 0xA6
  22. #define SSD1306_INVERTDISPLAY 0xA7
  23. #define SSD1306_DISPLAYOFF 0xAE
  24. #define SSD1306_DISPLAYON 0xAF
  25. #define SSD1306_SETDISPLAYOFFSET 0xD3
  26. #define SSD1306_SETCOMPINS 0xDA
  27. #define SSD1306_SETVCOMDETECT 0xDB
  28. #define SSD1306_SETDISPLAYCLOCKDIV 0xD5
  29. #define SSD1306_SETPRECHARGE 0xD9
  30. #define SSD1306_SETMULTIPLEX 0xA8
  31. #define SSD1306_SETLOWCOLUMN 0x00
  32. #define SSD1306_SETHIGHCOLUMN 0x10
  33. #define SSD1306_SETSTARTLINE 0x40
  34. #define SSD1306_MEMORYMODE 0x20
  35. #define SSD1306_COLUMNADDR 0x21
  36. #define SSD1306_PAGEADDR 0x22
  37. #define SSD1306_COMSCANINC 0xC0
  38. #define SSD1306_COMSCANDEC 0xC8
  39. #define SSD1306_SEGREMAP 0xA0
  40. #define SSD1306_CHARGEPUMP 0x8D
  41. #define SSD1306_EXTERNALVCC 0x1
  42. #define SSD1306_SWITCHCAPVCC 0x2
  43. /* Scrolling #defines */
  44. #define SSD1306_ACTIVATE_SCROLL 0x2F
  45. #define SSD1306_DEACTIVATE_SCROLL 0x2E
  46. #define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3
  47. #define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26
  48. #define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27
  49. #define SSD1306_VERT_AND_RIGHT_HORIZ_SCROLL 0x29
  50. #define SSD1306_VERT_AND_LEFT_HORIZ_SCROLL 0x2A
  51. #define COMAND 0x00
  52. #define DATA 0x40
  53. typedef struct{
  54. unsigned int out;
  55. float t;
  56. uint8_t i2cbuf[2];
  57. char buff[40]; //áóôåð äèñïëåÿ
  58. uint8_t OLED_X,OLED_Y;
  59. void (*clear)(void);
  60. void (*print_at)(unsigned char x, unsigned char y,unsigned char* buf, unsigned char size);
  61. void (*ad0x0_i2c_push)(ADQ_t _ctype,uint8_t _cbyte);
  62. uint8_t (*ad0x0_i2c_get_ext_async2)(uint8_t *_p_out_handle,void **_p_out_i2c_ext_t);
  63. void (*commmand)(unsigned char ControByte, unsigned char DataByte);
  64. void (*OLED_test)(void);
  65. }oled_desc_s;
  66. /* --- Ïðîòîòèïû ôóíêöèé -------------------------------- */
  67. // void delay_ms( unsigned int ms );
  68. // void OLED_CharBig(unsigned int c); /* âûâîä êðóïíûõ ñèìâîëîâ */
  69. // void OLED_Printf(unsigned char* buf, unsigned char size); /* ïå÷àòàåò ñòðîêó ñ ðàçìåðàìè - 0 ñàìûé ìåëêèé 2 - óâåëè÷èíûé - 3 ñàìûé áîëüøîé(òîëüêî äëÿ öèôð) */
  70. // void OLED_DrawImage(unsigned char num_image); /* âûâîäèò êàðòèíêó èç ôëåø */
  71. // void OLED_Bat(unsigned char y,unsigned char x, unsigned char z); /* ðèñóåò áàòàðåéêó ïî êîîðäèíàòàì z - îò 0 äî 10 äåëåíèé */
  72. // void OLED_Mode(char set_mode); /* 1 - inverted / 0 - normal */
  73. // void OLED_Sleep(char set); /* 1 - on sleep / 0 - off sleep */
  74. void OLED_Init2(I2C_TypeDef * _I2C_BASE, oled_desc_s *p_desc);
  75. unsigned char * i16_2s(int16_t value, unsigned char *buffer);
  76. unsigned char * i32_2s(int32_t value, unsigned char *buffer);
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80. #endif /* __SSD1306_H */