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.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Def/Def.hpp>
4 #include <Helpers/LinkedList.hpp>
5 #include <Print.h>
6 
8 
14 class DisplayInterface : public Print, public DoublyLinkable<DisplayInterface> {
15  protected:
19 
20  public:
23  // Note to self: don't forget to make destructor = default
24  // instead of deleting it altogether
25  virtual ~DisplayInterface() { elements.remove(this); }
26 
28  virtual void begin();
29 
31  virtual void clear() = 0;
33  virtual void drawBackground(){};
35  virtual void display() = 0;
36 
38  virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
39 
41  virtual void setTextColor(uint16_t color) = 0;
43  virtual void setTextSize(uint8_t size) = 0;
45  virtual void setCursor(int16_t x, int16_t y) = 0;
46 
54  size_t write(uint8_t c) override = 0;
55 
57  virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
58  uint16_t color) = 0;
60  virtual void drawFastVLine(int16_t x, int16_t y, int16_t h,
61  uint16_t color) = 0;
63  virtual void drawFastHLine(int16_t x, int16_t y, int16_t w,
64  uint16_t color) = 0;
65 
67  virtual void drawXBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
68  int16_t w, int16_t h, uint16_t color) = 0;
69 
71  virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
72  uint16_t color);
73 
75  virtual void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
76 
78  virtual void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
79 
82  static void beginAll();
83 
90  clear();
92  }
93 
94  private:
96 };
97 
DisplayInterface::drawFastVLine
virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)=0
Draw a vertical line.
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::~DisplayInterface
virtual ~DisplayInterface()
Definition: DisplayInterface.hpp:25
DisplayInterface::drawBackground
virtual void drawBackground()
Draw a custom background.
Definition: DisplayInterface.hpp:33
DisplayInterface
An interface for displays.
Definition: DisplayInterface.hpp:14
DoublyLinkedList::append
void append(Node *node)
Append a node to a linked list.
Definition: LinkedList.hpp:113
Def.hpp
DisplayInterface::clearAndDrawBackground
void clearAndDrawBackground()
Clear the frame buffer, and draw the custom background.
Definition: DisplayInterface.hpp:89
LinkedList.hpp
DoublyLinkedList::remove
void remove(Node *node)
Remove a node from the linked list.
Definition: LinkedList.hpp:196
DisplayInterface::drawLine
virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)=0
Draw a line between two points.
DisplayInterface::clear
virtual void clear()=0
Clear the frame buffer or display.
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: NamespaceSettings.hpp:9
DisplayInterface::setCursor
virtual void setCursor(int16_t x, int16_t y)=0
Set the cursor position.
DisplayInterface::setTextSize
virtual void setTextSize(uint8_t size)=0
Set the text size.
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::write
size_t write(uint8_t c) override=0
Write a character to the display.
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 >
DoublyLinkable
A class that can be inherited from to allow inserting into a DoublyLinkedList.
Definition: LinkedList.hpp:298
DisplayInterface::display
virtual void display()=0
Write the frame buffer to the display.
DisplayInterface::DisplayInterface
DisplayInterface()
Definition: DisplayInterface.hpp:18
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::drawXBitmap
virtual void drawXBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color)=0
Draw a bitmap to the display.
DisplayInterface::begin
virtual void begin()
Initialize the display.
Definition: DisplayInterface.cpp:7
DisplayInterface::setTextColor
virtual void setTextColor(uint16_t color)=0
Set the text color.