Skip to content

Commit 269d34b

Browse files
committed
1 parent 0b7c28d commit 269d34b

28 files changed

+3411
-218
lines changed

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

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

367+
getLvglScreenByName?: {
368+
name: string;
369+
};
370+
371+
getLvglObjectByName?: {
372+
name: string;
373+
};
374+
375+
getLvglGroupByName?: {
376+
name: string;
377+
};
378+
379+
getLvglStyleByName?: {
380+
name: string;
381+
};
382+
367383
getLvglImageByName?: {
368384
name: string;
369385
};

packages/project-editor/core/object.ts

+14
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,18 @@ export type FlowPropertyType =
150150
| "template-literal"
151151
| "scpi-template-literal";
152152

153+
export type LvglActionPropertyType =
154+
| "boolean"
155+
| "integer"
156+
| "string"
157+
| `enum:${string}`
158+
| "screen"
159+
| "widget"
160+
| `widget:${string}`
161+
| "group"
162+
| "style"
163+
| "image";
164+
153165
export interface PropertyInfo {
154166
name: string;
155167
type: PropertyType;
@@ -286,6 +298,8 @@ export interface PropertyInfo {
286298
) => React.ReactNode[];
287299

288300
colorEditorForLiteral?: boolean;
301+
302+
lvglActionPropertyType?: LvglActionPropertyType;
289303
}
290304

291305
export type InheritedValue =

packages/project-editor/features/variable/value-type.tsx

