mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 08:15:17 +03:00
Merge pull request #8412 from opentx/raphaelcoeffic/fix-model-select
2.4 fix model select
This commit is contained in:
commit
a3a375efc8
8 changed files with 73 additions and 35 deletions
|
@ -63,6 +63,12 @@ set(FIRMWARE_C_FLAGS_DEBUG "-g" CACHE STRING "Additional flags for firmware targ
|
|||
set(FIRMWARE_CXX_FLAGS "" CACHE STRING "Additional flags for firmware target c++ compiler (note: all CMAKE_CXX_FLAGS[_*] are ignored for firmware/bootloader).")
|
||||
set(FIRMWARE_CXX_FLAGS_DEBUG "-g" CACHE STRING "Additional flags for firmware target (Debug config) c++ compiler (note: CMAKE_CXX_FLAGS_DEBUG is ignored for firmware/bootloader).")
|
||||
|
||||
set(FIRMWARE_C_COMPILER "arm-none-eabi-gcc" CACHE STRING "Specific C compiler for firmware target.")
|
||||
set(FIRMWARE_CXX_COMPILER "arm-none-eabi-g++" CACHE STRING "Specific C++ compiler for firmware target.")
|
||||
set(FIRMWARE_ASM_COMPILER "arm-none-eabi-as" CACHE STRING "Specific assembler for firmware target.")
|
||||
set(FIRMWARE_OBJCOPY "arm-none-eabi-objcopy" CACHE STRING "Specific objcopy for firmware target.")
|
||||
set(FIRMWARE_SIZE "arm-none-eabi-size" CACHE STRING "Specific size for firmware target.")
|
||||
|
||||
set(THIRDPARTY_DIR thirdparty)
|
||||
set(LUA_DIR ${THIRDPARTY_DIR}/Lua/src)
|
||||
set(COOS_DIR ${THIRDPARTY_DIR}/CoOS)
|
||||
|
@ -497,9 +503,9 @@ if(NOT MSVC)
|
|||
|
||||
if(ARCH STREQUAL ARM)
|
||||
enable_language(ASM)
|
||||
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
|
||||
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
|
||||
set(CMAKE_ASM_COMPILER arm-none-eabi-as)
|
||||
set(CMAKE_C_COMPILER ${FIRMWARE_C_COMPILER})
|
||||
set(CMAKE_CXX_COMPILER ${FIRMWARE_CXX_COMPILER})
|
||||
set(CMAKE_ASM_COMPILER ${FIRMWARE_ASM_COMPILER})
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
set(CMAKE_SYSTEM_VERSION 1)
|
||||
|
@ -559,7 +565,7 @@ if(NOT MSVC)
|
|||
|
||||
add_custom_command(
|
||||
TARGET firmware POST_BUILD
|
||||
COMMAND arm-none-eabi-objcopy -O binary firmware.elf firmware.bin
|
||||
COMMAND ${FIRMWARE_OBJCOPY} -O binary firmware.elf firmware.bin
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
||||
|
@ -572,7 +578,7 @@ if(NOT MSVC)
|
|||
)
|
||||
else()
|
||||
add_custom_target(firmware-size
|
||||
COMMAND arm-none-eabi-size -A firmware.elf
|
||||
COMMAND ${FIRMWARE_SIZE} -A firmware.elf
|
||||
DEPENDS firmware
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
|
|
@ -51,9 +51,7 @@ uint8_t aux2SerialTracesEnabled();
|
|||
#elif defined(DEBUG)
|
||||
#define debugPrintf(...) do { serialPrintf(__VA_ARGS__); } while(0)
|
||||
#else
|
||||
inline void debugPrintf(const char *, ...)
|
||||
{
|
||||
}
|
||||
#define debugPrintf(...)
|
||||
#endif
|
||||
|
||||
#define TRACE_TIME_FORMAT "%0.2f "
|
||||
|
|
|
@ -37,7 +37,7 @@ void registerLayout(const LayoutFactory * factory)
|
|||
|
||||
const LayoutFactory * getLayoutFactory(const char * name)
|
||||
{
|
||||
std::list<const LayoutFactory *>::const_iterator it = getRegisteredLayouts().cbegin();
|
||||
auto it = getRegisteredLayouts().cbegin();
|
||||
for (; it != getRegisteredLayouts().cend(); ++it) {
|
||||
if (!strcmp(name, (*it)->getId())) {
|
||||
return (*it);
|
||||
|
@ -55,21 +55,48 @@ Layout * loadLayout(const char * name, Layout::PersistentData * persistentData)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void deleteCustomScreens()
|
||||
{
|
||||
for (unsigned int i = 0; i < MAX_CUSTOM_SCREENS; i++) {
|
||||
auto& screen = customScreens[i];
|
||||
if (screen) {
|
||||
screen->detach();
|
||||
delete screen;
|
||||
screen = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern const LayoutFactory * defaultLayout;
|
||||
|
||||
void loadDefaultLayout()
|
||||
{
|
||||
auto& screen = customScreens[0];
|
||||
auto& screenData = g_model.screenData[0];
|
||||
|
||||
if (screen == nullptr && defaultLayout != nullptr) {
|
||||
strcpy(screenData.layoutName, defaultLayout->getName());
|
||||
screen = defaultLayout->create(&screenData.layoutData);
|
||||
if (screen) {
|
||||
screen->attach(ViewMain::instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loadCustomScreens()
|
||||
{
|
||||
for (unsigned int i = 0; i < MAX_CUSTOM_SCREENS; i++) {
|
||||
delete customScreens[i];
|
||||
char name[LAYOUT_NAME_LEN + 1];
|
||||
memset(name, 0, sizeof(name));
|
||||
strncpy(name, g_model.screenData[i].layoutName, LAYOUT_NAME_LEN);
|
||||
customScreens[i] = loadLayout(name, &g_model.screenData[i].layoutData);
|
||||
|
||||
auto& screen = customScreens[i];
|
||||
screen = loadLayout(g_model.screenData[i].layoutName,
|
||||
&g_model.screenData[i].layoutData);
|
||||
|
||||
if (screen) {
|
||||
screen->attach(ViewMain::instance);
|
||||
}
|
||||
}
|
||||
|
||||
if (customScreens[0] == nullptr && getRegisteredLayouts().size()) {
|
||||
customScreens[0] = getRegisteredLayouts().front()->create(&g_model.screenData[0].layoutData);
|
||||
}
|
||||
|
||||
customScreens[g_model.view]->attach(ViewMain::instance);
|
||||
//customScreens[g_model.view]->attach(ViewMain::instance);
|
||||
}
|
||||
|
||||
void Layout::decorate(bool topbar, bool sliders, bool trims, bool flightMode)
|
||||
|
|
|
@ -123,6 +123,11 @@ class BaseLayoutFactory: public LayoutFactory
|
|||
};
|
||||
|
||||
Layout * loadLayout(const char * name, Layout::PersistentData * persistentData);
|
||||
|
||||
// intented for new models
|
||||
void loadDefaultLayout();
|
||||
|
||||
// intended for existing models
|
||||
void loadCustomScreens();
|
||||
|
||||
void drawTrimsAndSliders(Layout::PersistentData * persistentData);
|
||||
|
|
|
@ -211,17 +211,23 @@ class ModelSelectFooter: public Window {
|
|||
dc->drawSolidFilledRect(0, 0, width(), height(), DISABLE_COLOR);
|
||||
uint32_t size = sdGetSize() / 100;
|
||||
coord_t x = 7;
|
||||
dc->drawMask(7, 4, modelselSdFreeBitmap, DEFAULT_COLOR);
|
||||
x += modelselSdFreeBitmap->width() + 3;
|
||||
if (modelselSdFreeBitmap) {
|
||||
dc->drawMask(7, 4, modelselSdFreeBitmap, DEFAULT_COLOR);
|
||||
x += modelselSdFreeBitmap->width() + 3;
|
||||
}
|
||||
x = dc->drawNumber(x, 3, size, PREC1|FONT(XS), 0, nullptr, "GB");
|
||||
x += 20;
|
||||
dc->drawMask(x, 4, modelselModelQtyBitmap, DEFAULT_COLOR);
|
||||
x += modelselModelQtyBitmap->width() + 3;
|
||||
if (modelselModelQtyBitmap) {
|
||||
dc->drawMask(x, 4, modelselModelQtyBitmap, DEFAULT_COLOR);
|
||||
x += modelselModelQtyBitmap->width() + 3;
|
||||
}
|
||||
x = dc->drawNumber(x, 3, modelslist.getModelsCount(), FONT(XS));
|
||||
if (currentModel) {
|
||||
x += 20;
|
||||
dc->drawMask(x, 4, modelselModelNameBitmap, DEFAULT_COLOR);
|
||||
x += modelselModelNameBitmap->width() + 3;
|
||||
if (modelselModelNameBitmap) {
|
||||
dc->drawMask(x, 4, modelselModelNameBitmap, DEFAULT_COLOR);
|
||||
x += modelselModelNameBitmap->width() + 3;
|
||||
}
|
||||
dc->drawText(x, 3, currentModel->modelFilename, FONT(XS) | DEFAULT_COLOR);
|
||||
}
|
||||
}
|
||||
|
@ -275,8 +281,7 @@ class ModelCategoryPageBody: public FormWindow {
|
|||
loadModel(g_eeGeneral.currModelFilename, false);
|
||||
storageDirty(EE_GENERAL);
|
||||
storageCheck(true);
|
||||
// chainMenu(menuMainView);
|
||||
postModelLoad(true);
|
||||
|
||||
modelslist.setCurrentModel(model);
|
||||
update(); // modelslist.getModelIndex(modelCell));
|
||||
});
|
||||
|
@ -368,6 +373,7 @@ ModelSelectMenu::ModelSelectMenu():
|
|||
{
|
||||
modelslist.load();
|
||||
|
||||
TRACE("TabsGroup: %p", this);
|
||||
for (auto category: modelslist.getCategories()) {
|
||||
addTab(new ModelCategoryPage(category));
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ void ViewMain::openMenu()
|
|||
menu->addLine(STR_MONITOR_SCREENS, []() {
|
||||
new ChannelsViewMenu();
|
||||
});
|
||||
menu->addLine(STR_RESET_SUBMENU, [menu, this]() {
|
||||
menu->addLine(STR_RESET_SUBMENU, [this]() {
|
||||
Menu * resetMenu = new Menu(this);
|
||||
resetMenu->addLine(STR_RESET_FLIGHT, []() {
|
||||
flightReset();
|
||||
|
|
|
@ -511,12 +511,8 @@ void modelDefault(uint8_t id)
|
|||
strAppendUnsigned(strAppend(g_model.header.name, STR_MODEL), id + 1, 2);
|
||||
|
||||
#if defined(COLORLCD)
|
||||
extern const LayoutFactory * defaultLayout;
|
||||
delete customScreens[0];
|
||||
customScreens[0] = defaultLayout->create(&g_model.screenData[0].layoutData);
|
||||
strcpy(g_model.screenData[0].layoutName, "Layout2P1");
|
||||
// extern const WidgetFactory * defaultWidget;
|
||||
// customScreens[0]->createWidget(0, defaultWidget);
|
||||
loadDefaultLayout();
|
||||
|
||||
// enable switch warnings
|
||||
for (int i = 0; i < NUM_SWITCHES; i++) {
|
||||
g_model.switchWarningState |= (1 << (3*i));
|
||||
|
|
|
@ -136,7 +136,7 @@ static inline bool isVBatBridgeEnabled()
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
inline uint32_t ticksNow()
|
||||
static inline uint32_t ticksNow()
|
||||
{
|
||||
#if defined(SIMU)
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue