Skip to content

Commit fd02303

Browse files
angeloINTJclaude
andcommitted
refactor: split display driver into panel + touch controller files
src/display/ now contains: - DisplayDriver.h — dispatcher + composed driver struct - ILI9341_320x240.h — ILI9341 TFT panel (320x240, SPI) - XPT2046.h — XPT2046 resistive touch controller DisplayDriver inherits from both via multiple inheritance (zero-cost at compile time). Files named after controller + resolution for clarity. Future: HD44780_16x2.h for alphanumeric display. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent d1bcdaa commit fd02303

4 files changed

Lines changed: 55 additions & 37 deletions

File tree

src/display/DisplayDriver.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
/**
22
* @file display/DisplayDriver.h
3-
* @brief Display driver dispatcher — selects the active display hardware at compile time.
4-
* @details Include this header to get the correct DisplayDriver implementation.
5-
* The active driver is selected via build flags in platformio.ini:
6-
* SIMUT_DISPLAY_TFT — ILI9341 320x240 TFT + XPT2046 touch (default)
7-
* SIMUT_DISPLAY_ALPHA — 16x2 alphanumeric HD44780 (future)
3+
* @brief Display driver — composes display panel + touch controller.
4+
* @details The active hardware is selected at compile time via build flags.
5+
* Currently supported:
6+
* Default: ILI9341 320x240 TFT + XPT2046 touch
7+
* Future: HD44780 16x2 alphanumeric (SIMUT_DISPLAY_ALPHA)
88
*
99
* @project SIMUT — Integrated Universal Monitoring and Telemetry System
1010
* @license MIT License
1111
*/
1212

1313
#pragma once
1414

15-
/* ── Driver selection ───────────────────────────────────────────────── */
16-
1715
#if defined(SIMUT_DISPLAY_ALPHA)
18-
// Future: #include "AlphaDisplayDriver.h"
16+
// Future: #include "HD44780_16x2.h"
1917
#error "SIMUT_DISPLAY_ALPHA not yet implemented"
2018
#else
21-
/* Default: ILI9341 TFT */
22-
#include "TftDisplayDriver.h"
19+
/* Default: ILI9341 TFT + XPT2046 touch */
20+
#include "ILI9341_320x240.h"
21+
#include "XPT2046.h"
22+
23+
struct DisplayDriver : public Ili9341_320x240, public Xpt2046_Touch {
24+
};
2325
#endif

src/display/ILI9341_320x240.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @file display/ILI9341_320x240.h
3+
* @brief ILI9341 TFT display driver — 320x240 pixels, SPI interface.
4+
* @details Wraps TftWithOffset (Adafruit_ILI9341 with alignment offset).
5+
* Provides GFX drawing surface, off-screen canvas, and screen dimensions.
6+
*
7+
* @project SIMUT — Integrated Universal Monitoring and Telemetry System
8+
* @license MIT License
9+
*/
10+
#pragma once
11+
#include <Arduino.h>
12+
#include <Adafruit_GFX.h>
13+
#include <Adafruit_ILI9341.h>
14+
#include "TftWithOffset.h"
15+
16+
struct Ili9341_320x240 {
17+
TftWithOffset* tft = nullptr;
18+
GFXcanvas16* canvas = nullptr;
19+
GFXcanvas16* canvasSmall = nullptr;
20+
bool firstInit = true;
21+
22+
int16_t width = 320;
23+
int16_t height = 240;
24+
25+
/* Delegate GFX drawing calls to TFT */
26+
Adafruit_GFX* gfx( ) { return tft; }
27+
};

src/display/TftDisplayDriver.h

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

src/display/XPT2046.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @file display/XPT2046.h
3+
* @brief XPT2046 resistive touch controller driver.
4+
* @details Wraps the XPT2046_Touchscreen library. Provides touch point
5+
* reading and raw touch state detection.
6+
*
7+
* @project SIMUT — Integrated Universal Monitoring and Telemetry System
8+
* @license MIT License
9+
*/
10+
#pragma once
11+
#include <Arduino.h>
12+
#include <XPT2046_Touchscreen.h>
13+
14+
struct Xpt2046_Touch {
15+
XPT2046_Touchscreen* ts = nullptr;
16+
};

0 commit comments

Comments
 (0)