| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <array> | ||
| 4 | #include <string> | ||
| 5 | |||
| 6 | class DisplayDriver { | ||
| 7 | public: | ||
| 8 | 12 | DisplayDriver(int lt) : | |
| 9 | 12 | ledType(lt) {} | |
| 10 | 24 | virtual ~DisplayDriver() {} | |
| 11 | |||
| 12 | virtual bool initialize(int& i2cBus) = 0; | ||
| 13 | |||
| 14 | ✗ | virtual bool setFont(const std::string& f) { return false; } | |
| 15 | virtual void printString(int x, int y, const std::string& str, bool white = true) = 0; | ||
| 16 | virtual void printStringCentered(int y, const std::string& str, bool white = true) = 0; | ||
| 17 | virtual void fillTriangle(short x0, short y0, short x1, short y1, short x2, short y2, bool white = true) = 0; | ||
| 18 | virtual void drawLine(short x0, short y0, short x1, short y1, bool white = true) = 0; | ||
| 19 | virtual void drawBitmap(short x, short y, const unsigned char bitmap[], short w, short h, bool white = true) = 0; | ||
| 20 | virtual void drawRect(short x0, short y0, short x1, short y1, bool white = true) = 0; | ||
| 21 | virtual void fillRect(short x0, short y0, short x1, short y1, bool white = true) = 0; | ||
| 22 | virtual void clearDisplay() = 0; | ||
| 23 | virtual void flushDisplay() = 0; | ||
| 24 | virtual void displayOff() = 0; | ||
| 25 | |||
| 26 | virtual int getWidth() = 0; | ||
| 27 | virtual int getHeight() = 0; | ||
| 28 | |||
| 29 | ✗ | virtual int getMinimumRefresh() { return 1000; } | |
| 30 | |||
| 31 | protected: | ||
| 32 | int ledType; | ||
| 33 | }; | ||
| 34 | |||
| 35 | class SSD1306DisplayDriver : public DisplayDriver { | ||
| 36 | public: | ||
| 37 | SSD1306DisplayDriver(int type); | ||
| 38 | virtual ~SSD1306DisplayDriver(); | ||
| 39 | |||
| 40 | virtual bool initialize(int& i2cBus) override; | ||
| 41 | virtual int getWidth() override; | ||
| 42 | virtual int getHeight() override; | ||
| 43 | |||
| 44 | virtual bool setFont(const std::string& f); | ||
| 45 | virtual void printString(int x, int y, const std::string& str, bool white = true) override; | ||
| 46 | virtual void printStringCentered(int y, const std::string& str, bool white = true) override; | ||
| 47 | virtual void fillTriangle(short x0, short y0, short x1, short y1, short x2, short y2, bool white = true) override; | ||
| 48 | virtual void drawLine(short x0, short y0, short x1, short y1, bool white = true) override; | ||
| 49 | virtual void drawBitmap(short x, short y, const unsigned char bitmap[], short w, short h, bool white = true) override; | ||
| 50 | virtual void drawRect(short x0, short y0, short x1, short y1, bool white = true) override; | ||
| 51 | virtual void fillRect(short x0, short y0, short x1, short y1, bool white = true) override; | ||
| 52 | virtual void clearDisplay() override; | ||
| 53 | virtual void flushDisplay() override; | ||
| 54 | virtual void displayOff() override; | ||
| 55 | }; | ||
| 56 | |||
| 57 | class PinCapabilities; | ||
| 58 | class I2C1602_2004_DisplayDriver : public DisplayDriver { | ||
| 59 | public: | ||
| 60 | I2C1602_2004_DisplayDriver(int type); | ||
| 61 | virtual ~I2C1602_2004_DisplayDriver(); | ||
| 62 | |||
| 63 | virtual bool initialize(int& i2cBus) override; | ||
| 64 | virtual int getWidth() override; | ||
| 65 | virtual int getHeight() override; | ||
| 66 | |||
| 67 | virtual bool setFont(const std::string& f); | ||
| 68 | virtual void printString(int x, int y, const std::string& str, bool white = true) override; | ||
| 69 | virtual void printStringCentered(int y, const std::string& str, bool white = true) override; | ||
| 70 | virtual void fillTriangle(short x0, short y0, short x1, short y1, short x2, short y2, bool white = true) override; | ||
| 71 | virtual void drawLine(short x0, short y0, short x1, short y1, bool white = true) override; | ||
| 72 | virtual void drawBitmap(short x, short y, const unsigned char bitmap[], short w, short h, bool white = true) override; | ||
| 73 | virtual void drawRect(short x0, short y0, short x1, short y1, bool white = true) override; | ||
| 74 | virtual void fillRect(short x0, short y0, short x1, short y1, bool white = true) override; | ||
| 75 | virtual void clearDisplay() override; | ||
| 76 | virtual void flushDisplay() override; | ||
| 77 | virtual void displayOff() override; | ||
| 78 | ✗ | virtual int getMinimumRefresh() { return 3000; } | |
| 79 | |||
| 80 | private: | ||
| 81 | void write4Bits(uint8_t bits, bool cmd); | ||
| 82 | void command(uint8_t bits); | ||
| 83 | void send(uint8_t bits, bool cmd); | ||
| 84 | std::array<std::string, 4> lines; | ||
| 85 | std::array<std::string, 4> lastLines; | ||
| 86 | }; | ||
| 87 |