+56-23
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
PropertyInfo,
2828
PropertyProps
2929
} from "project-editor/core/object";
30-
import type { Project, ProjectType } from "project-editor/project/project";
30+
import { Project, ProjectType } from "project-editor/project/project";
3131
import { ProjectContext } from "project-editor/project/context";
3232
import { getPropertyValue } from "project-editor/ui-components/PropertyGrid/utils";
3333
import type {
@@ -305,17 +305,46 @@ export function registerSystemStructure(
305305
////////////////////////////////////////////////////////////////////////////////
306306

307307
class SystemEnum implements IEnum {
308-
name: string;
309-
members: IEnumMember[];
310-
projectTypes: ProjectType[] | undefined;
308+
static SYSTEM_ENUMS: SystemEnum[] = [];
309+
310+
static getSystemEnums(projectStore: ProjectStore) {
311+
return this.SYSTEM_ENUMS.filter(systemEnum => {
312+
if (systemEnum.projectTypes == undefined) {
313+
return true;
314+
}
315+
316+
if (
317+
systemEnum.projectTypes.indexOf(
318+
projectStore.project.settings.general.projectType
319+
) != -1
320+
) {
321+
if (
322+
projectStore.project.settings.general.projectType ==
323+
ProjectType.LVGL
324+
) {
325+
if (systemEnum.lvglVersion == undefined) {
326+
return true;
327+
}
328+
329+
if (
330+
systemEnum.lvglVersion ==
331+
projectStore.project.settings.general.lvglVersion
332+
) {
333+
return true;
334+
}
335+
}
336+
}
337+
338+
return false;
339+
});
340+
}
311341

312342
constructor(
313-
enumDef: Omit<IEnum, "membersMap"> & {
314-
projectTypes: ProjectType[] | undefined;
315-
}
343+
public name: string,
344+
public members: IEnumMember[],
345+
private projectTypes: ProjectType[] | undefined,
346+
private lvglVersion?: "8.3" | "9.0"
316347
) {
317-
Object.assign(this, enumDef);
318-
319348
makeObservable(this, {
320349
membersMap: computed
321350
});
@@ -330,14 +359,24 @@ class SystemEnum implements IEnum {
330359
}
331360
}
332361

333-
export const SYSTEM_ENUMS: SystemEnum[] = [];
362+
export function registerSystemEnum({
363+
name,
364+
members,
365+
projectTypes,
366+
lvglVersion
367+
}: {
368+
name: string;
369+
members: IEnumMember[];
370+
projectTypes: ProjectType[] | undefined;
371+
lvglVersion?: "8.3" | "9.0";
372+
}) {
373+
SystemEnum.SYSTEM_ENUMS.push(
374+
new SystemEnum(name, members, projectTypes, lvglVersion)
375+
);
376+
}
334377

335-
export function registerSystemEnum(
336-
systemEnum: Omit<IEnum, "membersMap"> & {
337-
projectTypes: ProjectType[] | undefined;
338-
}
339-
) {
340-
SYSTEM_ENUMS.push(new SystemEnum(systemEnum));
378+
export function getSystemEnums(projectStore: ProjectStore) {
379+
return SystemEnum.getSystemEnums(projectStore);
341380
}
342381

343382
////////////////////////////////////////////////////////////////////////////////
@@ -600,13 +639,7 @@ export const VariableTypeSelect = observer(
600639

601640
const enumTypes = [
602641
...project.variables.enums,
603-
...SYSTEM_ENUMS.filter(
604-
enumDef =>
605-
enumDef.projectTypes == undefined ||
606-
enumDef.projectTypes.indexOf(
607-
this.props.project.settings.general.projectType
608-
) != -1
609-
)
642+
...getSystemEnums(this.props.project._store)
610643
];
611644

612645
const enums = enumTypes.map(enumDef => (

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

+3-9
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import {
6161
getObjectVariableTypeFromType,
6262
SYSTEM_STRUCTURES,
6363
isValidType,
64-
SYSTEM_ENUMS
64+
getSystemEnums
6565
} from "project-editor/features/variable/value-type";
6666
import {
6767
FLOW_ITERATOR_INDEXES_VARIABLE,
@@ -1315,14 +1315,8 @@ export class ProjectVariables extends EezObject {
13151315
map.set(enumDef.name, enumDef);
13161316
}
13171317

1318-
const project = ProjectEditor.getProject(this);
1319-
const systemEnums = SYSTEM_ENUMS.filter(
1320-
enumDef =>
1321-
enumDef.projectTypes == undefined ||
1322-
enumDef.projectTypes.indexOf(
1323-
project.settings.general.projectType
1324-
) != -1
1325-
);
1318+
const projectStore = ProjectEditor.getProjectStore(this);
1319+
const systemEnums = getSystemEnums(projectStore);
13261320
for (const enumDef of systemEnums) {
13271321
map.set(enumDef.name, enumDef);
13281322
}

packages/project-editor/flow/component.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4678,7 +4678,7 @@ function isActionComponent(component: Component) {
46784678
return component instanceof ActionComponent;
46794679
}
46804680

4681-
function checkProperty(
4681+
export function checkProperty(
46824682
projectStore: ProjectStore,
46834683
component: Component,
46844684
messages: IMessage[],

packages/project-editor/flow/components/component-types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export const COMPONENT_TYPE_MQTT_UNSUBSCRIBE = 1040;
7272
export const COMPONENT_TYPE_MQTT_PUBLISH = 1041;
7373
export const COMPONENT_TYPE_LABEL_IN_ACTION = 1042;
7474
export const COMPONENT_TYPE_LABEL_OUT_ACTION = 1043;
75+
export const COMPONENT_TYPE_LVGL_ACTION_API = 1044;
7576

7677
export const FIRST_DASHBOARD_ACTION_COMPONENT_TYPE = 10000;
7778
export const FIRST_DASHBOARD_WIDGET_COMPONENT_TYPE = 20000;

packages/project-editor/flow/expression/ExpressionBuilder.tsx

+2-9
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import {
4444
isStructType,
4545
isObjectType,
4646
getObjectVariableTypeFromType,
47-
SYSTEM_ENUMS
47+
getSystemEnums
4848
} from "project-editor/features/variable/value-type";
4949
import { ProjectEditor } from "project-editor/project-editor-interface";
5050
import {
@@ -815,14 +815,7 @@ const SelectItemDialog = observer(
815815

816816
const enumTypes = [
817817
...this.context.project.variables.enums,
818-
...SYSTEM_ENUMS.filter(
819-
enumDef =>
820-
enumDef.projectTypes == undefined ||
821-
enumDef.projectTypes.indexOf(
822-
this.context.project.settings.general
823-
.projectType
824-
) != -1
825-
)
818+
...getSystemEnums(this.context)
826819
];
827820

828821
if (enumTypes.length) {

packages/project-editor/flow/expression/operations.tsx

+16-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,8 @@ export const builtInFunctions: {
599599
: undefined,
600600
getValueType: (...args: ValueType[]) => {
601601
return "blob";
602-
}
602+
},
603+
enabled: projectStore => !projectStore.projectTypeTraits.isLVGL
603604
},
604605

605606
"Flow.getBitmapAsDataURL": {
@@ -1429,6 +1430,20 @@ export const builtInFunctions: {
14291430
return "integer";
14301431
},
14311432
enabled: projectStore => projectStore.projectTypeTraits.isLVGL
1433+
},
1434+
1435+
"LVGL.getScreenByName": {
1436+
operationIndex: 89,
1437+
arity: 0,
1438+
args: ["string"],
1439+
eval: (
1440+
expressionContext: IExpressionContext | undefined,
1441+
...args: any[]
1442+
) => 0,
1443+
getValueType: (...args: ValueType[]) => {
1444+
return "integer";
1445+
},
1446+
enabled: projectStore => projectStore.projectTypeTraits.isLVGL
14321447
}
14331448
};
14341449

packages/project-editor/flow/runtime/cpp/lvgl-runtime/common/src/flow.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,30 @@ static lv_group_t *getLvglGroupFromIndex(int32_t index) {
990990

991991
////////////////////////////////////////////////////////////////////////////////
992992

993+
static int32_t getLvglScreenByName(const char *name) {
994+
return (int32_t)EM_ASM_INT({
995+
return getLvglScreenByName($0, UTF8ToString($1));
996+
}, eez::flow::g_wasmModuleId, name);
997+
}
998+
999+
static int32_t getLvglObjectByName(const char *name) {
1000+
return (int32_t)EM_ASM_INT({
1001+
return getLvglObjectByName($0, UTF8ToString($1));
1002+
}, eez::flow::g_wasmModuleId, name);
1003+
}
1004+
1005+
static int32_t getLvglGroupByName(const char *name) {
1006+
return (int32_t)EM_ASM_INT({
1007+
return getLvglGroupByName($0, UTF8ToString($1));
1008+
}, eez::flow::g_wasmModuleId, name);
1009+
}
1010+
1011+
static int32_t getLvglStyleByName(const char *name) {
1012+
return (int32_t)EM_ASM_INT({
1013+
return getLvglStyleByName($0, UTF8ToString($1));
1014+
}, eez::flow::g_wasmModuleId, name);
1015+
}
1016+
9931017
static const void *getLvglImageByName(const char *name) {
9941018
return (const void *)EM_ASM_INT({
9951019
return getLvglImageByName($0, UTF8ToString($1));
@@ -1033,6 +1057,10 @@ extern "C" void flowInit(uint32_t wasmModuleId, uint32_t debuggerMessageSubscipt
10331057
eez::flow::replacePageHook = replacePageHook;
10341058
eez::flow::stopScriptHook = stopScript;
10351059
eez::flow::getLvglObjectFromIndexHook = getLvglObjectFromIndex;
1060+
eez::flow::getLvglScreenByNameHook = getLvglScreenByName;
1061+
eez::flow::getLvglObjectByNameHook = getLvglObjectByName;
1062+
eez::flow::getLvglGroupByNameHook = getLvglGroupByName;
1063+
eez::flow::getLvglStyleByNameHook = getLvglStyleByName;
10361064
eez::flow::getLvglImageByNameHook = getLvglImageByName;
10371065
eez::flow::lvglObjAddStyleHook = lvglObjAddStyle;
10381066
eez::flow::lvglObjRemoveStyleHook = lvglObjRemoveStyle;

packages/project-editor/flow/runtime/lvgl_runtime_v8.3.js

+18-14
Original file line numberDiff line numberDiff line change
@@ -969,20 +969,24 @@ function dbg(text) {
969969
// === Body ===
970970

971971
var ASM_CONSTS = {
972-
1036456: ($0) => { startToDebuggerMessage($0); },
973-
1036488: ($0, $1, $2) => { writeDebuggerBuffer($0, new Uint8Array(Module.HEAPU8.buffer, $1, $2)); },
974-
1036563: ($0, $1, $2) => { writeDebuggerBuffer($0, new Uint8Array(Module.HEAPU8.buffer, $1, $2)); },
975-
1036638: ($0) => { finishToDebuggerMessage($0); },
976-
1036671: ($0, $1) => { return getLvglImageByName($0, UTF8ToString($1)); },
977-
1036724: ($0, $1, $2) => { lvglObjAddStyle($0, $1, $2); },
978-
1036757: ($0, $1, $2) => { lvglObjRemoveStyle($0, $1, $2); },
979-
1036793: ($0, $1, $2, $3, $4, $5) => { return eez_mqtt_init($0, UTF8ToString($1), UTF8ToString($2), $3, UTF8ToString($4), UTF8ToString($5)); },
980-
1036899: ($0, $1) => { return eez_mqtt_deinit($0, $1); },
981-
1036935: ($0, $1) => { return eez_mqtt_connect($0, $1); },
982-
1036972: ($0, $1) => { return eez_mqtt_disconnect($0, $1); },
983-
1037012: ($0, $1, $2) => { return eez_mqtt_subscribe($0, $1, UTF8ToString($2)); },
984-
1037069: ($0, $1, $2) => { return eez_mqtt_unsubscribe($0, $1, UTF8ToString($2)); },
985-
1037128: ($0, $1, $2, $3) => { return eez_mqtt_publish($0, $1, UTF8ToString($2), UTF8ToString($3)); }
972+
1038920: ($0) => { startToDebuggerMessage($0); },
973+
1038952: ($0, $1, $2) => { writeDebuggerBuffer($0, new Uint8Array(Module.HEAPU8.buffer, $1, $2)); },
974+
1039027: ($0, $1, $2) => { writeDebuggerBuffer($0, new Uint8Array(Module.HEAPU8.buffer, $1, $2)); },
975+
1039102: ($0) => { finishToDebuggerMessage($0); },
976+
1039135: ($0, $1) => { return getLvglScreenByName($0, UTF8ToString($1)); },
977+
1039189: ($0, $1) => { return getLvglObjectByName($0, UTF8ToString($1)); },
978+
1039243: ($0, $1) => { return getLvglGroupByName($0, UTF8ToString($1)); },
979+
1039296: ($0, $1) => { return getLvglStyleByName($0, UTF8ToString($1)); },
980+
1039349: ($0, $1) => { return getLvglImageByName($0, UTF8ToString($1)); },
981+
1039402: ($0, $1, $2) => { lvglObjAddStyle($0, $1, $2); },
982+
1039435: ($0, $1, $2) => { lvglObjRemoveStyle($0, $1, $2); },
983+
1039471: ($0, $1, $2, $3, $4, $5) => { return eez_mqtt_init($0, UTF8ToString($1), UTF8ToString($2), $3, UTF8ToString($4), UTF8ToString($5)); },
984+
1039577: ($0, $1) => { return eez_mqtt_deinit($0, $1); },
985+
1039613: ($0, $1) => { return eez_mqtt_connect($0, $1); },
986+
1039650: ($0, $1) => { return eez_mqtt_disconnect($0, $1); },
987+
1039690: ($0, $1, $2) => { return eez_mqtt_subscribe($0, $1, UTF8ToString($2)); },
988+
1039747: ($0, $1, $2) => { return eez_mqtt_unsubscribe($0, $1, UTF8ToString($2)); },
989+
1039806: ($0, $1, $2, $3) => { return eez_mqtt_publish($0, $1, UTF8ToString($2), UTF8ToString($3)); }
986990
};
987991

988992

Binary file not shown.

packages/project-editor/flow/runtime/lvgl_runtime_v9.0.js

+18-14
Original file line numberDiff line numberDiff line change
@@ -969,20 +969,24 @@ function dbg(text) {
969969
// === Body ===
970970

971971
var ASM_CONSTS = {
972-
1031320: ($0) => { startToDebuggerMessage($0); },
973-
1031352: ($0, $1, $2) => { writeDebuggerBuffer($0, new Uint8Array(Module.HEAPU8.buffer, $1, $2)); },
974-
1031427: ($0, $1, $2) => { writeDebuggerBuffer($0, new Uint8Array(Module.HEAPU8.buffer, $1, $2)); },
975-
1031502: ($0) => { finishToDebuggerMessage($0); },
976-
1031535: ($0, $1) => { return getLvglImageByName($0, UTF8ToString($1)); },
977-
1031588: ($0, $1, $2) => { lvglObjAddStyle($0, $1, $2); },
978-
1031621: ($0, $1, $2) => { lvglObjRemoveStyle($0, $1, $2); },
979-
1031657: ($0, $1, $2, $3, $4, $5) => { return eez_mqtt_init($0, UTF8ToString($1), UTF8ToString($2), $3, UTF8ToString($4), UTF8ToString($5)); },
980-
1031763: ($0, $1) => { return eez_mqtt_deinit($0, $1); },
981-
1031799: ($0, $1) => { return eez_mqtt_connect($0, $1); },
982-
1031836: ($0, $1) => { return eez_mqtt_disconnect($0, $1); },
983-
1031876: ($0, $1, $2) => { return eez_mqtt_subscribe($0, $1, UTF8ToString($2)); },
984-
1031933: ($0, $1, $2) => { return eez_mqtt_unsubscribe($0, $1, UTF8ToString($2)); },
985-
1031992: ($0, $1, $2, $3) => { return eez_mqtt_publish($0, $1, UTF8ToString($2), UTF8ToString($3)); }
972+
1033784: ($0) => { startToDebuggerMessage($0); },
973+
1033816: ($0, $1, $2) => { writeDebuggerBuffer($0, new Uint8Array(Module.HEAPU8.buffer, $1, $2)); },
974+
1033891: ($0, $1, $2) => { writeDebuggerBuffer($0, new Uint8Array(Module.HEAPU8.buffer, $1, $2)); },
975+
1033966: ($0) => { finishToDebuggerMessage($0); },
976+
1033999: ($0, $1) => { return getLvglScreenByName($0, UTF8ToString($1)); },
977+
1034053: ($0, $1) => { return getLvglObjectByName($0, UTF8ToString($1)); },
978+
1034107: ($0, $1) => { return getLvglGroupByName($0, UTF8ToString($1)); },
979+
1034160: ($0, $1) => { return getLvglStyleByName($0, UTF8ToString($1)); },
980+
1034213: ($0, $1) => { return getLvglImageByName($0, UTF8ToString($1)); },
981+
1034266: ($0, $1, $2) => { lvglObjAddStyle($0, $1, $2); },
982+
1034299: ($0, $1, $2) => { lvglObjRemoveStyle($0, $1, $2); },
983+
1034335: ($0, $1, $2, $3, $4, $5) => { return eez_mqtt_init($0, UTF8ToString($1), UTF8ToString($2), $3, UTF8ToString($4), UTF8ToString($5)); },
984+
1034441: ($0, $1) => { return eez_mqtt_deinit($0, $1); },
985+
1034477: ($0, $1) => { return eez_mqtt_connect($0, $1); },
986+
1034514: ($0, $1) => { return eez_mqtt_disconnect($0, $1); },
987+
1034554: ($0, $1, $2) => { return eez_mqtt_subscribe($0, $1, UTF8ToString($2)); },
988+
1034611: ($0, $1, $2) => { return eez_mqtt_unsubscribe($0, $1, UTF8ToString($2)); },
989+
1034670: ($0, $1, $2, $3) => { return eez_mqtt_publish($0, $1, UTF8ToString($2), UTF8ToString($3)); }
986990
};
987991

988992

Binary file not shown.

0 commit comments

Comments
 (0)