Skip to content

Commit b5e5334

Browse files
committed
Doxygen across new sections
1 parent 0242373 commit b5e5334

File tree

7 files changed

+136
-64
lines changed

7 files changed

+136
-64
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,6 @@ data/
5252

5353
# Misc. Data
5454
tests/
55-
venv/
55+
venv/
56+
57+
Doxyfile

src/Wippersnapper.h

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,24 @@
4747
// Define actual debug output functions when necessary.
4848
#ifdef WS_DEBUG
4949
#define WS_DEBUG_PRINT(...) \
50-
{ WS_PRINTER.print(__VA_ARGS__); } ///< Prints debug output.
50+
{ \
51+
WS_PRINTER.print(__VA_ARGS__); \
52+
} ///< Prints debug output.
5153
#define WS_DEBUG_PRINTLN(...) \
52-
{ WS_PRINTER.println(__VA_ARGS__); } ///< Prints line from debug output.
54+
{ \
55+
WS_PRINTER.println(__VA_ARGS__); \
56+
} ///< Prints line from debug output.
5357
#define WS_DEBUG_PRINTHEX(...) \
54-
{ WS_PRINTER.print(__VA_ARGS__, HEX); } ///< Prints debug output.
58+
{ \
59+
WS_PRINTER.print(__VA_ARGS__, HEX); \
60+
} ///< Prints debug output.
5561
#else
5662
#define WS_DEBUG_PRINT(...) \
57-
{} ///< Prints debug output
63+
{ \
64+
} ///< Prints debug output
5865
#define WS_DEBUG_PRINTLN(...) \
59-
{} ///< Prints line from debug output.
66+
{ \
67+
} ///< Prints line from debug output.
6068
#endif
6169

6270
#define WS_DELAY_WITH_WDT(timeout) \
@@ -127,12 +135,12 @@
127135
#include "display/ws_display_ui_helper.h"
128136
#endif
129137

138+
#include "components/display/controller.h"
130139
#include "components/ds18x20/ws_ds18x20.h"
131140
#include "components/pixels/ws_pixels.h"
132141
#include "components/pwm/ws_pwm.h"
133142
#include "components/servo/ws_servo.h"
134143
#include "components/uart/ws_uart.h"
135-
#include "components/display/controller.h"
136144

