@@ -173,8 +173,9 @@ int16_t DisplayHardware::parsePin(const char *pinStr) {
173173 Pointer to the SPI configuration structure for EPD.
174174 @return True if configuration was successful, False otherwise.
175175*/
176- bool DisplayHardware::beginEPD (wippersnapper_display_v1_EPDConfig *config,
177- wippersnapper_display_v1_SpiConfig *spi_config) {
176+ bool DisplayHardware::beginEPD (
177+ wippersnapper_display_v1_EPDConfig *config,
178+ wippersnapper_display_v1_EpdSpiConfig *spi_config) {
178179 // Validate pointers
179180 if (config == nullptr || spi_config == nullptr ) {
180181 WS_DEBUG_PRINTLN (" [display] EPD config or SPI config is null!" );
@@ -272,8 +273,9 @@ void DisplayHardware::removeSuffix(const char *suffix) {
272273 Pointer to the SPI configuration structure for TFT.
273274 @return True if configuration was successful, False otherwise.
274275*/
275- bool DisplayHardware::beginTft (wippersnapper_display_v1_TftConfig *config,
276- wippersnapper_display_v1_SpiConfig *spi_config) {
276+ bool DisplayHardware::beginTft (
277+ wippersnapper_display_v1_TftConfig *config,
278+ wippersnapper_display_v1_TftSpiConfig *spi_config) {
277279 // Validate pointers
278280 if (config == nullptr || spi_config == nullptr ) {
279281 WS_DEBUG_PRINTLN (" [display] EPD config or SPI config is null!" );
@@ -331,133 +333,6 @@ bool DisplayHardware::beginTft(wippersnapper_display_v1_TftConfig *config,
331333 return true ;
332334}
333335
334- /* !
335- @brief Attempts to configure and initialize an OLED display
336- @param config
337- Pointer to the OLED's configuration structure.
338- @param i2c_config
339- Pointer to the I2C configuration structure.
340- @return True if configuration was successful, False otherwise.
341- */
342- bool DisplayHardware::beginOled (
343- wippersnapper_display_v1_OledConfig *config,
344- wippersnapper_display_v1_I2cConfig *i2c_config) {
345- // Validate pointers
346- if (config == nullptr || i2c_config == nullptr || !i2c_config->has_i2c )
347- return false ;
348-
349- // If we already have a display driver assigned to this hardware instance,
350- // clean it up!
351- if (_drvDisp) {
352- delete _drvDisp;
353- _drvDisp = nullptr ;
354- }
355-
356- // Initialize OLED display driver based on device name
357- if (strnlen (i2c_config->i2c .i2c_device_name ,
358- sizeof (i2c_config->i2c .i2c_device_name )) <
359- sizeof (i2c_config->i2c .i2c_device_name ) &&
360- strcmp (i2c_config->i2c .i2c_device_name , " SSD1306" ) == 0 ) {
361- _drvDisp = new dispDrvSsd1306 (WS._i2cPort0 ->getBus (),
362- i2c_config->i2c .i2c_device_address );
363- } else if (strnlen (i2c_config->i2c .i2c_device_name ,
364- sizeof (i2c_config->i2c .i2c_device_name )) <
365- sizeof (i2c_config->i2c .i2c_device_name ) &&
366- strcmp (i2c_config->i2c .i2c_device_name , " SH1107" ) == 0 ) {
367- _drvDisp = new dispDrvSh1107 (WS._i2cPort0 ->getBus (),
368- i2c_config->i2c .i2c_device_address );
369- } else {
370- WS_DEBUG_PRINTLN (" [display] Unsupported OLED driver!" );
371- return false ;
372- }
373-
374- // Validate that the display driver was created successfully
375- if (!_drvDisp) {
376- WS_DEBUG_PRINTLN (" [display] Failed to create display driver!" );
377- _drvDisp = nullptr ;
378- return false ;
379- }
380-
381- // Configure display dimensions and text size
382- _drvDisp->setWidth (config->width );
383- _drvDisp->setHeight (config->height );
384- _drvDisp->setTextSize (config->text_size );
385-
386- // Initialize the display driver
387- if (!_drvDisp->begin ()) {
388- WS_DEBUG_PRINTLN (" [display] Failed to begin display driver!" );
389- delete _drvDisp;
390- _drvDisp = nullptr ;
391- return false ;
392- }
393-
394- WS_DEBUG_PRINTLN (" [display] OLED initialized successfully." );
395- return true ;
396- }
397-
398- /* !
399- @brief Attempts to configure and initialize an LED Backpack display
400- @param config
401- Pointer to the LED Backpack's configuration structure.
402- @param i2c_config
403- Pointer to the I2C configuration structure.
404- @return True if configuration was successful, False otherwise.
405- */
406- bool DisplayHardware::beginLedBackpack (
407- wippersnapper_display_v1_LEDBackpackConfig *config,
408- wippersnapper_display_v1_I2cConfig *i2c_config) {
409- // Validate pointers
410- if (config == nullptr || i2c_config == nullptr || !i2c_config->has_i2c )
411- return false ;
412-
413- // If we already have a display driver assigned to this hardware instance,
414- // clean it up!
415- if (_drvDisp) {
416- delete _drvDisp;
417- _drvDisp = nullptr ;
418- }
419-
420- // Initialize OLED display driver based on device name
421- if (strnlen (i2c_config->i2c .i2c_device_name ,
422- sizeof (i2c_config->i2c .i2c_device_name )) <
423- sizeof (i2c_config->i2c .i2c_device_name ) &&
424- strcmp (i2c_config->i2c .i2c_device_name , " 7seg" ) == 0 ) {
425- _drvDisp = new dispDrv7Seg (WS._i2cPort0 ->getBus (),
426- i2c_config->i2c .i2c_device_address );
427- } else if (strnlen (i2c_config->i2c .i2c_device_name ,
428- sizeof (i2c_config->i2c .i2c_device_name )) <
429- sizeof (i2c_config->i2c .i2c_device_name ) &&
430- strcmp (i2c_config->i2c .i2c_device_name , " quadalphanum" ) == 0 ) {
431- _drvDisp = new dispDrvQuadAlphaNum (WS._i2cPort0 ->getBus (),
432- i2c_config->i2c .i2c_device_address );
433- } else {
434- WS_DEBUG_PRINTLN (" [display] Unsupported OLED driver!" );
435- return false ;
436- }
437-
438- // Validate that the display driver was created successfully
439- if (!_drvDisp) {
440- WS_DEBUG_PRINTLN (" [display] Failed to create display driver!" );
441- _drvDisp = nullptr ;
442- return false ;
443- }
444-
445- // Configure display dimensions and text size
446- _drvDisp->setAlignment (config->alignment );
447- _drvDisp->setBrightness (config->brightness );
448-
449- // Initialize the display driver
450- if (!_drvDisp->begin ()) {
451- WS_DEBUG_PRINTLN (" [display] Failed to begin driver!" );
452- delete _drvDisp;
453- _drvDisp = nullptr ;
454- return false ;
455- }
456-
457- WS_DEBUG_PRINTLN (" [display] LED backpack initialized successfully." );
458- return true ;
459- }
460-
461336/* !
462337 @brief Gets the name of the display hardware instance.
463338 @return The name of the display hardware instance.
0 commit comments