Subversion Repositories chibiosIgnition

Rev

Rev 14 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*********************************************************************
  2. This is a library for our Monochrome OLEDs based on SSD1306 drivers
  3.  
  4.   Pick one up today in the adafruit shop!
  5.   ------> http://www.adafruit.com/category/63_98
  6.  
  7. These displays use SPI to communicate, 4 or 5 pins are required to  
  8. interface
  9.  
  10. Adafruit invests time and resources providing this open source code,
  11. please support Adafruit and open-source hardware by purchasing
  12. products from Adafruit!
  13.  
  14. Written by Limor Fried/Ladyada  for Adafruit Industries.  
  15. BSD license, check license.txt for more information
  16. All text above, and the splash screen must be included in any redistribution
  17. *********************************************************************/
  18.  
  19. #include "stdint.h"
  20.  
  21. #define BLACK  0
  22. #define WHITE  1
  23. #define INVERT 2
  24.  
  25. // this driver can cope with more than one physical display of the same type.
  26.  
  27. #define MAX_PHYS_DISPLAYS 1
  28.  
  29. /*=========================================================================
  30.     SSD1306 Displays
  31.     -----------------------------------------------------------------------
  32.     The driver is used in multiple displays (128x64, 128x32, etc.).
  33.     Select the appropriate display below to create an appropriately
  34.     sized framebuffer, etc.
  35.  
  36.     SSD1306_128_64  128x64 pixel display
  37.  
  38.     SSD1306_128_32  128x32 pixel display
  39.  
  40.     -----------------------------------------------------------------------*/
  41.         #define SSD1306_128_64
  42. /*=========================================================================*/
  43.  
  44. #if defined SSD1306_128_64 && defined SSD1306_128_32
  45.   #error "Only one SSD1306 display can be specified at once in SSD1306.h"
  46. #endif
  47. #if !defined SSD1306_128_64 && !defined SSD1306_128_32 && !defined SSD1306_132_64
  48.  #error "At least one SSD1306 display must be specified in SSD1306.h"
  49. #endif
  50.  
  51. // the 1106 has a RAM width of 128
  52. #if defined SSD1306_128_64
  53.   #define SSD1306_LCDWIDTH                  128
  54.   #define SSD1306_LCDHEIGHT                 64
  55.   #define SSD1306_RAMWIDTH                 128
  56. #endif
  57. #if defined SSD1306_128_32
  58.   #define SSD1306_LCDWIDTH                  128
  59.   #define SSD1306_LCDHEIGHT                 32
  60.   #define SSD1306_RAMWIDTH                 128
  61. #endif
  62. #if defined SSD1306_132_64
  63.   #define SSD1306_LCDWIDTH                  128
  64.   #define SSD1306_LCDHEIGHT                 64
  65.   #define SSD1306_RAMWIDTH                 132
  66. #endif
  67.  
  68.  
  69. #define SSD1306_SETCONTRAST 0x81
  70. #define SSD1306_DISPLAYALLON_RESUME 0xA4
  71. #define SSD1306_DISPLAYALLON 0xA5
  72. #define SSD1306_NORMALDISPLAY 0xA6
  73. #define SSD1306_INVERTDISPLAY 0xA7
  74. #define SSD1306_DISPLAYOFF 0xAE
  75. #define SSD1306_DISPLAYON 0xAF
  76.  
  77. #define SSD1306_SETDISPLAYOFFSET 0xD3
  78. #define SSD1306_SETCOMPINS 0xDA
  79.  
  80. #define SSD1306_SETVCOMDETECT 0xDB
  81.  
  82. #define SSD1306_SETDISPLAYCLOCKDIV 0xD5
  83. #define SSD1306_SETPRECHARGE 0xD9
  84.  
  85. #define SSD1306_SETMULTIPLEX 0xA8
  86.  
  87. #define SSD1306_SETLOWCOLUMN 0x00
  88. #define SSD1306_SETHIGHCOLUMN 0x10
  89.  
  90. #define SSD1306_SETSTARTLINE 0x40
  91.  
  92. #define SSD1306_MEMORYMODE 0x20
  93. #define SSD1306_COLUMNADDR 0x21
  94. #define SSD1306_PAGEADDR   0x22
  95.  
  96. #define SSD1306_COMSCANINC 0xC0
  97. #define SSD1306_COMSCANDEC 0xC8
  98.  
  99. #define SSD1306_SEGREMAP 0xA0
  100.  
  101. #define SSD1306_CHARGEPUMP 0x8D
  102.  
  103. #define SSD1306_EXTERNALVCC 0x1
  104. #define SSD1306_SWITCHCAPVCC 0x2
  105.  
  106. // Scrolling #defines
  107. #define SSD1306_ACTIVATE_SCROLL 0x2F
  108. #define SSD1306_DEACTIVATE_SCROLL 0x2E
  109. #define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3
  110. #define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26
  111. #define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27
  112. #define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29
  113. #define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A
  114.  
  115.  
  116. extern const uint16_t WIDTH;
  117. extern const uint16_t HEIGHT;
  118. extern uint8_t display_buffer[SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8];
  119.  
  120. extern uint8_t getRotation(void);
  121. extern int16_t width(void);
  122. extern int16_t height(void);
  123.  
  124.  
  125. /* stolen from AdaFruit class and converted to C */
  126. extern  void ssd1306_begin(uint8_t vccstate, uint8_t i2caddr);
  127.  
  128. extern  void clearDisplay(void);
  129. extern  void invertDisplay(uint8_t i);
  130. extern  void display(void);
  131.  
  132. extern  void startscrollright(uint8_t start, uint8_t stop);
  133. extern  void startscrollleft(uint8_t start, uint8_t stop);
  134.  
  135. extern  void startscrolldiagright(uint8_t start, uint8_t stop);
  136. extern  void startscrolldiagleft(uint8_t start, uint8_t stop);
  137. extern  void stopscroll(void);
  138.  
  139.  
  140. extern void dim(uint8_t contrast);
  141.  
  142. extern  void drawPixel(int16_t x, int16_t y, uint16_t color);
  143.  
  144. extern void drawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t color);
  145.