Skip to content

Commit adb4ddc

Browse files
committed
[LVGL] Color themes #271
1 parent e819f57 commit adb4ddc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2126
-2083
lines changed

packages/eez-studio-types/index.d.ts

+22
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,10 @@ export interface WorkerToRenderMessage {
364364
name: string;
365365
};
366366

367+
setDashboardColorTheme?: {
368+
themeName: string;
369+
};
370+
367371
getLvglScreenByName?: {
368372
name: string;
369373
};
@@ -393,6 +397,10 @@ export interface WorkerToRenderMessage {
393397
targetObj: number;
394398
styleIndex: number;
395399
};
400+
401+
lvglSetColorTheme?: {
402+
themeName: string;
403+
};
396404
}
397405

398406
interface IField {
@@ -502,6 +510,7 @@ interface AssetsMap {
502510
displayWidth: number;
503511
displayHeight: number;
504512
bitmaps: string[];
513+
lvglWidgetIndexes: { [identifier: string]: number };
505514
}
506515

507516
export interface ScpiCommand {
@@ -674,6 +683,8 @@ export interface IWasmFlowRuntime {
674683
_lvglCreateCanvas(parentObj: number, index: number, x: number, y: number, w: number, h: number);
675684

676685
_lvglCreateLed(parentObj: number, index: number, x: number, y: number, w: number, h: number, color: number, brightness: number);
686+
_lvglLedSetColor(obj: number, color: number);
687+
677688
_lvglUpdateLedColor(obj: number, flow_state: number, component_index: number, property_index: number): void;
678689
_lvglUpdateLedBrightness(obj: number, flow_state: number, component_index: number, property_index: number): void;
679690

@@ -726,6 +737,7 @@ export interface IWasmFlowRuntime {
726737
_lvglAddObjectFlowCallback(obj: number, filter: number, flow_state: number, component_index: number, output_or_property_index: number, userDataValuePtr: number): void;
727738
_lvglSetImgbuttonImageSrc(obj: number, statE: number, img_src: number): void;
728739
_lvglSetKeyboardTextarea(obj: number, textarea: number): void;
740+
729741
_lvglMeterAddScale(obj: number,
730742
minorTickCount: number, minorTickLineWidth: number, minorTickLength: number, minorTickColor: number,
731743
nthMajor: number, majorTickWidth: number, majorTickLength: number, majorTickColor: number, labelGap: number,
@@ -737,6 +749,14 @@ export interface IWasmFlowRuntime {
737749
_lvglUpdateMeterIndicatorValue(obj: number, indicator: number, flow_state: number, component_index: number, property_index: number): void;
738750
_lvglUpdateMeterIndicatorStartValue(obj: number, indicator: number, flow_state: number, component_index: number, property_index: number): void;
739751
_lvglUpdateMeterIndicatorEndValue(obj: number, indicator: number, flow_state: number, component_index: number, property_index: number): void;
752+
753+
_lvglMeterIndicatorNeedleLineSetColor(obj: number, indicator: number, color: number);
754+
_lvglMeterIndicatorScaleLinesSetColorStart(obj: number, indicator: number, color: number);
755+
_lvglMeterIndicatorScaleLinesSetColorEnd(obj: number, indicator: number, color: number);
756+
_lvglMeterIndicatorArcSetColor(obj: number, indicator: number, color: number);
757+
_lvglMeterScaleSetMinorTickColor(obj: number, scale: number, color: number);
758+
_lvglMeterScaleSetMajorTickColor(obj: number, scale: number, color: number);
759+
740760
_lvglUpdateLabelText(obj: number, flow_state: number, component_index: number, property_index: number): void;
741761
_lvglUpdateRollerOptions(obj: number, flow_state: number, component_index: number, property_index: number, mode: number): void;
742762
_lvglUpdateRollerSelected(obj: number, flow_state: number, component_index: number, property_index: number): void;
@@ -792,6 +812,8 @@ export interface IWasmFlowRuntime {
792812
_lvglSetKeyboardGroup(groupObj: number): void;
793813
_lvglAddScreenLoadedEventHandler(screenObj: number): void;
794814
_lvglGroupAddObject(screenObj: number, groupObj: number, obj: number): void;
815+
816+
_lvglObjInvalidate(obj: number);
795817
}
796818

797819
export interface IDashboardComponentContext {

packages/project-editor/build/assets.ts

+68-50
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ export class Assets {
160160
typeIndexes: {},
161161
displayWidth: this.displayWidth,
162162
displayHeight: this.displayHeight,
163-
bitmaps: []
163+
bitmaps: [],
164+
lvglWidgetIndexes: {}
164165
};
165166

166167
dashboardComponentClassNameToComponentIdMap: {
@@ -174,6 +175,8 @@ export class Assets {
174175

175176
isUsingCrypyoSha256: boolean = false;
176177

178+
lvglBuild: LVGLBuild;
179+
177180
get projectStore() {
178181
return this.rootProject._store;
179182
}
@@ -208,6 +211,11 @@ export class Assets {
208211
buildConfiguration: BuildConfiguration | undefined,
209212
public option: "check" | "buildAssets" | "buildFiles"
210213
) {
214+
if (rootProject.projectTypeTraits.isLVGL) {
215+
this.lvglBuild = new LVGLBuild(this);
216+
this.lvglBuild.firtsPassStart();
217+
}
218+
211219
this.projectStore.typesStore.reset();
212220

213221
this.getConstantIndex(undefined, "undefined"); // undefined has value index 0
@@ -1283,6 +1291,13 @@ export class Assets {
12831291
this.map.typeIndexes = this.projectStore.typesStore.typeIndexes;
12841292

12851293
this.map.bitmaps = this.bitmaps.map(bitmap => bitmap.name);
1294+
1295+
if (this.projectStore.projectTypeTraits.isLVGL) {
1296+
this.lvglBuild.lvglObjectIdentifiers.fromPage.identifiers.forEach(
1297+
(identifier, widgetIndex) =>
1298+
(this.map.lvglWidgetIndexes[identifier] = widgetIndex)
1299+
);
1300+
}
12861301
}
12871302

12881303
get displayWidth() {
@@ -1515,6 +1530,10 @@ export async function buildAssets(
15151530

15161531
const assets = new Assets(project, buildConfiguration, option);
15171532

1533+
if (project.projectTypeTraits.isLVGL) {
1534+
await assets.lvglBuild.firstPassFinish();
1535+
}
1536+
15181537
if (!project.projectTypeTraits.isLVGL) {
15191538
assets.reportUnusedAssets();
15201539
}
@@ -1666,144 +1685,143 @@ export async function buildAssets(
16661685
if (buildAssetsData) {
16671686
result.GUI_ASSETS_DATA = compressedData;
16681687
}
1669-
1670-
if (buildAssetsDataMap) {
1671-
assets.finalizeMap();
1672-
1673-
result.GUI_ASSETS_DATA_MAP = JSON.stringify(
1674-
assets.map,
1675-
undefined,
1676-
2
1677-
);
1678-
1679-
result.GUI_ASSETS_DATA_MAP_JS = assets.map;
1680-
}
16811688
}
16821689

16831690
if (option != "buildAssets") {
16841691
if (assets.projectStore.projectTypeTraits.isLVGL) {
1685-
const lvglBuild = new LVGLBuild(assets);
1686-
1687-
// PASS 1 (find out which LVGL objects are accessible through global objects structure)
1688-
await lvglBuild.buildScreensDef();
1689-
1690-
// PASS 2
16911692
if (!sectionNames || sectionNames.indexOf("LVGL_INCLUDE") !== -1) {
16921693
result.LVGL_INCLUDE = `#include <${assets.projectStore.project.settings.build.lvglInclude}>`;
16931694
}
16941695

16951696
if (
16961697
!sectionNames ||
1697-
sectionNames.indexOf("LVGL_SCREENS_DECL") !== -1
1698+
sectionNames.indexOf("LVGL_STYLES_DECL") !== -1
16981699
) {
1699-
result.LVGL_SCREENS_DECL = await lvglBuild.buildScreensDecl();
1700+
result.LVGL_STYLES_DECL =
1701+
await assets.lvglBuild.buildStylesDef();
17001702
}
17011703

17021704
if (
17031705
!sectionNames ||
1704-
sectionNames.indexOf("LVGL_SCREENS_DEF") !== -1
1706+
sectionNames.indexOf("LVGL_STYLES_DEF") !== -1
17051707
) {
1706-
result.LVGL_SCREENS_DEF = await lvglBuild.buildScreensDef();
1708+
result.LVGL_STYLES_DEF =
1709+
await assets.lvglBuild.buildStylesDecl();
17071710
}
17081711

17091712
if (
17101713
!sectionNames ||
1711-
sectionNames.indexOf("LVGL_SCREENS_DECL_EXT") !== -1
1714+
sectionNames.indexOf("LVGL_SCREENS_DEF") !== -1
17121715
) {
1713-
result.LVGL_SCREENS_DECL_EXT =
1714-
await lvglBuild.buildScreensDeclExt();
1716+
result.LVGL_SCREENS_DEF =
1717+
await assets.lvglBuild.buildScreensDef();
17151718
}
17161719

17171720
if (
17181721
!sectionNames ||
17191722
sectionNames.indexOf("LVGL_SCREENS_DEF_EXT") !== -1
17201723
) {
17211724
result.LVGL_SCREENS_DEF_EXT =
1722-
await lvglBuild.buildScreensDefExt();
1725+
await assets.lvglBuild.buildScreensDefExt();
17231726
}
17241727

17251728
if (
17261729
!sectionNames ||
1727-
sectionNames.indexOf("LVGL_IMAGES_DECL") !== -1
1730+
sectionNames.indexOf("LVGL_SCREENS_DECL") !== -1
17281731
) {
1729-
result.LVGL_IMAGES_DECL = await lvglBuild.buildImagesDecl();
1732+
result.LVGL_SCREENS_DECL =
1733+
await assets.lvglBuild.buildScreensDecl();
17301734
}
17311735

17321736
if (
17331737
!sectionNames ||
1734-
sectionNames.indexOf("LVGL_IMAGES_DEF") !== -1
1738+
sectionNames.indexOf("LVGL_SCREENS_DECL_EXT") !== -1
17351739
) {
1736-
result.LVGL_IMAGES_DEF = await lvglBuild.buildImagesDef();
1740+
result.LVGL_SCREENS_DECL_EXT =
1741+
await assets.lvglBuild.buildScreensDeclExt();
17371742
}
17381743

17391744
if (
17401745
!sectionNames ||
1741-
sectionNames.indexOf("LVGL_FONTS_DECL") !== -1
1746+
sectionNames.indexOf("LVGL_IMAGES_DECL") !== -1
17421747
) {
1743-
result.LVGL_FONTS_DECL = await lvglBuild.buildFontsDecl();
1748+
result.LVGL_IMAGES_DECL =
1749+
await assets.lvglBuild.buildImagesDecl();
17441750
}
17451751

17461752
if (
17471753
!sectionNames ||
1748-
sectionNames.indexOf("LVGL_ACTIONS_DECL") !== -1
1754+
sectionNames.indexOf("LVGL_IMAGES_DEF") !== -1
17491755
) {
1750-
result.LVGL_ACTIONS_DECL = await lvglBuild.buildActionsDecl();
1756+
result.LVGL_IMAGES_DEF =
1757+
await assets.lvglBuild.buildImagesDef();
17511758
}
17521759

17531760
if (
17541761
!sectionNames ||
1755-
sectionNames.indexOf("LVGL_ACTIONS_ARRAY_DEF") !== -1
1762+
sectionNames.indexOf("LVGL_FONTS_DECL") !== -1
17561763
) {
1757-
result.LVGL_ACTIONS_ARRAY_DEF =
1758-
await lvglBuild.buildActionsArrayDef();
1764+
result.LVGL_FONTS_DECL =
1765+
await assets.lvglBuild.buildFontsDecl();
17591766
}
17601767

17611768
if (
17621769
!sectionNames ||
1763-
sectionNames.indexOf("LVGL_VARS_DECL") !== -1
1770+
sectionNames.indexOf("LVGL_ACTIONS_DECL") !== -1
17641771
) {
1765-
result.LVGL_VARS_DECL = await lvglBuild.buildVariablesDecl();
1772+
result.LVGL_ACTIONS_DECL =
1773+
await assets.lvglBuild.buildActionsDecl();
17661774
}
17671775

17681776
if (
17691777
!sectionNames ||
1770-
sectionNames.indexOf("LVGL_NATIVE_VARS_TABLE_DEF") !== -1
1778+
sectionNames.indexOf("LVGL_ACTIONS_ARRAY_DEF") !== -1
17711779
) {
1772-
result.LVGL_NATIVE_VARS_TABLE_DEF =
1773-
await lvglBuild.buildNativeVarsTableDef();
1780+
result.LVGL_ACTIONS_ARRAY_DEF =
1781+
await assets.lvglBuild.buildActionsArrayDef();
17741782
}
17751783

17761784
if (
17771785
!sectionNames ||
1778-
sectionNames.indexOf("LVGL_STYLES_DECL") !== -1
1786+
sectionNames.indexOf("LVGL_VARS_DECL") !== -1
17791787
) {
1780-
result.LVGL_STYLES_DECL = await lvglBuild.buildStylesDef();
1788+
result.LVGL_VARS_DECL =
1789+
await assets.lvglBuild.buildVariablesDecl();
17811790
}
17821791

17831792
if (
17841793
!sectionNames ||
1785-
sectionNames.indexOf("LVGL_STYLES_DEF") !== -1
1794+
sectionNames.indexOf("LVGL_NATIVE_VARS_TABLE_DEF") !== -1
17861795
) {
1787-
result.LVGL_STYLES_DEF = await lvglBuild.buildStylesDecl();
1796+
result.LVGL_NATIVE_VARS_TABLE_DEF =
1797+
await assets.lvglBuild.buildNativeVarsTableDef();
17881798
}
17891799

17901800
if (
17911801
!sectionNames ||
17921802
sectionNames.indexOf("EEZ_FOR_LVGL_CHECK") !== -1
17931803
) {
17941804
result.EEZ_FOR_LVGL_CHECK =
1795-
await lvglBuild.buildEezForLvglCheck();
1805+
await assets.lvglBuild.buildEezForLvglCheck();
17961806
}
17971807

17981808
if (option == "buildFiles") {
1799-
await lvglBuild.copyBitmapFiles();
1800-
await lvglBuild.copyFontFiles();
1809+
await assets.lvglBuild.copyBitmapFiles();
1810+
await assets.lvglBuild.copyFontFiles();
18011811
}
18021812
}
18031813

18041814
assets.reportUnusedAssets();
18051815
}
18061816

1817+
if (buildAssetsDataMap) {
1818+
assets.finalizeMap();
1819+
1820+
result.GUI_ASSETS_DATA_MAP = JSON.stringify(assets.map, undefined, 2);
1821+
1822+
result.GUI_ASSETS_DATA_MAP_JS = assets.map;
1823+
}
1824+
18071825
if (option == "buildAssets") {
18081826
return result;
18091827
}

packages/project-editor/core/object.ts

+1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export interface PropertyInfo {
183183
referencedObject: IEezObject
184184
) => boolean;
185185
computed?: boolean;
186+
computedIfNotLoadProject?: boolean;
186187
modifiable?: boolean;
187188
onSelect?: (
188189
object: IEezObject,

packages/project-editor/features/bitmap/bitmap.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ export class Bitmap extends EezObject {
385385
return getThemedColor(
386386
getProjectStore(this),
387387
style.backgroundColorProperty
388-
);
388+
).colorValue;
389389
}
390390
}
391391
return "transparent";

0 commit comments

Comments
 (0)