Subversion Repositories chibiosIgnition

Rev

Rev 3 | 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
 
19
 
20
typedef uint8_t boolean;
21
static const boolean true = 1;
22
static const boolean false = 0;
23
 
24
#define BLACK  0
25
#define WHITE  1
26
#define INVERT 2
27
 
28
// this driver can cope with more than one physical display of the same type.
29
 
30
#define MAX_PHYS_DISPLAYS 1
31
 
32
/*=========================================================================
33
    SSD1306 Displays
34
    -----------------------------------------------------------------------
35
    The driver is used in multiple displays (128x64, 128x32, etc.).
36
    Select the appropriate display below to create an appropriately
37
    sized framebuffer, etc.
38
 
39
    SSD1306_128_64  128x64 pixel display
40
 
41
    SSD1306_128_32  128x32 pixel display
42
 
43
    -----------------------------------------------------------------------*/
44
        #define SSD1306_128_64
45
/*=========================================================================*/
46
 
47
#if defined SSD1306_128_64 && defined SSD1306_128_32
48
  #error "Only one SSD1306 display can be specified at once in SSD1306.h"
49
#endif
50
#if !defined SSD1306_128_64 && !defined SSD1306_128_32
51
  #error "At least one SSD1306 display must be specified in SSD1306.h"
52
#endif
53
 
54
// the 1106 has a RAM width of 128
55
#if defined SSD1306_128_64
56
  #define SSD1306_LCDWIDTH                  128
57
  #define SSD1306_LCDHEIGHT                 64
58
  #define SSD1306_RAMWIDTH                 128
59
#endif
60
#if defined SSD1306_128_32
61
  #define SSD1306_LCDWIDTH                  128
62
  #define SSD1306_LCDHEIGHT                 32
63
  #define SSD1306_RAMWIDTH                 128
64
#endif
65
 
66
#define SSD1306_SETCONTRAST 0x81
67
#define SSD1306_DISPLAYALLON_RESUME 0xA4
68
#define SSD1306_DISPLAYALLON 0xA5
69
#define SSD1306_NORMALDISPLAY 0xA6
70
#define SSD1306_INVERTDISPLAY 0xA7
71
#define SSD1306_DISPLAYOFF 0xAE
72
#define SSD1306_DISPLAYON 0xAF
73
 
74
#define SSD1306_SETDISPLAYOFFSET 0xD3
75
#define SSD1306_SETCOMPINS 0xDA
76
 
77
#define SSD1306_SETVCOMDETECT 0xDB
78
 
79
#define SSD1306_SETDISPLAYCLOCKDIV 0xD5
80
#define SSD1306_SETPRECHARGE 0xD9
81
 
82
#define SSD1306_SETMULTIPLEX 0xA8
83
 
84
#define SSD1306_SETLOWCOLUMN 0x00
85
#define SSD1306_SETHIGHCOLUMN 0x10
86
 
87
#define SSD1306_SETSTARTLINE 0x40
88
 
89
#define SSD1306_MEMORYMODE 0x20
90
#define SSD1306_COLUMNADDR 0x21
91
#define SSD1306_PAGEADDR   0x22
92
 
93
#define SSD1306_COMSCANINC 0xC0
94
#define SSD1306_COMSCANDEC 0xC8
95
 
96
#define SSD1306_SEGREMAP 0xA0
97
 
98
#define SSD1306_CHARGEPUMP 0x8D
99
 
100
#define SSD1306_EXTERNALVCC 0x1
101
#define SSD1306_SWITCHCAPVCC 0x2
102
 
103
// Scrolling #defines
104
#define SSD1306_ACTIVATE_SCROLL 0x2F
105
#define SSD1306_DEACTIVATE_SCROLL 0x2E
106
#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3
107
#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26
108
#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27
109
#define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29
110
#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A
111
 
112
 
113
extern const uint16_t WIDTH;
114
extern const uint16_t HEIGHT;
115
extern uint8_t display_buffer[SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8];
116
 
117
extern inline uint8_t getRotation(void);
118
extern inline int16_t width(void);
119
extern inline int16_t height(void);
120
 
121
 
122
/* stolen from AdaFruit class and converted to C */
123
extern  void ssd1306_begin(uint8_t vccstate, uint8_t i2caddr);
124
 
125
extern  void clearDisplay(void);
126
extern  void invertDisplay(uint8_t i);
127
extern  void display(void);
128
 
129
extern  void startscrollright(uint8_t start, uint8_t stop);
130
extern  void startscrollleft(uint8_t start, uint8_t stop);
131
 
132
extern  void startscrolldiagright(uint8_t start, uint8_t stop);
133
extern  void startscrolldiagleft(uint8_t start, uint8_t stop);
134
extern  void stopscroll(void);
135
 
136
extern void dim(uint8_t contrast);
137
 
138
 extern inline void drawPixel(int16_t x, int16_t y, uint16_t color);
139
 
140
  void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
141
  void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
142
 
143
 
144
  inline void drawFastVLineInternal(int16_t x, int16_t y, int16_t h, uint16_t color) __attribute__((always_inline));
145
  inline void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, uint16_t color) __attribute__((always_inline));
146
 
147
 
148
  extern void drawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t color);
149