Control Surface
1.1.1
MIDI Control Surface library for Arduino
src
Display
DisplayInterface.cpp
Go to the documentation of this file.
1
#include "
DisplayInterface.hpp
"
2
3
BEGIN_CS_NAMESPACE
4
5
DoublyLinkedList<DisplayInterface>
DisplayInterface::elements
;
6
7
void
DisplayInterface::begin
() {
8
clear
();
9
drawBackground
();
10
display
();
11
}
12
13
void
DisplayInterface::fillRect
(int16_t x, int16_t y, int16_t w, int16_t h,
14
uint16_t color) {
15
for
(int16_t r = y; r < y + h; r++)
16
drawFastHLine
(x, r, w, color);
17
}
18
19
void
DisplayInterface::drawCircle
(int16_t x0, int16_t y0, int16_t r,
20
uint16_t color) {
21
int
x = r;
22
int
y = 0;
23
int
err = 0;
24
25
while
(x >= y) {
26
drawPixel
(x0 + x, y0 + y, color);
27
drawPixel
(x0 + y, y0 + x, color);
28
drawPixel
(x0 - y, y0 + x, color);
29
drawPixel
(x0 - x, y0 + y, color);
30
drawPixel
(x0 - x, y0 - y, color);
31
drawPixel
(x0 - y, y0 - x, color);
32
drawPixel
(x0 + y, y0 - x, color);
33
drawPixel
(x0 + x, y0 - y, color);
34
35
if
(err <= 0)
36
err += 2 * ++y + 1;
37
else
38
err -= 2 * --x + 1;
39
}
40
}
41
42
void
DisplayInterface::fillCircle
(int16_t x0, int16_t y0, int16_t r,
43
uint16_t color) {
44
int
x = r;
45
int
y = 0;
46
int
err = 0;
47
48
while
(x >= y) {
49
drawFastHLine
(x0 - x, y0 + y, 2 * x, color);
50
drawFastHLine
(x0 - y, y0 + x, 2 * y, color);
51
drawFastHLine
(x0 - y, y0 - x, 2 * y, color);
52
drawFastHLine
(x0 - x, y0 - y, 2 * x, color);
53
54
if
(err <= 0)
55
err += 2 * ++y + 1;
56
else
57
err -= 2 * --x + 1;
58
}
59
}
60
61
void
DisplayInterface::beginAll
() {
62
for
(
DisplayInterface
&el :
elements
)
63
el.begin();
64
}
65
66
END_CS_NAMESPACE
DisplayInterface::display
virtual void display()=0
Write the frame buffer to the display.
DisplayInterface::elements
static DoublyLinkedList< DisplayInterface > elements
Definition:
DisplayInterface.hpp:123
DisplayInterface::clear
virtual void clear()=0
Clear the frame buffer or display.
DisplayInterface
An interface for displays.
Definition:
DisplayInterface.hpp:14
DisplayInterface::beginAll
static void beginAll()
Initialize all displays.
Definition:
DisplayInterface.cpp:61
DisplayInterface::drawPixel
virtual void drawPixel(int16_t x, int16_t y, uint16_t color)=0
Paint a single pixel with the given color.
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition:
Settings/NamespaceSettings.hpp:9
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition:
Settings/NamespaceSettings.hpp:10
DisplayInterface.hpp
DisplayInterface::fillCircle
virtual void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Draw a disk (filled circle).
Definition:
DisplayInterface.cpp:42
DoublyLinkedList< DisplayInterface >
DisplayInterface::begin
virtual void begin()
Initialize the display.
Definition:
DisplayInterface.cpp:7
DisplayInterface::fillRect
virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Draw a filled rectangle.
Definition:
DisplayInterface.cpp:13
DisplayInterface::drawBackground
virtual void drawBackground()
Draw a custom background.
Definition:
DisplayInterface.hpp:33
DisplayInterface::drawFastHLine
virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)=0
Draw a horizontal line.
DisplayInterface::drawCircle
virtual void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Draw a circle.
Definition:
DisplayInterface.cpp:19
Generated by
1.8.16