137145
#if defined(USE_TINYUSB)
138146
#include "provisioning/tinyusb/Wippersnapper_FS.h"
@@ -154,7 +162,7 @@
154162
#define TOPIC_INFO "/info/" ///< Registration sub-topic
155163
#define TOPIC_SIGNALS "/signals/" ///< Signals sub-topic
156164
#define TOPIC_I2C "/i2c" ///< I2C sub-topic
157-
#define TOPIC_DISPLAY "/display" ///< Display sub-topic (EPD, OLED, TFT, etc.)
165+
#define TOPIC_DISPLAY "/display" ///< Display sub-topic (EPD, OLED, TFT, etc.)
158166
#define MQTT_TOPIC_PIXELS_DEVICE \
159167
"/signals/device/pixel" ///< Pixels device->broker topic
160168
#define MQTT_TOPIC_PIXELS_BROKER \
@@ -371,7 +379,8 @@ class Wippersnapper {
371379
ws_servo *_servoComponent; ///< Instance of servo class
372380
ws_ds18x20 *_ds18x20Component; ///< Instance of DS18x20 class
373381
ws_uart *_uartComponent; ///< Instance of UART class
374-
DisplayController *_displayController; ///< Instance of display controller class
382+
DisplayController
383+
*_displayController; ///< Instance of display controller class
375384

376385
// TODO: does this really need to be global?
377386
uint8_t _macAddr[6]; /*!< Unique network iface identifier */
@@ -408,8 +417,10 @@ class Wippersnapper {
408417
char *_topic_signal_pixels_device = NULL; /*!< Topic carries pixel messages */
409418
char *_topic_signal_uart_brkr = NULL; /*!< Topic carries UART messages */
410419
char *_topic_signal_uart_device = NULL; /*!< Topic carries UART messages */
411-
char *_topic_signal_display_brkr = NULL; /*!< Topic carries messages from a device to a broker. */
412-
char *_topic_signal_display_device = NULL; /*!< Topic carries messages from a broker to a device. */
420+
char *_topic_signal_display_brkr =
421+
NULL; /*!< Topic carries messages from a device to a broker. */
422+
char *_topic_signal_display_device =
423+
NULL; /*!< Topic carries messages from a broker to a device. */
413424

414425
wippersnapper_signal_v1_CreateSignalRequest
415426
_incomingSignalMsg; /*!< Incoming signal message from broker */
@@ -436,7 +447,8 @@ class Wippersnapper {
436447
wippersnapper_signal_v1_UARTRequest
437448
msgSignalUART; ///< UARTReq wrapper message
438449

439-
wippersnapper_signal_v1_DisplayRequest msgSignalDisplay;
450+
wippersnapper_signal_v1_DisplayRequest
451+
msgSignalDisplay; ///< DisplayRequest wrapper message
440452

441453
char *throttleMessage; /*!< Pointer to throttle message data. */
442454
int throttleTime; /*!< Total amount of time to throttle the device, in
@@ -498,8 +510,8 @@ class Wippersnapper {
498510
*_topic_signal_pixels_sub; /*!< Subscribes to pixel device topic. */
499511
Adafruit_MQTT_Subscribe
500512
*_topic_signal_uart_sub; /*!< Subscribes to signal's UART topic. */
501-
Adafruit_MQTT_Subscribe
502-
*_topic_signal_display_sub; /*!< Subscription callback for display topic. */
513+
Adafruit_MQTT_Subscribe *_topic_signal_display_sub; /*!< Subscription callback
514+
for display topic. */
503515

504516
Adafruit_MQTT_Subscribe
505517
*_err_sub; /*!< Subscription to Adafruit IO Error topic. */

src/Wippersnapper_demo.ino.cpp

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

src/components/display/drivers/dispDrvBase.h

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,65 @@
1818
#include "Adafruit_ThinkInk.h"
1919
#include "Wippersnapper.h"
2020

21+
/*!
22+
@brief Abstract base class for display drivers.
23+
This class provides a common interface for all display drivers,
24+
allowing them to be used interchangeably.
25+
*/
2126
class dispDrvBase {
2227
public:
28+
/*!
29+
@brief Constructor for the base display driver for E-Ink displays.
30+
@param dc
31+
Data/Command pin for the display.
32+
@param rst
33+
Reset pin for the display.
34+
@param cs
35+
Chip Select pin for the display.
36+
@param sram_cs
37+
Optional SRAM Chip Select pin for E-Ink displays that support it.
38+
@param busy
39+
Optional Busy pin for the display.
40+
*/
2341
dispDrvBase(int16_t dc, int16_t rst, int16_t cs, int16_t sram_cs = -1,
2442
int16_t busy = -1)
2543
: _pin_dc(dc), _pin_rst(rst), _pin_cs(cs), _pin_sram_cs(sram_cs),
26-
_pin_busy(busy) {
27-
// Constructor implementation (if we need one)
28-
}
44+
_pin_busy(busy) {}
2945

30-
virtual ~dispDrvBase() {
31-
// Destructor implementation (if we need one)
32-
};
46+
/*!
47+
@brief Destructor for the base display driver.
48+
This destructor is virtual to allow derived classes to clean up
49+
resources properly.
50+
*/
51+
virtual ~dispDrvBase() {}
3352

53+
/*!
54+
@brief Attempts to initialize a ThinkInk EPD driver.
55+
@param mode
56+
The ThinkInk mode to use for the display.
57+
@param reset
58+
Whether to reset the display before initialization.
59+
@return True if the display was initialized successfully, false otherwise.
60+
*/
3461
virtual bool begin(thinkinkmode_t mode, bool reset = true);
3562

63+
/*!
64+
@brief Writes a message to the display.
65+
@param message
66+
The message to write to the display.
67+
@note MUST be implemented by derived classes.
68+
*/
3669
virtual void writeMessage(const char *message) = 0;
3770

3871
protected:
39-
int16_t _pin_dc;
40-
int16_t _pin_rst;
41-
int16_t _pin_cs;
42-
int16_t _pin_busy;
43-
int16_t _pin_sram_cs; // for optional EPD SRAM chip select
44-
uint8_t _text_sz = 1; ///< Text size for display messages
72+
int16_t _pin_dc; ///< Data/Command pin
73+
int16_t _pin_rst; ///< Reset pin
74+
int16_t _pin_cs; ///< Chip Select pin
75+
int16_t _pin_busy; ///< Optional Busy pin
76+
int16_t _pin_sram_cs; ///< Optional EPD SRAM chip select pin
77+
uint8_t _text_sz = 1; ///< Text size for displaying a message
78+
int16_t _height; ///< Height of the display
79+
int16_t _width; ///< Width of the display
4580
};
4681

4782
#endif // WS_DISP_DRV_BASE_H

src/components/display/drivers/dispDrvThinkInkGrayscale4Eaamfgn.h

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* @file src/components/display/drivers/drvDispThinkInkGrayscale4Eaamfgn.h
2+
* @file src/components/display/drivers/dispDrvThinkInkGrayscale4Eaamfgn.h
33
*
44
* Driver for ThinkInk 2.9" Grayscale 4-level EAAMFGN display (present on the
55
* 2025 version of the Adafruit MagTag)
@@ -18,8 +18,25 @@
1818

1919
#include "dispDrvBase.h"
2020

21+
/*!
22+
@brief Driver for a ThinkInk 2.9" Grayscale 4-level EAAMFGN display.
23+
*/
2124
class drvDispThinkInkGrayscale4Eaamfgn : public dispDrvBase {
2225
public:
26+
/*!
27+
@brief Constructor for the ThinkInk Grayscale 4-level EAAMFGN display
28+
driver.
29+
@param dc
30+
Data/Command pin for the display.
31+
@param rst
32+
Reset pin for the display.
33+
@param cs
34+
Chip Select pin for the display.
35+
@param sram_cs
36+
Optional SRAM Chip Select pin for E-Ink displays that support it.
37+
@param busy
38+
Optional Busy pin for the display.
39+
*/
2340
drvDispThinkInkGrayscale4Eaamfgn(int16_t dc, int16_t rst, int16_t cs,
2441
int16_t sram_cs = -1, int16_t busy = -1)
2542
: dispDrvBase(dc, rst, cs, sram_cs, busy), _display(nullptr) {}
@@ -31,6 +48,15 @@ class drvDispThinkInkGrayscale4Eaamfgn : public dispDrvBase {
3148
}
3249
}
3350

51+
/*!
52+
@brief Attempts to initialize the ThinkInk Grayscale 4-level EAAMFGN
53+
display driver.
54+
@param mode
55+
The ThinkInk mode to use for the display.
56+
@param reset
57+
Whether to reset the display before initialization.
58+
@return True if the display was initialized successfully, false otherwise.
59+
*/
3460
bool begin(thinkinkmode_t mode, bool reset = true) override {
3561
_display = new ThinkInk_290_Grayscale4_EAAMFGN(_pin_dc, _pin_rst, _pin_cs,
3662
_pin_sram_cs, _pin_busy);
@@ -44,13 +70,22 @@ class drvDispThinkInkGrayscale4Eaamfgn : public dispDrvBase {
4470
_display->setTextSize(_text_sz);
4571
_display->setTextColor(EPD_BLACK);
4672
_display->setTextWrap(false);
73+
_height = _display->height();
74+
_width = _display->width();
4775
// Clear the display buffer
4876
_display->clearBuffer();
4977
_display->display();
5078

5179
return true;
5280
}
5381

82+
/*!
83+
@brief Writes a message to the display.
84+
@param message
85+
The message to write to the display.
86+
@note This method overrides the base class method to provide specific
87+
functionality for the Think Ink Grayscale 4 EAAMGFGN driver.
88+
*/
5489
virtual void writeMessage(const char *message) override {
5590
if (_display == nullptr)
5691
return;
@@ -66,17 +101,23 @@ class drvDispThinkInkGrayscale4Eaamfgn : public dispDrvBase {
66101
uint16_t c_idx = 0;
67102
size_t msg_size = strlen(message);
68103
for (size_t i = 0; i < msg_size && c_idx < msg_size; i++) {
104+
if (y_idx + line_height > _height)
105+
break;
69106
if (message[i] == '\\' && i + 1 < msg_size &&
70107
(message[i + 1] == 'n' || message[i + 1] == 'r')) {
71108
// Handle \r\n sequence as a single newline
72109
if (message[i + 1] == 'r' && i + 3 < msg_size &&
73110
message[i + 2] == '\\' && message[i + 3] == 'n') {
74111
// Skip to the next line
112+
if (y_idx + line_height > _height)
113+
break;
75114
y_idx += line_height;
76115
_display->setCursor(0, y_idx);
77116
i += 3;
78117
} else if (message[i + 1] == 'n') {
79118
// Skip to the next line
119+
if (y_idx + line_height > _height)
120+
break;
80121
y_idx += line_height;
81122
_display->setCursor(0, y_idx);
82123
i++;

src/components/display/hardware.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ dispDrvBase *CreateDrvDisp(const char *driver_name, int16_t dc, int16_t rst,
6363

6464
/*!
6565
@brief Constructs a new DisplayHardware object
66+
@param name
67+
The name of the hardware instance.
6668
*/
6769
DisplayHardware::DisplayHardware(const char *name) {
6870
strncpy(_name, name, sizeof(_name) - 1);
@@ -74,7 +76,10 @@ DisplayHardware::DisplayHardware(const char *name) {
7476
@brief Destructor
7577
*/
7678
DisplayHardware::~DisplayHardware() {
77-
// TODO
79+
if (_drvDisp) {
80+
delete _drvDisp;
81+
_drvDisp = nullptr;
82+
}
7883
}
7984

8085
/*!
@@ -152,8 +157,8 @@ bool DisplayHardware::beginEPD(
152157
// TODO: Configure SPI bus selection (UNUSED AS OF RIGHT NOW)
153158

154159
// Create display driver object using the factory function
155-
_disp_drv_base = CreateDrvDisp(_name, dc, rst, cs, srcs, busy);
156-
if (!_disp_drv_base) {
160+
_drvDisp = CreateDrvDisp(_name, dc, rst, cs, srcs, busy);
161+
if (!_drvDisp) {
157162
WS_DEBUG_PRINTLN("[display] Failed to create display driver!");
158163
return false; // Failed to create display driver
159164
}
@@ -165,10 +170,10 @@ bool DisplayHardware::beginEPD(
165170
WS_DEBUG_PRINTLN("[display] EPD mode: GRAYSCALE4");
166171
}
167172

168-
if (!_disp_drv_base->begin(epd_mode)) {
173+
if (!_drvDisp->begin(epd_mode)) {
169174
WS_DEBUG_PRINTLN("[display] Failed to begin display driver!");
170-
delete _disp_drv_base;
171-
_disp_drv_base = nullptr;
175+
delete _drvDisp;
176+
_drvDisp = nullptr;
172177
return false;
173178
}
174179

@@ -181,9 +186,14 @@ bool DisplayHardware::beginEPD(
181186
*/
182187
const char *DisplayHardware::getName() { return _name; }
183188

189+
/*!
190+
@brief Writes a message to the display.
191+
@param message
192+
The message to display.
193+
*/
184194
void DisplayHardware::writeMessage(const char *message) {
185-
if (_disp_drv_base) {
186-
_disp_drv_base->writeMessage(message);
195+
if (_drvDisp) {
196+
_drvDisp->writeMessage(message);
187197
} else {
188198
WS_DEBUG_PRINTLN("[display] No display driver initialized!");
189199
}

src/components/display/hardware.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@
2020
#include <functional>
2121
#include <map>
2222

23-
/**************************************************************************/
2423
/*!
2524
@brief Interface for interacting with display hardware (TFT, eInk,
2625
OLED, etc.)
2726
This class provides methods to initialize, write to, and
2827
manage the state of display hardware.
2928
*/
30-
/**************************************************************************/
3129
class DisplayHardware {
3230
public:
3331
DisplayHardware(const char *name);
@@ -52,6 +50,6 @@ class DisplayHardware {
5250
private:
5351
char _name[64]; ///< Identifies the hardware instance
5452
wippersnapper_display_v1_DisplayType _type; ///< Display type
55-
dispDrvBase *_disp_drv_base = nullptr; ///< Base display driver
53+
dispDrvBase *_drvDisp = nullptr; ///< Base display driver
5654
};
5755
#endif // WS_DISPLAY_HARDWARE_H

0 commit comments

Comments
 (0)