Subversion Repositories chibiosIgnition

Rev

Rev 3 | Rev 9 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 mjames 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
 
7 mjames 19
#include "stdint.h"
3 mjames 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
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
 
63
#define SSD1306_SETCONTRAST 0x81
64
#define SSD1306_DISPLAYALLON_RESUME 0xA4
65
#define SSD1306_DISPLAYALLON 0xA5
66
#define SSD1306_NORMALDISPLAY 0xA6
67
#define SSD1306_INVERTDISPLAY 0xA7
68
#define SSD1306_DISPLAYOFF 0xAE
69
#define SSD1306_DISPLAYON 0xAF
70
 
71
#define SSD1306_SETDISPLAYOFFSET 0xD3
72
#define SSD1306_SETCOMPINS 0xDA
73
 
74
#define SSD1306_SETVCOMDETECT 0xDB
75
 
76
#define SSD1306_SETDISPLAYCLOCKDIV 0xD5
77
#define SSD1306_SETPRECHARGE 0xD9
78
 
79
#define SSD1306_SETMULTIPLEX 0xA8
80
 
81
#define SSD1306_SETLOWCOLUMN 0x00
82
#define SSD1306_SETHIGHCOLUMN 0x10
83
 
84
#define SSD1306_SETSTARTLINE 0x40
85
 
86
#define SSD1306_MEMORYMODE 0x20
87
#define SSD1306_COLUMNADDR 0x21
88
#define SSD1306_PAGEADDR   0x22
89
 
90
#define SSD1306_COMSCANINC 0xC0
91
#define SSD1306_COMSCANDEC 0xC8
92
 
93
#define SSD1306_SEGREMAP 0xA0
94
 
95
#define SSD1306_CHARGEPUMP 0x8D
96
 
97
#define SSD1306_EXTERNALVCC 0x1
98
#define SSD1306_SWITCHCAPVCC 0x2
99
 
100
// Scrolling #defines
101
#define SSD1306_ACTIVATE_SCROLL 0x2F
102
#define SSD1306_DEACTIVATE_SCROLL 0x2E
103
#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3
104
#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26
105
#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27
106
#define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29
107
#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A
108
 
109
 
110
extern const uint16_t WIDTH;
111
extern const uint16_t HEIGHT;
112
extern uint8_t display_buffer[SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8];
113
 
114
extern inline uint8_t getRotation(void);
115
extern inline int16_t width(void);
116
extern inline int16_t height(void);
117
 
118
 
119
/* stolen from AdaFruit class and converted to C */
120
extern  void ssd1306_begin(uint8_t vccstate, uint8_t i2caddr);
121
 
122
extern  void clearDisplay(void);
123
extern  void invertDisplay(uint8_t i);
124
extern  void display(void);
125
 
126
extern  void startscrollright(uint8_t start, uint8_t stop);
127
extern  void startscrollleft(uint8_t start, uint8_t stop);
128
 
129
extern  void startscrolldiagright(uint8_t start, uint8_t stop);
130
extern  void startscrolldiagleft(uint8_t start, uint8_t stop);
131
extern  void stopscroll(void);
132
 
133
extern void dim(uint8_t contrast);
134
 
135
 extern inline void drawPixel(int16_t x, int16_t y, uint16_t color);
136
 
137
  void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
138
  void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
139
 
140
 
141
  inline void drawFastVLineInternal(int16_t x, int16_t y, int16_t h, uint16_t color) __attribute__((always_inline));
142
  inline void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, uint16_t color) __attribute__((always_inline));
143
 
144
 
145
  extern void drawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t color);
146