This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
DisplayInterface.cpp
Go to the documentation of this file.
1 #include "DisplayInterface.hpp"
2 
4 
6 
8  clear();
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 
62  for (DisplayInterface &el : elements)
63  el.begin();
64 }
65 
DisplayInterface::elements
static DoublyLinkedList< DisplayInterface > elements
Definition: DisplayInterface.hpp:95
DisplayInterface::beginAll
static void beginAll()
Initialize all displays.
Definition: DisplayInterface.cpp:61
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
DisplayInterface::drawBackground
virtual void drawBackground()
Draw a custom background.
Definition: DisplayInterface.hpp:33
DisplayInterface
An interface for displays.
Definition: DisplayInterface.hpp:14
DisplayInterface.hpp
DisplayInterface::clear
virtual void clear()=0
Clear the frame buffer or display.
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: NamespaceSettings.hpp:9
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
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
DisplayInterface::drawPixel
virtual void drawPixel(int16_t x, int16_t y, uint16_t color)=0
Paint a single pixel with the given color.
DoublyLinkedList< DisplayInterface >
DisplayInterface::display
virtual void display()=0
Write the frame buffer to the display.
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::begin
virtual void begin()
Initialize the display.
Definition: DisplayInterface.cpp:7