Skip to content

Commit

Permalink
Fixed: [LVGL] In generated source code, user widgets are also include…
Browse files Browse the repository at this point in the history
…d inside enum ScreensEnum and static const char *screen_names[] = { ... }; #637
  • Loading branch information
mvladic committed Nov 17, 2024
1 parent dd4d67e commit 0574bb6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions packages/project-editor/lvgl/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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},`
);
}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions packages/project-editor/lvgl/page-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down

0 comments on commit 0574bb6

Please sign in to comment.