uuu000

oled_ssd1306.h

Nov 5th, 2022
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. /*
  2. * Created: 19.06.2016 11:38:00
  3. * Author: Ulrich
  4. */
  5.  
  6. #ifndef __oled_H
  7. #define __oled_H
  8.  
  9. #include <inttypes.h>
  10. #include <avr/io.h>
  11. #include <avr/pgmspace.h>
  12. #include <stdlib.h>
  13. #include <stdarg.h>
  14. #include <ctype.h>
  15. #include <string.h>
  16. #include <util/delay.h>
  17.  
  18. #define SDA_PIN PC4
  19. #define SCL_PIN PC5
  20. #define I2C_PORT PORTC
  21.  
  22. #define OLED_I2C_ADDR 0x78
  23. #define SCL_CLOCK 400000UL
  24.  
  25. void oled_init(void);
  26. void oled_clear_screen(void);
  27. void oled_font_size (uint8_t byte);
  28. void oled_gotoxy(uint8_t x, uint8_t y);
  29. void oled_write_char(char c);
  30. void oled_write_str(char* str);
  31. void oled_write_P (const char *Buffer,...);
  32.  
  33. #define oled_write(format, args...) oled_write_P(PSTR(format) , ## args)
  34.  
  35. #define COMMAND 0x00
  36. #define DATA 0x40
  37.  
  38. #define SET_CONTRAST_CONTROL 0x81
  39. #define SET_DISPLAY_ON 0xAF
  40. #define SET_DISPLAY_OFF 0xAE
  41. #define SET_DISPLAY_NORMAL 0xA6
  42. #define SET_DISPLAY_INVERSE 0xA7
  43. #define ENTIRE_DISPLAY_ON 0xA4
  44.  
  45. #define SET_MEMORY_ADDR_MODE 0x20
  46. #define HORIZONTAL_ADDRESSING_MODE 0x00
  47. #define VERTICAL_ADDRESSING_MODE 0x01
  48. #define PAGE_ADDRESSING_MODE 0x02
  49.  
  50. #define SET_PAGE_START 0xB0 //~0xB7
  51. #define SET_COLUMN_ADDRESS 0x21
  52. #define SET_PAGE_ADDRESS 0x22
  53.  
  54. #define SET_COM_OUTPUT_NORMAL 0xC0
  55. #define SET_COM_OUTPUT_REMAPPED 0xC8
  56.  
  57. #define SET_DISPLAY_OFFSET 0xD3
  58. #define SET_DISPLAY_CLOCK 0xD5
  59. #define SET_PRECHARGE_PERIOD 0xD9
  60. #define SET_COM_PINS 0xDA
  61.  
  62. #define SET_VCOMH_DESELECT 0xDB //0x00,0x20,0x30
  63.  
  64. #define SET_LOWER_COLUMN 0x00
  65. #define SET_HIGHER_COLUMN 0x10
  66. #define SET_DISPLAY_START_LINE 0x40
  67.  
  68. #define SET_SEGMENT_REMAP_O1 0xA0
  69. #define SET_SEGMENT_REMAP_O2 0xA1
  70.  
  71. #define SET_MULTIPLEX_RATIO 0xA8
  72. #define COMMAND_NO_OPERATION 0xE3
  73.  
  74. #define CHARGE_BUMB_SETTING 0x8D
  75.  
  76.  
  77. #endif // __oled_H
  78.  
Advertisement
Add Comment
Please, Sign In to add comment