Subversion Repositories DashDisplay

Rev

Rev 28 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 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 2
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
#if defined SSD1306_128_64
55
  #define SSD1306_LCDWIDTH                  128
56
  #define SSD1306_LCDHEIGHT                 64
57
#endif
58
#if defined SSD1306_128_32
59
  #define SSD1306_LCDWIDTH                  128
60
  #define SSD1306_LCDHEIGHT                 32
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[MAX_PHYS_DISPLAYS][SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8];
113
 
46 mjames 114
extern uint8_t getRotation(void);
115
extern int16_t width(void);
116
extern int16_t height(void);
2 mjames 117
 
46 mjames 118
extern void fastSPIwrite(uint8_t d);
2 mjames 119
 
120
 
121
/* stolen from AdaFruit class and converted to C */
122
void ssd1306_begin(uint8_t vccstate, uint8_t i2caddr);
123
extern  void ssd1306_command(uint8_t c);
124
extern  void ssd1306_data(uint8_t c);
125
 
126
extern  void clearDisplay(void);
127
extern  void invertDisplay(uint8_t i);
128
extern  void display();
129
 
130
extern  void startscrollright(uint8_t start, uint8_t stop);
131
extern  void startscrollleft(uint8_t start, uint8_t stop);
132
 
133
extern  void startscrolldiagright(uint8_t start, uint8_t stop);
134
extern  void startscrolldiagleft(uint8_t start, uint8_t stop);
135
extern  void stopscroll(void);
136
 
137
extern void dim(uint8_t contrast);
138
 
46 mjames 139
 extern void drawPixel(int16_t x, int16_t y, uint16_t color);
2 mjames 140
 
141
  void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
142
  void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
143
 
144
 
145
  inline void drawFastVLineInternal(int16_t x, int16_t y, int16_t h, uint16_t color) __attribute__((always_inline));
146
  inline void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, uint16_t color) __attribute__((always_inline));
147
 
148
 
149
  extern void drawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t color);
150
 
151
 
152
  extern  void select_display(int i) ; // select physical display [i]
153
 
154
  extern  inline uint8_t * display_address(void) ;