LCOV - code coverage report
Current view: top level - src/Display - DisplayInterface.hpp (source / functions) Hit Total Coverage
Test: 19d2efc7037c2e176feca44750a12594c76f466f Lines: 0 6 0.0 %
Date: 2019-11-24 14:50:27 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <Def/Def.hpp>
       4             : #include <Helpers/LinkedList.hpp>
       5             : #include <Print.h>
       6             : 
       7             : BEGIN_CS_NAMESPACE
       8             : 
       9             : /**
      10             :  * @brief   An interface for displays. 
      11             :  * 
      12             :  * Inspired by the Adafruit GFX library for easy compatibility.
      13             :  */
      14             : class DisplayInterface : public Print, public DoublyLinkable<DisplayInterface> {
      15             :   protected:
      16             :     /// @todo   Do I need to keep a list now that I have sorted all 
      17             :     ///         DisplayElement%s?
      18             :     DisplayInterface() { elements.append(this); }
      19             : 
      20             :   public:
      21             :     /// @todo   Do I need to keep a list now that I have sorted all 
      22             :     ///         DisplayElement%s?
      23             :     // Note to self:    don't forget to make destructor = default 
      24             :     //                  instead of deleting it altogether
      25           0 :     virtual ~DisplayInterface() { elements.remove(this); }
      26             : 
      27             :     /// Initialize the display.
      28             :     virtual void begin();
      29             : 
      30             :     /// Clear the frame buffer or display.
      31             :     virtual void clear() = 0;
      32             :     /// Draw a custom background.
      33           0 :     virtual void drawBackground(){};
      34             :     /// Write the frame buffer to the display.
      35             :     virtual void display() = 0;
      36             : 
      37             :     /// Paint a single pixel with the given color.
      38             :     virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
      39             : 
      40             :     /// Set the text color.
      41             :     virtual void setTextColor(uint16_t color) = 0;
      42             :     /// Set the text size.
      43             :     virtual void setTextSize(uint8_t size) = 0;
      44             :     /// Set the cursor position.
      45             :     virtual void setCursor(int16_t x, int16_t y) = 0;
      46             : 
      47             :     /**
      48             :      * @brief   Write a character to the display.
      49             :      * 
      50             :      * @see     setCursor
      51             :      * @see     setTextSize
      52             :      * @see     setTextColor
      53             :      */
      54             :     size_t write(uint8_t c) override = 0;
      55             : 
      56             :     /// Draw a line between two points.
      57             :     virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
      58             :                           uint16_t color) = 0;
      59             :     /// Draw a vertical line.
      60             :     virtual void drawFastVLine(int16_t x, int16_t y, int16_t h,
      61             :                                uint16_t color) = 0;
      62             :     /// Draw a horizontal line.
      63             :     virtual void drawFastHLine(int16_t x, int16_t y, int16_t w,
      64             :                                uint16_t color) = 0;
      65             : 
      66             :     /// Draw a bitmap to the display.
      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             : 
      70             :     /// Draw a filled rectangle.
      71             :     virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
      72             :                           uint16_t color);
      73             : 
      74             :     /// Draw a circle.
      75             :     virtual void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
      76             : 
      77             :     /// Draw a disk (filled circle).
      78             :     virtual void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
      79             : 
      80             :     /// Initialize all displays.
      81             :     /// @see    begin
      82             :     static void beginAll();
      83             : 
      84             :     /**
      85             :      * @brief   Clear the frame buffer, and draw the custom background.
      86             :      * @see    clear
      87             :      * @see    drawBackground
      88             :      */
      89           0 :     void clearAndDrawBackground() {
      90           0 :         clear();
      91           0 :         drawBackground();
      92           0 :     }
      93             : 
      94             :   private:
      95             :     static DoublyLinkedList<DisplayInterface> elements;
      96             : };
      97             : 
      98             : END_CS_NAMESPACE

Generated by: LCOV version 1.14-5-g4ff2ed6