Skip to content

Commit c896159

Browse files
committed
Add Doxygen
1 parent 7be4cad commit c896159

File tree

5 files changed

+78
-41
lines changed

5 files changed

+78
-41
lines changed

src/Wippersnapper_demo.ino.cpp

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/components/display/drivers/dispDrvBase.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,34 @@ class dispDrvBase {
9494
*/
9595
virtual void writeMessage(const char *message) = 0;
9696

97+
/*!
98+
@brief Sets the width of the display.
99+
@param w
100+
The width of the display in pixels.
101+
*/
97102
void setWidth(int16_t w) { _width = w; }
103+
104+
/*!
105+
@brief Sets the height of the display.
106+
@param h
107+
The height of the display in pixels.
108+
*/
98109
void setHeight(int16_t h) { _height = h; }
110+
111+
/*!
112+
@brief Sets the rotation of the display.
113+
@param r
114+
The rotation of the display (0-3).
115+
*/
99116
void setRotation(uint8_t r) { _rotation = r; }
100117

118+
/*!
119+
@brief Sets the text size for the display.
120+
@param s
121+
The text size to set.
122+
@note This method can be overridden by derived classes to provide
123+
specific functionality.
124+
*/
101125
virtual void setTextSize(uint8_t s) { _text_sz = s; }
102126

103127
protected:

src/components/display/drivers/dispDrvSt7789.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "dispDrvBase.h"
1919
#include <Adafruit_ST7789.h>
2020

21-
#define ST7789_TEXT_SZ_DEFAULT 2
21+
#define ST7789_TEXT_SZ_DEFAULT 2 ///< Default text size for ST7789 displays
2222

2323
/*!
2424
@brief Driver for ST7789-based TFT displays.
@@ -70,19 +70,27 @@ class dispDrvSt7789 : public dispDrvBase {
7070
#endif
7171

7272
_display = new Adafruit_ST7789(_pin_cs, _pin_dc, _pin_rst);
73-
7473
if (!_display)
7574
return false;
7675

7776
_display->init(_width, _height);
7877
_display->setRotation(_rotation);
78+
setTextSize(ST7789_TEXT_SZ_DEFAULT);
7979
_display->fillScreen(ST77XX_BLACK);
8080
_display->setTextColor(ST77XX_WHITE);
81-
_display->setTextSize(ST7789_TEXT_SZ_DEFAULT);
8281
return true;
8382
}
8483

84+
/*!
85+
@brief Sets the text size for the display.
86+
@param s
87+
The text size to set.
88+
@note This method overrides the base class method to provide specific
89+
functionality for the ST7789 driver.
90+
*/
8591
void setTextSize(uint8_t s) override {
92+
if (!_display)
93+
return;
8694
_text_sz = s;
8795
_display->setTextSize(s);
8896
}
@@ -92,7 +100,7 @@ class dispDrvSt7789 : public dispDrvBase {
92100
@param message
93101
The message to write to the display.
94102
@note This method overrides the base class method to provide specific
95-
functionality for the Think Ink Grayscale 4 EAAMGFGN driver.
103+
functionality for the ST7789 driver.
96104
*/
97105
virtual void writeMessage(const char *message) override {
98106
if (_display == nullptr)

src/components/display/hardware.cpp

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ static const std::map<std::string, FnCreateDispDrvTft> FactoryDrvDispTft = {
5050
return new dispDrvSt7789(cs, dc, mosi, sck, rst, miso);
5151
}},
5252
{"st7789",
53-
[](int16_t cs, int16_t dc, int16_t mosi, int16_t sck, int16_t rst,
54-
int16_t miso) -> dispDrvBase * {
55-
return new dispDrvSt7789(cs, dc, mosi, sck, rst, miso);
56-
}},
57-
{"st7789-large",
5853
[](int16_t cs, int16_t dc, int16_t mosi, int16_t sck, int16_t rst,
5954
int16_t miso) -> dispDrvBase * {
6055
return new dispDrvSt7789(cs, dc, mosi, sck, rst, miso);
@@ -93,6 +88,20 @@ dispDrvBase *CreateDrvDispEpd(const char *driver_name, int16_t dc, int16_t rst,
9388
name.
9489
@param driver_name
9590
The name of the SPI TFT display driver to create.
91+
@param cs
92+
Chip Select pin number.
93+
@param dc
94+
Data/Command pin number.
95+
@param mosi
96+
MOSI pin number.
97+
@param sck
98+
SCK pin number.
99+
@param rst
100+
Optional Reset pin number (default: -1).
101+
@param miso
102+
Optional MISO pin number (default: -1).
103+
@return Pointer to the created display driver instance, or nullptr if the
104+
driver name is not recognized.
96105
*/
97106
dispDrvBase *CreateDrvDispTft(const char *driver_name, int16_t cs, int16_t dc,
98107
int16_t mosi, int16_t sck, int16_t rst = -1,
@@ -244,6 +253,18 @@ bool DisplayHardware::beginEPD(
244253
return true;
245254
}
246255

256+
/*!
257+
@brief Removes a suffix from the hardware instance name, if it exists.
258+
@param suffix
259+
The suffix to remove (e.g., "-lg", "-md", "-sm").
260+
*/
261+
void DisplayHardware::removeSuffix(const char *suffix) {
262+
char *suffix_pos = strstr(_name, suffix);
263+
if (suffix_pos) {
264+
*suffix_pos = '\0'; // Truncate string at suffix position
265+
}
266+
}
267+
247268
/*!
248269
@brief Attempts to configure and initialize a TFT display
249270
@param config
@@ -282,24 +303,33 @@ bool DisplayHardware::beginTft(
282303
miso = parsePin(spi_config->pin_miso);
283304
}
284305

306+
// Configure text size based on suffix in driver name
307+
uint8_t text_sz; // Default text size
308+
if (strstr(_name, "-lg") != nullptr) {
309+
// Larger text size for displays with -lg suffix
310+
text_sz = 4;
311+
removeSuffix("-lg");
312+
} else if (strstr(_name, "-md") != nullptr) {
313+
// Larger text size for displays with -md suffix
314+
text_sz = 3;
315+
removeSuffix("-md");
316+
} else {
317+
text_sz = 1;
318+
}
319+
285320
// Create display driver object using the factory function
286321
_drvDisp = CreateDrvDispTft(_name, cs, dc, mosi, sck, rst, miso);
287322
if (!_drvDisp) {
288323
WS_DEBUG_PRINTLN("[display] Failed to create display driver!");
289324
return false;
290325
}
291326

292-
// Check if name has -large suffix, and if so, set a larger default text size
293-
if (strstr(_name, "-large") != nullptr) {
294-
_drvDisp->setTextSize(3); // Large text size for -large displays
295-
}
296-
297327
_drvDisp->setWidth(config->width);
298328
_drvDisp->setHeight(config->height);
299329
_drvDisp->setRotation(config->rotation);
300330
_drvDisp->begin();
331+
_drvDisp->setTextSize(text_sz);
301332

302-
WS_DEBUG_PRINTLN("[display] TFT display initialized successfully!");
303333
return true;
304334
}
305335

src/components/display/hardware.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class DisplayHardware {
5353

5454
private:
5555
int16_t parsePin(const char *pinStr);
56+
void removeSuffix(const char *suffix);
5657
bool detect_ssd1680(uint8_t cs, uint8_t dc, uint8_t rst);
5758
char _name[64]; ///< Identifies the hardware instance
5859
wippersnapper_display_v1_DisplayType _type; ///< Display type

0 commit comments

Comments
 (0)