-
Notifications
You must be signed in to change notification settings - Fork 1
/
PCD8544.h
123 lines (93 loc) · 4.11 KB
/
PCD8544.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
/*
* PCD8544 - Interface with Philips PCD8544 (or compatible) LCDs.
*
* Copyright (c) 2010 Carlos Rodrigues <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef PCD8544_H
#define PCD8544_H
#if ARDUINO < 100
#include <WProgram.h>
#else
#include <Arduino.h>
#endif
// Chip variants supported (ST7576 is experimental)...
#define CHIP_PCD8544 0
#define CHIP_ST7576 1
class PCD8544: public Print {
public:
// All the pins can be changed from the default values...
PCD8544(unsigned char sclk = 13, /* clock (display pin 2) */
unsigned char sdin = 11, /* data-in (display pin 3) */
unsigned char dc = 10, /* data select (display pin 4) */
unsigned char reset = 9, /* reset (display pin 8) */
unsigned char sce = 8); /* enable (display pin 5) */
// Display initialization (dimensions in pixels)...
void begin(unsigned char width=84, unsigned char height=48, unsigned char model=CHIP_PCD8544);
void stop();
// Erase everything on the display...
void clear();
void clearLine(); // ...or just the current line
// Control the display's power state...
void setPower(bool on);
// For compatibility with the LiquidCrystal library...
void display();
void noDisplay();
// Activate white-on-black mode (whole display)...
void setInverse(bool inverse);
// Set display contrast level (0-127)...
void setContrast(unsigned char level);
// Place the cursor at the start of the current line...
void home();
// Place the cursor at position (column, line)...
void setCursor(unsigned char column, unsigned char line);
// Assign a user-defined glyph (5x8) to an ASCII character (0-31)...
void createChar(unsigned char chr, const unsigned char *glyph);
// Write an ASCII character at the current cursor position (7-bit)...
#if ARDUINO < 100
virtual void write(uint8_t chr);
#else
virtual size_t write(uint8_t chr);
#endif
// Draw a bitmap at the current cursor position...
void drawBitmap(const unsigned char *data, unsigned char columns, unsigned char lines);
// Draw a chart element at the current cursor position...
void drawColumn(unsigned char lines, unsigned char value);
private:
unsigned char pin_sclk;
unsigned char pin_sdin;
unsigned char pin_dc;
unsigned char pin_reset;
unsigned char pin_sce;
// Chip variant in use...
unsigned char model;
// The size of the display, in pixels...
unsigned char width;
unsigned char height;
// Current cursor position...
unsigned char column;
unsigned char line;
// User-defined glyphs (below the ASCII space character)...
const unsigned char *custom[' '];
// Send a command or data to the display...
void send(unsigned char type, unsigned char data);
};
#endif /* PCD8544_H */
/* vim: set expandtab ts=4 sw=4: */