forked from adafruit/Adafruit_SSD1325_Library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdafruit_SSD1325.h
129 lines (102 loc) · 3.91 KB
/
Adafruit_SSD1325.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*********************************************************************
This is a library for our Monochrome OLEDs based on SSD1325 drivers
Pick one up today in the adafruit shop!
------> http://www.adafruit.com/category/63_98
These displays use SPI to communicate, 4 or 5 pins are required to
interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#ifdef __arm__
#define _BV(b) (1<<(b))
#endif
#include <Adafruit_GFX.h>
#ifndef adagfx_swap
#define adagfx_swap(a, b) { uint8_t t = a; a = b; b = t; }
#endif
#define BLACK 0
#define WHITE 1
/*=========================================================================
SSD1325 Displays
-----------------------------------------------------------------------
The driver is used in multiple displays (128x64, 128x32, etc.).
Select the appropriate display below to create an appropriately
sized framebuffer, etc.
SSD1325_128_64 128x64 pixel display
SSD1325_128_32 128x32 pixel display
You also need to set the LCDWIDTH and LCDHEIGHT defines to an
appropriate size
-----------------------------------------------------------------------*/
#define SSD1325_128_64
/*=========================================================================*/
#if defined SSD1325_128_64 && defined SSD1325_128_32
#error "Only one SSD1325 display can be specified at once in SSD1325.h"
#endif
#if !defined SSD1325_128_64 && !defined SSD1325_128_32
#error "At least one SSD1325 display must be specified in SSD1325.h"
#endif
#if defined SSD1325_128_64
#define SSD1325_LCDWIDTH 128
#define SSD1325_LCDHEIGHT 64
#endif
#if defined SSD1325_128_32
#define SSD1325_LCDWIDTH 128
#define SSD1325_LCDHEIGHT 32
#endif
#define SSD1325_SETCOLADDR 0x15
#define SSD1325_SETROWADDR 0x75
#define SSD1325_SETCONTRAST 0x81
#define SSD1325_SETCURRENT 0x84
#define SSD1325_SETREMAP 0xA0
#define SSD1325_SETSTARTLINE 0xA1
#define SSD1325_SETOFFSET 0xA2
#define SSD1325_NORMALDISPLAY 0xA4
#define SSD1325_DISPLAYALLON 0xA5
#define SSD1325_DISPLAYALLOFF 0xA6
#define SSD1325_INVERTDISPLAY 0xA7
#define SSD1325_SETMULTIPLEX 0xA8
#define SSD1325_MASTERCONFIG 0xAD
#define SSD1325_DISPLAYOFF 0xAE
#define SSD1325_DISPLAYON 0xAF
#define SSD1325_SETPRECHARGECOMPENABLE 0xB0
#define SSD1325_SETPHASELEN 0xB1
#define SSD1325_SETROWPERIOD 0xB2
#define SSD1325_SETCLOCK 0xB3
#define SSD1325_SETPRECHARGECOMP 0xB4
#define SSD1325_SETGRAYTABLE 0xB8
#define SSD1325_SETPRECHARGEVOLTAGE 0xBC
#define SSD1325_SETVCOMLEVEL 0xBE
#define SSD1325_SETVSL 0xBF
#define SSD1325_GFXACCEL 0x23
#define SSD1325_DRAWRECT 0x24
#define SSD1325_COPY 0x25
class Adafruit_SSD1325 : public Adafruit_GFX {
public:
Adafruit_SSD1325(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS) : Adafruit_GFX(128,64), sid(SID), sclk(SCLK), dc(DC), rst(RST), cs(CS) {}
Adafruit_SSD1325(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST) : Adafruit_GFX(128,64), sid(SID), sclk(SCLK), dc(DC), rst(RST), cs(-1) {}
Adafruit_SSD1325(int8_t DC, int8_t RST, int8_t CS) : Adafruit_GFX(128,64), sid(-1), sclk(-1), dc(DC), rst(RST), cs(CS) {}
void begin(void);
void command(uint8_t c);
void data(uint8_t c);
void clearDisplay(void);
void invertDisplay(uint8_t i);
void setBrightness(uint8_t i);
void display();
void drawPixel(int16_t x, int16_t y, uint16_t color);
private:
int8_t sid, sclk, dc, rst, cs;
void spixfer(uint8_t x);
#ifdef __AVR__
volatile uint8_t *mosiport, *clkport;
uint8_t mosipinmask, clkpinmask;
#endif
};