-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathColorLCD.cpp
More file actions
86 lines (69 loc) · 2.27 KB
/
ColorLCD.cpp
File metadata and controls
86 lines (69 loc) · 2.27 KB
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
/*
This file is part of Arduino-Color-LCD, an Arduino library for driving
Nokia 132x132 color displays, including the "Knock-Off color LCD"
from SparkFun.
Version 0.2.0. Created by Cosmin Gorgovan <cosmin AT linux-geek.org>,
February 1, 2010
Home page: http://www2.cs.man.ac.uk/~gorgovc9/arduino.html
Arduino-Color-LCD is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Arduino-Color-LCD is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Arduino-Color-LCD. If not, see <http://www.gnu.org/licenses/>.
*/
#include "WProgram.h"
#include "ColorLCD.h"
// Constructor function
ColorLCD::ColorLCD()
{
// Screen width (used to compute text box size)
screenWidth = 132;
// The font dimensions
fontWidth = 5;
fontHeight = 8;
fontSpacing = 1;
// Text length in a box, gets reseted to 0 when moving the text pointer
textLength = 0;
// The margins of the text box
textBoxLeftMargin = 5;
textBoxTopMargin = 5;
// The width of the text box in pixels
textBoxWidth = screenWidth - 2 * textBoxLeftMargin;
// Foreground and background color codes
foreground = 0xFF;
background = 0x00;
}
// Change the background color (used by text printing)
void ColorLCD::setBackground(byte color)
{
background = color;
}
// Change the foreground color (default color when displaying stuff)
void ColorLCD::setForeground(byte color)
{
foreground = color;
}
// Fill an area of the screen with the foreground color
void ColorLCD::colorFill(byte x, byte y, byte width, byte height)
{
colorFill(x, y, width, height, foreground);
}
// Fills the whole screen with the background color
void ColorLCD::clear()
{
colorFill(0, 0, 132, 132, background);
textLength = 0;
moveCursor(5, 5, 120);
}
// Fills the whole screen with black
void ColorLCD::reset()
{
colorFill(0, 0, 132, 132, 0x00);
textLength = 0;
moveCursor(5, 5, 120);
}