Control Surface main
MIDI Control Surface library for Arduino
DisplayInterface.cpp
Go to the documentation of this file.
2
4
6 clear();
8 display();
9}
10
11void 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
17void 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
40void 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
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)=0
Draw a horizontal line.
virtual void drawPixel(int16_t x, int16_t y, uint16_t color)=0
Paint a single pixel with the given color.
virtual void clear()=0
Clear the frame buffer or clear the display.
virtual void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Draw a disk (filled circle).
virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Draw a filled rectangle.
virtual void display()=0
Write the frame buffer to the display.
virtual void begin()
Initialize the display.
virtual void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Draw a circle.
virtual void drawBackground()
Draw a custom background.