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