@@ -50,11 +50,6 @@ static const std::map<std::string, FnCreateDispDrvTft> FactoryDrvDispTft = {
50
50
return new dispDrvSt7789 (cs, dc, mosi, sck, rst, miso);
51
51
}},
52
52
{" 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" ,
58
53
[](int16_t cs, int16_t dc, int16_t mosi, int16_t sck, int16_t rst,
59
54
int16_t miso) -> dispDrvBase * {
60
55
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,
93
88
name.
94
89
@param driver_name
95
90
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.
96
105
*/
97
106
dispDrvBase *CreateDrvDispTft (const char *driver_name, int16_t cs, int16_t dc,
98
107
int16_t mosi, int16_t sck, int16_t rst = -1 ,
@@ -244,6 +253,18 @@ bool DisplayHardware::beginEPD(
244
253
return true ;
245
254
}
246
255
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
+
247
268
/* !
248
269
@brief Attempts to configure and initialize a TFT display
249
270
@param config
@@ -282,24 +303,33 @@ bool DisplayHardware::beginTft(
282
303
miso = parsePin (spi_config->pin_miso );
283
304
}
284
305
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
+
285
320
// Create display driver object using the factory function
286
321
_drvDisp = CreateDrvDispTft (_name, cs, dc, mosi, sck, rst, miso);
287
322
if (!_drvDisp) {
288
323
WS_DEBUG_PRINTLN (" [display] Failed to create display driver!" );
289
324
return false ;
290
325
}
291
326
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
-
297
327
_drvDisp->setWidth (config->width );
298
328
_drvDisp->setHeight (config->height );
299
329
_drvDisp->setRotation (config->rotation );
300
330
_drvDisp->begin ();
331
+ _drvDisp->setTextSize (text_sz);
301
332
302
- WS_DEBUG_PRINTLN (" [display] TFT display initialized successfully!" );
303
333
return true ;
304
334
}
305
335
0 commit comments