Peritoneal Dialysis Capstone
Controlling catheter for peritoneal dialysis
Loading...
Searching...
No Matches
AdafruitTFTDriver.h
Go to the documentation of this file.
1
4
5#ifndef ADAFRUIT_TFT_DRIVER_H
6#define ADAFRUIT_TFT_DRIVER_H
7
8#include <Adafruit_ST7735.h>
9#include <TFTDriver.h>
10#include <stdint.h>
11
17public:
24 AdafruitTFTDriver(int csPin, int dcPin);
25
26 void initialize() override;
27 [[nodiscard]] unsigned getScreenWidth() const override;
28 [[nodiscard]] unsigned getScreenHeight() const override;
29 [[nodiscard]] unsigned getTextWidth() const override;
30 [[nodiscard]] unsigned getTextHeight() const override;
31 void clearScreen(TFTColor color) override;
32 void drawText(
33 TFTPoint topLeft, TFTColor textColor, TFTColor bgColor, const char *string
34 ) override;
35
36private:
37 // The display accepts 16-bit colors in the 565 format (5 bits red, 6 bits
38 // green, 5 bits blue).
39 using Color565 = uint16_t;
40
41 // <https://learn.adafruit.com/adafruit-mini-tft-0-dot-96-inch-180x60-breakout/wiring-test>
42 static constexpr uint8_t DISPLAY_REVISION{INITR_MINI160x80_PLUGIN};
43
44 // The magnification level for text.
45 static constexpr unsigned TEXT_SCALE{2};
46
47 // The value used for the Adafruit GFX `setRotation` call. By default, the
48 // display uses a portrait oritentation. A value of 1 corresponds to a
49 // landscape orientation.
50 static constexpr unsigned SCREEN_ORIENTATION{1};
51
52 // According to
53 // <https://adafruit.github.io/Adafruit-GFX-Library/html/class_adafruit___g_f_x.html#a39eb4a8a2c9fa4ab7d58ceffd19535d5>,
54 // the default text size is 6x8.
55 static constexpr unsigned DEFAULT_TEXT_WIDTH{6};
56 static constexpr unsigned DEFAULT_TEXT_HEIGHT{8};
57
62 static Color565 encodeColor(TFTColor color);
63
64 Adafruit_ST7735 m_gfx;
65};
66
67#endif // ADAFRUIT_TFT_DRIVER_H
TFTColor
A color used for drawing on a TFT display.
Definition TFT.h:14
unsigned getScreenHeight() const override
Returns the height, in pixels, of the screen.
Definition AdafruitTFTDriver.cpp:19
static constexpr unsigned TEXT_SCALE
Definition AdafruitTFTDriver.h:45
unsigned getTextWidth() const override
Returns the width, in pixels, of one character.
Definition AdafruitTFTDriver.cpp:23
void clearScreen(TFTColor color) override
Assigns one color to all pixels on the screen, clearing any previously drawn text.
Definition AdafruitTFTDriver.cpp:31
Adafruit_ST7735 m_gfx
Definition AdafruitTFTDriver.h:64
static constexpr unsigned DEFAULT_TEXT_HEIGHT
Definition AdafruitTFTDriver.h:56
static Color565 encodeColor(TFTColor color)
Converts an abstract color to the representation used by the Adafruit ST7735 library.
Definition AdafruitTFTDriver.cpp:45
static constexpr unsigned SCREEN_ORIENTATION
Definition AdafruitTFTDriver.h:50
static constexpr unsigned DEFAULT_TEXT_WIDTH
Definition AdafruitTFTDriver.h:55
AdafruitTFTDriver(int csPin, int dcPin)
Instantiate the Adafruit driver using hardware SPI.
Definition AdafruitTFTDriver.cpp:4
void initialize() override
Initializes the display.
Definition AdafruitTFTDriver.cpp:9
void drawText(TFTPoint topLeft, TFTColor textColor, TFTColor bgColor, const char *string) override
Draws monospace text.
Definition AdafruitTFTDriver.cpp:35
unsigned getTextHeight() const override
Returns the height, in pixels, of one character.
Definition AdafruitTFTDriver.cpp:27
static constexpr uint8_t DISPLAY_REVISION
Definition AdafruitTFTDriver.h:42
unsigned getScreenWidth() const override
Returns the width, in pixels, of the screen.
Definition AdafruitTFTDriver.cpp:15
uint16_t Color565
Definition AdafruitTFTDriver.h:39
A low-level interface to a TFT display.
Definition TFTDriver.h:13
The position of a pixel on a TFT display, given in Cartesian coordinates.
Definition TFT.h:27