You've already forked meshtastic-device-ui
mirror of
https://github.com/m5stack/meshtastic-device-ui.git
synced 2026-05-20 11:51:03 -07:00
96 lines
2.4 KiB
C++
96 lines
2.4 KiB
C++
#include "graphics/DeviceGUI.h"
|
|
#include "graphics/driver/DisplayDriver.h"
|
|
#include "graphics/driver/DisplayDriverConfig.h"
|
|
#include "input/InputDriver.h"
|
|
|
|
#if LV_USE_LIBINPUT
|
|
#include "input/LinuxInputDriver.h"
|
|
static LinuxInputDriver *linuxInputDriver = nullptr;
|
|
#else
|
|
#if defined(INPUTDRIVER_I2C_KBD_TYPE)
|
|
#include "input/I2CKeyboardInputDriver.h"
|
|
static I2CKeyboardInputDriver *keyboardDriver = nullptr;
|
|
#endif
|
|
#if defined(INPUTDRIVER_ENCODER_TYPE)
|
|
#include "input/EncoderInputDriver.h"
|
|
static EncoderInputDriver *encoderDriver = nullptr;
|
|
#endif
|
|
#if defined(INPUTDRIVER_MATRIX_TYPE)
|
|
#include "input/KeyMatrixInputDriver.h"
|
|
static KeyMatrixInputDriver *keyMatrixDriver = nullptr;
|
|
#endif
|
|
#if defined(INPUTDRIVER_BUTTON_TYPE)
|
|
#include "input/ButtonInputDriver.h"
|
|
static ButtonInputDriver *buttonDriver = nullptr;
|
|
#endif
|
|
#endif
|
|
#include "lvgl.h"
|
|
#include "ui.h"
|
|
#include "util/ILog.h"
|
|
|
|
DeviceGUI::DeviceGUI(const DisplayDriverConfig *cfg, DisplayDriver *driver) : displaydriver(driver), inputdriver(nullptr)
|
|
{
|
|
#if LV_USE_LIBINPUT
|
|
if (cfg)
|
|
linuxInputDriver = new LinuxInputDriver(cfg->keyboard(), cfg->pointer());
|
|
// else
|
|
// linuxInputDriver = InputDriver::instance();
|
|
#else
|
|
#if defined(INPUTDRIVER_I2C_KBD_TYPE)
|
|
keyboardDriver = new I2CKeyboardInputDriver;
|
|
#endif
|
|
#if defined(INPUTDRIVER_ENCODER_TYPE)
|
|
encoderDriver = new EncoderInputDriver;
|
|
#endif
|
|
#if defined(INPUTDRIVER_MATRIX_TYPE)
|
|
keyMatrixDriver = new KeyMatrixInputDriver;
|
|
#endif
|
|
#if defined(INPUTDRIVER_BUTTON_TYPE)
|
|
buttonDriver = new ButtonInputDriver;
|
|
#endif
|
|
#endif
|
|
if (!inputdriver)
|
|
inputdriver = InputDriver::instance();
|
|
}
|
|
|
|
void DeviceGUI::init(IClientBase *client)
|
|
{
|
|
ILOG_DEBUG("Display driver init...");
|
|
displaydriver->init(this);
|
|
|
|
ILOG_DEBUG("Input driver init...");
|
|
#if LV_USE_LIBINPUT
|
|
if (linuxInputDriver)
|
|
linuxInputDriver->init();
|
|
#endif
|
|
#if defined(INPUTDRIVER_I2C_KBD_TYPE)
|
|
if (keyboardDriver)
|
|
keyboardDriver->init();
|
|
#endif
|
|
#if defined(INPUTDRIVER_ENCODER_TYPE)
|
|
if (encoderDriver)
|
|
encoderDriver->init();
|
|
#endif
|
|
#if defined(INPUTDRIVER_MATRIX_TYPE)
|
|
if (keyMatrixDriver)
|
|
keyMatrixDriver->init();
|
|
#endif
|
|
#if defined(INPUTDRIVER_BUTTON_TYPE)
|
|
if (buttonDriver)
|
|
buttonDriver->init();
|
|
#endif
|
|
if (inputdriver)
|
|
inputdriver->init();
|
|
|
|
displaydriver->printConfig();
|
|
}
|
|
|
|
void DeviceGUI::task_handler(void)
|
|
{
|
|
displaydriver->task_handler();
|
|
};
|
|
|
|
DeviceGUI::~DeviceGUI()
|
|
{
|
|
delete inputdriver;
|
|
} |