2020using FnCreateDispDrvEpd =
2121 std::function<dispDrvBase *(int16_t , int16_t , int16_t , int16_t , int16_t )>;
2222
23- // Factory for creating a new display drivers
23+ // Factory for creating new display drivers
2424// NOTE: When you add a new display driver, make sure to add it to the factory!
25- static const std::map<std::string, FnCreateDispDrvEpd> FactoryDrvDispEpd = {
26- {" eink-29-grayscale-ssd1680" ,
27- [](int16_t dc, int16_t rst, int16_t cs, int16_t sram_cs,
28- int16_t busy) -> dispDrvBase * {
29- return new drvDispThinkInkGrayscale4Eaamfgn (dc, rst, cs, sram_cs, busy);
30- }},
31- {" thinkink-gs4-t5" ,
32- [](int16_t dc, int16_t rst, int16_t cs, int16_t sram_cs,
33- int16_t busy) -> dispDrvBase * {
34- return new dispDrvThinkInkGrayscale4T5 (dc, rst, cs, sram_cs, busy);
35- }}};
25+ static const std::map<wippersnapper_display_v1_DisplayDriver,
26+ FnCreateDispDrvEpd>
27+ FactoryDrvDispEpd = {
28+ {wippersnapper_display_v1_DisplayDriver_DISPLAY_DRIVER_EPD_SSD1680,
29+ [](int16_t dc, int16_t rst, int16_t cs, int16_t sram_cs,
30+ int16_t busy) -> dispDrvBase * {
31+ return new drvDispThinkInkGrayscale4Eaamfgn (dc, rst, cs, sram_cs,
32+ busy);
33+ }},
34+ {wippersnapper_display_v1_DisplayDriver_DISPLAY_DRIVER_EPD_ILI0373,
35+ [](int16_t dc, int16_t rst, int16_t cs, int16_t sram_cs,
36+ int16_t busy) -> dispDrvBase * {
37+ return new dispDrvThinkInkGrayscale4T5 (dc, rst, cs, sram_cs, busy);
38+ }}};
3639
3740/* !
3841 @brief Lambda function to create a dispDrvBase SPI TFT instance
@@ -43,23 +46,20 @@ using FnCreateDispDrvTft = std::function<dispDrvBase *(
4346// Factory for creating a new SPI TFT display driver
4447// NOTE: When you add a new SPI TFT display driver, make sure to add it to the
4548// factory!
46- static const std::map<std::string, FnCreateDispDrvTft> FactoryDrvDispTft = {
47- {" tft-154-wide-angle" ,
48- [](int16_t cs, int16_t dc, int16_t mosi, int16_t sck, int16_t rst,
49- int16_t miso) -> dispDrvBase * {
50- return new dispDrvSt7789 (cs, dc, mosi, sck, rst, miso);
51- }},
52- {" tft-114" ,
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- }}};
49+ static const std::map<wippersnapper_display_v1_DisplayDriver,
50+ FnCreateDispDrvTft>
51+ FactoryDrvDispTft = {
52+ {wippersnapper_display_v1_DisplayDriver_DISPLAY_DRIVER_TFT_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+ }}};
5757
5858/* !
5959 @brief Creates a new E-Ink display driver instance based on the driver
6060 name.
61- @param driver_name
62- The name of the display driver to create.
61+ @param driver
62+ The name of the EPD display driver to create.
6363 @param dc
6464 Data/Command pin number.
6565 @param rst
@@ -73,10 +73,10 @@ static const std::map<std::string, FnCreateDispDrvTft> FactoryDrvDispTft = {
7373 @return Pointer to the created display driver instance, or nullptr if the
7474 driver name is not recognized.
7575*/
76- dispDrvBase *CreateDrvDispEpd (const char *driver_name, int16_t dc, int16_t rst ,
77- int16_t cs , int16_t sram_cs = - 1 ,
78- int16_t busy = -1 ) {
79- auto it = FactoryDrvDispEpd.find (driver_name );
76+ dispDrvBase *CreateDrvDispEpd (wippersnapper_display_v1_DisplayDriver driver ,
77+ int16_t dc , int16_t rst, int16_t cs ,
78+ int16_t sram_cs = - 1 , int16_t busy = -1 ) {
79+ auto it = FactoryDrvDispEpd.find (driver );
8080 if (it == FactoryDrvDispEpd.end ())
8181 return nullptr ;
8282
@@ -86,7 +86,7 @@ dispDrvBase *CreateDrvDispEpd(const char *driver_name, int16_t dc, int16_t rst,
8686/* !
8787 @brief Creates a new SPI TFT display driver instance based on the driver
8888 name.
89- @param driver_name
89+ @param driver
9090 The name of the SPI TFT display driver to create.
9191 @param cs
9292 Chip Select pin number.
@@ -103,10 +103,10 @@ dispDrvBase *CreateDrvDispEpd(const char *driver_name, int16_t dc, int16_t rst,
103103 @return Pointer to the created display driver instance, or nullptr if the
104104 driver name is not recognized.
105105*/
106- dispDrvBase *CreateDrvDispTft (const char *driver_name, int16_t cs, int16_t dc ,
107- int16_t mosi , int16_t sck , int16_t rst = - 1 ,
108- int16_t miso = -1 ) {
109- auto it = FactoryDrvDispTft.find (driver_name );
106+ dispDrvBase *CreateDrvDispTft (wippersnapper_display_v1_DisplayDriver driver ,
107+ int16_t cs , int16_t dc , int16_t mosi, int16_t sck ,
108+ int16_t rst = - 1 , int16_t miso = -1 ) {
109+ auto it = FactoryDrvDispTft.find (driver );
110110 if (it == FactoryDrvDispTft.end ())
111111 return nullptr ;
112112
@@ -174,6 +174,7 @@ int16_t DisplayHardware::parsePin(const char *pinStr) {
174174 @return True if configuration was successful, False otherwise.
175175*/
176176bool DisplayHardware::beginEPD (
177+ wippersnapper_display_v1_DisplayDriver *driver,
177178 wippersnapper_display_v1_EPDConfig *config,
178179 wippersnapper_display_v1_EpdSpiConfig *spi_config) {
179180 // Validate pointers
@@ -217,7 +218,7 @@ bool DisplayHardware::beginEPD(
217218 }
218219
219220 // Create display driver object using the factory function
220- _drvDisp = CreateDrvDispEpd (_name , dc, rst, cs, srcs, busy);
221+ _drvDisp = CreateDrvDispEpd (*driver , dc, rst, cs, srcs, busy);
221222 if (!_drvDisp) {
222223 WS_DEBUG_PRINTLN (" [display] Failed to create display driver!" );
223224 return false ; // Failed to create display driver
@@ -308,6 +309,7 @@ void DisplayHardware::removeSuffix(const char *suffix) {
308309 @return True if configuration was successful, False otherwise.
309310*/
310311bool DisplayHardware::beginTft (
312+ wippersnapper_display_v1_DisplayDriver *driver,
311313 wippersnapper_display_v1_TftConfig *config,
312314 wippersnapper_display_v1_TftSpiConfig *spi_config) {
313315 // Validate pointers
@@ -338,7 +340,7 @@ bool DisplayHardware::beginTft(
338340 }
339341
340342 // Create display driver object using the factory function
341- _drvDisp = CreateDrvDispTft (_name , cs, dc, mosi, sck, rst, miso);
343+ _drvDisp = CreateDrvDispTft (*driver , cs, dc, mosi, sck, rst, miso);
342344 if (!_drvDisp) {
343345 WS_DEBUG_PRINTLN (" [display] Failed to create display driver!" );
344346 return false ;
0 commit comments