From 0574bb6d60c19504cb424d1860d7253c7498b1b9 Mon Sep 17 00:00:00 2001 From: Martin Vladic Date: Sun, 17 Nov 2024 13:17:00 +0100 Subject: [PATCH] Fixed: [LVGL] In generated source code, user widgets are also included inside enum ScreensEnum and static const char *screen_names[] = { ... }; #637 --- packages/project-editor/lvgl/build.ts | 11 +++++++---- packages/project-editor/lvgl/page-runtime.ts | 6 +++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/project-editor/lvgl/build.ts b/packages/project-editor/lvgl/build.ts index 93ee3ba2..3515c78a 100644 --- a/packages/project-editor/lvgl/build.ts +++ b/packages/project-editor/lvgl/build.ts @@ -831,10 +831,11 @@ export class LVGLBuild extends Build { build.line(""); build.line(`enum ScreensEnum {`); build.indent(); - for (let i = 0; i < this.pages.length; i++) { + const pages = this.pages.filter(page => !page.isUsedAsUserWidget); + for (let i = 0; i < pages.length; i++) { build.line( `SCREEN_ID_${this.getScreenIdentifier( - this.pages[i] + pages[i] ).toUpperCase()} = ${i + 1},` ); } @@ -1376,13 +1377,15 @@ export class LVGLBuild extends Build { } if (this.assets.projectStore.projectTypeTraits.hasFlowSupport) { - if (this.pages.length > 0) { + const pages = this.pages.filter(page => !page.isUsedAsUserWidget); + if (pages.length > 0) { build.line( - `static const char *screen_names[] = { ${this.pages + `static const char *screen_names[] = { ${pages .map(page => `"${page.name}"`) .join(", ")} };` ); } + if (this.lvglObjectIdentifiers.fromPage.identifiers.length > 0) { build.line( `static const char *object_names[] = { ${this.lvglObjectIdentifiers.fromPage.identifiers diff --git a/packages/project-editor/lvgl/page-runtime.ts b/packages/project-editor/lvgl/page-runtime.ts index 43807590..0fc476a8 100644 --- a/packages/project-editor/lvgl/page-runtime.ts +++ b/packages/project-editor/lvgl/page-runtime.ts @@ -160,9 +160,9 @@ export abstract class LVGLPageRuntime { getLvglScreenByName(screenName: string) { return ( - this.project._store.lvglIdentifiers.pages.findIndex( - page => page.name == screenName - ) + 1 + this.project._store.lvglIdentifiers.pages + .filter(page => !page.isUsedAsUserWidget) + .findIndex(page => page.name == screenName) + 1 ); }