-
Notifications
You must be signed in to change notification settings - Fork 25
/
PCD8544.h
143 lines (111 loc) · 5.03 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
* PCD8544 - Interface with Philips PCD8544 (or compatible) LCDs.
*
* Copyright (c) 2010 Carlos Rodrigues <[email protected]>
*
* Apr 24, 2020: Breakout board variant details added by Mike Pfleger
*
* 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
#include <Arduino.h>
// Chip variants supported (ST7576 is experimental)...
#define CHIP_PCD8544 0
#define CHIP_ST7576 1
class PCD8544: public Print {
public:
/*
* Please verify the particular variant of your Nokia LCD module before
* applying power.
*
* The PCD8544 "Nokia" LCD modules seem to come in two popular variants,
* which we will refer to as "AdaFruit" and "Sparkfun", referring to the
* popular online vendors. The pinout differences are detailed here for
* reference:
*
* AdaFruit Sparkfun function notes
* -----------+-----------+----------+----------------------------------
* 1 2 GND
* 2 1 VCC
* 3 7 CLK / SCLK
* 4 6 DIN / MOSI
* 5 5 D/C
* 6 3 CS / SCE
* 7 4 RST
* 8 8 LED no Ilim resistors on "Sparkfun"
*/
// All the pins can be changed from the default values...
PCD8544(uint8_t sclk = 3, /* clock (display pin 2) */
uint8_t sdin = 4, /* data-in (display pin 3) */
uint8_t dc = 5, /* data select (display pin 4) */
uint8_t reset = 6, /* reset (display pin 8) */
uint8_t sce = 7); /* enable (display pin 5) */
// Display initialization (dimensions in pixels)...
void begin(uint8_t width=84, uint8_t height=48, uint8_t 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...
void setInverse(bool enabled); // ...whole display
void setInverseOutput(bool enabled); // ...future writes
// Set display contrast level (0-127)...
void setContrast(uint8_t level);
// Place the cursor at the start of the current line...
void home();
// Place the cursor at position (column, line)...
void setCursor(uint8_t column, uint8_t line);
// Assign a user-defined glyph (5x8) to an ASCII character (0-31)...
void createChar(uint8_t chr, const uint8_t *glyph);
// Write an ASCII character at the current cursor position (7-bit)...
virtual size_t write(uint8_t chr);
// Draw a bitmap at the current cursor position...
void drawBitmap(const uint8_t *data, uint8_t columns, uint8_t lines);
// Draw a chart element at the current cursor position...
void drawColumn(uint8_t lines, uint8_t value);
private:
uint8_t pin_sclk;
uint8_t pin_sdin;
uint8_t pin_dc;
uint8_t pin_reset;
uint8_t pin_sce;
// Chip variant in use...
uint8_t model;
// The size of the display, in pixels...
uint8_t width;
uint8_t height;
// Current cursor position...
uint8_t column;
uint8_t line;
// Current output mode for writes (doesn't apply to draws)...
bool inverse_output = false;
// User-defined glyphs (below the ASCII space character)...
const uint8_t *custom[' '];
// Send a command or data to the display...
void send(uint8_t type, uint8_t data);
};
#endif /* PCD8544_H */
/* vim: set expandtab ts=4 sw=4: */