2025-01-12 18:08:57 +01:00
|
|
|
#include "graphics/common/ViewFactory.h"
|
2024-05-16 08:38:13 +02:00
|
|
|
#if defined(VIEW_128x64) || defined(ARCH_PORTDUINO)
|
2025-01-12 18:08:57 +01:00
|
|
|
#include "graphics/view/OLED/OLEDView_128x64.h"
|
2024-04-15 14:54:47 +02:00
|
|
|
#endif
|
2024-05-16 08:38:13 +02:00
|
|
|
#if defined(VIEW_160x80) || defined(ARCH_PORTDUINO)
|
2025-01-12 18:08:57 +01:00
|
|
|
#include "graphics/view/TFT/TFTView_160x80.h"
|
2024-04-15 14:54:47 +02:00
|
|
|
#endif
|
2024-05-16 08:38:13 +02:00
|
|
|
#if defined(VIEW_240x240) || defined(ARCH_PORTDUINO)
|
2025-01-12 18:08:57 +01:00
|
|
|
#include "graphics/view/TFT/TFTView_240x240.h"
|
2024-04-15 14:54:47 +02:00
|
|
|
#endif
|
2024-05-16 08:38:13 +02:00
|
|
|
#if defined(VIEW_320x240) || defined(ARCH_PORTDUINO)
|
2025-01-12 18:08:57 +01:00
|
|
|
#include "graphics/view/TFT/TFTView_320x240.h"
|
2024-04-15 14:54:47 +02:00
|
|
|
#endif
|
2025-08-16 18:28:05 +02:00
|
|
|
#if defined(VIEW_480x222) || defined(ARCH_PORTDUINO)
|
|
|
|
|
#include "graphics/view/TFT/TFTView_480x222.h"
|
2024-04-15 14:54:47 +02:00
|
|
|
#endif
|
2025-01-12 18:08:57 +01:00
|
|
|
#include "util/ILog.h"
|
2024-04-15 14:54:47 +02:00
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
|
|
ViewFactory::ViewFactory(void) {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Compile-time fix view creation
|
|
|
|
|
*
|
|
|
|
|
* @return DeviceGUI*
|
|
|
|
|
*/
|
|
|
|
|
DeviceGUI *ViewFactory::create(void)
|
|
|
|
|
{
|
|
|
|
|
#if defined(VIEW_128x64)
|
|
|
|
|
return OLEDView_128x64::instance();
|
|
|
|
|
#elif defined(VIEW_160x80)
|
|
|
|
|
return TFTView_160x80::instance();
|
|
|
|
|
#elif defined(VIEW_240x240)
|
|
|
|
|
return TFTView_240x240::instance();
|
2025-08-16 18:28:05 +02:00
|
|
|
#elif defined(VIEW_480x222)
|
|
|
|
|
return TFTView_480x222::instance();
|
2024-04-15 14:54:47 +02:00
|
|
|
#elif defined(VIEW_320x240)
|
|
|
|
|
return TFTView_320x240::instance();
|
|
|
|
|
#endif
|
2024-10-17 09:06:42 +02:00
|
|
|
ILOG_CRIT("ViewFactory: VIEW is not defined and no config provided");
|
2024-05-05 20:42:25 +02:00
|
|
|
assert(false);
|
2024-04-15 14:54:47 +02:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Run-time view creation
|
|
|
|
|
*
|
|
|
|
|
* @param cfg
|
|
|
|
|
* @return DeviceGUI*
|
|
|
|
|
*/
|
|
|
|
|
DeviceGUI *ViewFactory::create(const DisplayDriverConfig &cfg)
|
|
|
|
|
{
|
2025-08-16 18:28:05 +02:00
|
|
|
#if defined(VIEW_128x64)
|
2024-04-15 14:54:47 +02:00
|
|
|
if (cfg.width() == 128 && cfg.height() == 64) {
|
|
|
|
|
return OLEDView_128x64::instance(cfg);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2025-08-16 18:28:05 +02:00
|
|
|
#if defined(VIEW_160x80)
|
2024-04-15 14:54:47 +02:00
|
|
|
if (cfg.width() == 160 && cfg.height() == 80) {
|
|
|
|
|
return TFTView_160x80::instance(cfg);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2025-08-16 18:28:05 +02:00
|
|
|
#if defined(VIEW_240x240)
|
2024-04-15 14:54:47 +02:00
|
|
|
if (cfg.width() == 240 && cfg.height() == 240) {
|
|
|
|
|
return TFTView_240x240::instance(cfg);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2025-08-16 18:28:05 +02:00
|
|
|
#if defined(VIEW_480x222)
|
|
|
|
|
if (cfg.width() == 480 && cfg.height() == 222) {
|
|
|
|
|
return TFTView_480x222::instance(cfg);
|
2024-04-15 14:54:47 +02:00
|
|
|
}
|
|
|
|
|
#endif
|
2025-08-16 18:28:05 +02:00
|
|
|
#if defined(VIEW_320x240)
|
2024-04-15 14:54:47 +02:00
|
|
|
// default if nothing else matches
|
|
|
|
|
return TFTView_320x240::instance(cfg);
|
|
|
|
|
#endif
|
2025-08-16 18:28:05 +02:00
|
|
|
ILOG_CRIT("ViewFactory: did not find suitable view for creation with config %dx%d", cfg.width(), cfg.height());
|
|
|
|
|
assert(false);
|
|
|
|
|
return nullptr;
|
2024-04-15 14:54:47 +02:00
|
|
|
}
|