Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Jan 29, 2025
1 parent a794695 commit ef6a4dc
Show file tree
Hide file tree
Showing 15 changed files with 158 additions and 117 deletions.
4 changes: 2 additions & 2 deletions packages/project-editor/flow/editor/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ const CenterLines = observer(
const transform = flowContext.viewState.transform;

const CENTER_LINES_COLOR = settingsController.isDarkTheme
? "#444"
: "#eee";
? "#666"
: "#ddd";
const CENTER_LINES_WIDTH = 1 / transform.scale;

const centerLineStyle = {
Expand Down
Binary file modified packages/project-editor/flow/runtime/lvgl_runtime_v8.3.wasm
Binary file not shown.
40 changes: 20 additions & 20 deletions packages/project-editor/flow/runtime/lvgl_runtime_v9.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -969,25 +969,25 @@ function dbg(text) {
// === Body ===

var ASM_CONSTS = {
1029552: ($0) => { startToDebuggerMessage($0); },
1029584: ($0, $1, $2) => { writeDebuggerBuffer($0, new Uint8Array(Module.HEAPU8.buffer, $1, $2)); },
1029659: ($0, $1, $2) => { writeDebuggerBuffer($0, new Uint8Array(Module.HEAPU8.buffer, $1, $2)); },
1029734: ($0) => { finishToDebuggerMessage($0); },
1029767: ($0, $1) => { return getLvglScreenByName($0, UTF8ToString($1)); },
1029821: ($0, $1) => { return getLvglObjectByName($0, UTF8ToString($1)); },
1029875: ($0, $1) => { return getLvglGroupByName($0, UTF8ToString($1)); },
1029928: ($0, $1) => { return getLvglStyleByName($0, UTF8ToString($1)); },
1029981: ($0, $1) => { return getLvglImageByName($0, UTF8ToString($1)); },
1030034: ($0, $1, $2) => { lvglObjAddStyle($0, $1, $2); },
1030067: ($0, $1, $2) => { lvglObjRemoveStyle($0, $1, $2); },
1030103: ($0, $1) => { lvglSetColorTheme($0, UTF8ToString($1)); },
1030148: ($0, $1, $2, $3, $4, $5) => { return eez_mqtt_init($0, UTF8ToString($1), UTF8ToString($2), $3, UTF8ToString($4), UTF8ToString($5)); },
1030254: ($0, $1) => { return eez_mqtt_deinit($0, $1); },
1030290: ($0, $1) => { return eez_mqtt_connect($0, $1); },
1030327: ($0, $1) => { return eez_mqtt_disconnect($0, $1); },
1030367: ($0, $1, $2) => { return eez_mqtt_subscribe($0, $1, UTF8ToString($2)); },
1030424: ($0, $1, $2) => { return eez_mqtt_unsubscribe($0, $1, UTF8ToString($2)); },
1030483: ($0, $1, $2, $3) => { return eez_mqtt_publish($0, $1, UTF8ToString($2), UTF8ToString($3)); }
1031824: ($0) => { startToDebuggerMessage($0); },
1031856: ($0, $1, $2) => { writeDebuggerBuffer($0, new Uint8Array(Module.HEAPU8.buffer, $1, $2)); },
1031931: ($0, $1, $2) => { writeDebuggerBuffer($0, new Uint8Array(Module.HEAPU8.buffer, $1, $2)); },
1032006: ($0) => { finishToDebuggerMessage($0); },
1032039: ($0, $1) => { return getLvglScreenByName($0, UTF8ToString($1)); },
1032093: ($0, $1) => { return getLvglObjectByName($0, UTF8ToString($1)); },
1032147: ($0, $1) => { return getLvglGroupByName($0, UTF8ToString($1)); },
1032200: ($0, $1) => { return getLvglStyleByName($0, UTF8ToString($1)); },
1032253: ($0, $1) => { return getLvglImageByName($0, UTF8ToString($1)); },
1032306: ($0, $1, $2) => { lvglObjAddStyle($0, $1, $2); },
1032339: ($0, $1, $2) => { lvglObjRemoveStyle($0, $1, $2); },
1032375: ($0, $1) => { lvglSetColorTheme($0, UTF8ToString($1)); },
1032420: ($0, $1, $2, $3, $4, $5) => { return eez_mqtt_init($0, UTF8ToString($1), UTF8ToString($2), $3, UTF8ToString($4), UTF8ToString($5)); },
1032526: ($0, $1) => { return eez_mqtt_deinit($0, $1); },
1032562: ($0, $1) => { return eez_mqtt_connect($0, $1); },
1032599: ($0, $1) => { return eez_mqtt_disconnect($0, $1); },
1032639: ($0, $1, $2) => { return eez_mqtt_subscribe($0, $1, UTF8ToString($2)); },
1032696: ($0, $1, $2) => { return eez_mqtt_unsubscribe($0, $1, UTF8ToString($2)); },
1032755: ($0, $1, $2, $3) => { return eez_mqtt_publish($0, $1, UTF8ToString($2), UTF8ToString($3)); }
};


Expand Down Expand Up @@ -4854,9 +4854,9 @@ var _lvglScrollTo = Module['_lvglScrollTo'] = createExportWrapper('lvglScrollTo'
var _lvglGetScrollX = Module['_lvglGetScrollX'] = createExportWrapper('lvglGetScrollX');
var _lvglGetScrollY = Module['_lvglGetScrollY'] = createExportWrapper('lvglGetScrollY');
var _lvglObjInvalidate = Module['_lvglObjInvalidate'] = createExportWrapper('lvglObjInvalidate');
var _fflush = Module['_fflush'] = createExportWrapper('fflush');
var _onMqttEvent = Module['_onMqttEvent'] = createExportWrapper('onMqttEvent');
var ___errno_location = createExportWrapper('__errno_location');
var _fflush = Module['_fflush'] = createExportWrapper('fflush');
var _emscripten_stack_init = () => (_emscripten_stack_init = wasmExports['emscripten_stack_init'])();
var _emscripten_stack_get_free = () => (_emscripten_stack_get_free = wasmExports['emscripten_stack_get_free'])();
var _emscripten_stack_get_base = () => (_emscripten_stack_get_base = wasmExports['emscripten_stack_get_base'])();
Expand Down
Binary file modified packages/project-editor/flow/runtime/lvgl_runtime_v9.0.wasm
Binary file not shown.
82 changes: 42 additions & 40 deletions packages/project-editor/lvgl/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,47 +78,49 @@ export const LVGLPage = observer(
}
);

const LVGLPageCanvas = React.forwardRef(
(
props: {
width: number;
height: number;
flowContext: IFlowContext;
},
ref: React.Ref<HTMLCanvasElement>
) => {
const style: React.CSSProperties = {
imageRendering:
props.flowContext.viewState.transform.scale > 2
? "pixelated"
: "auto"
};
const LVGLPageCanvas = observer(
React.forwardRef(
(
props: {
width: number;
height: number;
flowContext: IFlowContext;
},
ref: React.Ref<HTMLCanvasElement>
) => {
const style: React.CSSProperties = {
imageRendering:
props.flowContext.viewState.transform.scale > 2
? "pixelated"
: "auto"
};

if (
props.flowContext.projectStore.project.settings.general
.circularDisplay ||
props.flowContext.projectStore.project.settings.general
.displayBorderRadius != 0
) {
style.borderRadius = props.flowContext.projectStore.project.settings
.general.circularDisplay
? Math.min(props.width, props.height)
: props.flowContext.projectStore.project.settings.general
.displayBorderRadius;
if (
props.flowContext.projectStore.project.settings.general
.circularDisplay ||
props.flowContext.projectStore.project.settings.general
.displayBorderRadius != 0
) {
style.borderRadius = props.flowContext.projectStore.project
.settings.general.circularDisplay
? Math.min(props.width, props.height)
: props.flowContext.projectStore.project.settings.general
.displayBorderRadius;

style.border = `1px solid ${
settingsController.isDarkTheme ? "#444" : "#eee"
}`;
style.transform = "translate(-1px, -1px)";
}
style.border = `1px solid ${
settingsController.isDarkTheme ? "#444" : "#eee"
}`;
style.transform = "translate(-1px, -1px)";
}

return (
<canvas
ref={ref}
width={props.width}
height={props.height}
style={style}
></canvas>
);
}
return (
<canvas
ref={ref}
width={props.width}
height={props.height}
style={style}
></canvas>
);
}
)
);
57 changes: 53 additions & 4 deletions packages/project-editor/lvgl/lvgl-versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,56 @@ import { settingsController } from "home/settings";

////////////////////////////////////////////////////////////////////////////////

const V8_LV_COORD_TYPE_SHIFT = 13;
const V8_LV_COORD_TYPE_SPEC = 1 << V8_LV_COORD_TYPE_SHIFT;
function V8_LV_COORD_SET_SPEC(x: number) {
return x | V8_LV_COORD_TYPE_SPEC;
}

const V8_LV_COORD_MAX = (1 << V8_LV_COORD_TYPE_SHIFT) - 1;

function V8_LV_PCT(x: number) {
return x < 0 ? V8_LV_COORD_SET_SPEC(1000 - x) : V8_LV_COORD_SET_SPEC(x);
}

const V8_LV_SIZE_CONTENT = V8_LV_COORD_SET_SPEC(2001);

////////////////////////////////////////////////////////////////////////////////

const V9_LV_COORD_TYPE_SHIFT = 29;
const V9_LV_COORD_TYPE_SPEC = 1 << V9_LV_COORD_TYPE_SHIFT;

function V9_LV_COORD_SET_SPEC(x: number) {
return x | V9_LV_COORD_TYPE_SPEC;
}

const V9_LV_COORD_MAX = (1 << V9_LV_COORD_TYPE_SHIFT) - 1;

const V9_LV_PCT_STORED_MAX = V9_LV_COORD_MAX - 1;

const V9_LV_PCT_POS_MAX = V9_LV_PCT_STORED_MAX / 2;

function V9_LV_PCT(x: number) {
return V9_LV_COORD_SET_SPEC(
x < 0
? V9_LV_PCT_POS_MAX - Math.max(x, -V9_LV_PCT_POS_MAX)
: Math.min(x, V9_LV_PCT_POS_MAX)
);
}

const V9_LV_SIZE_CONTENT = V9_LV_COORD_SET_SPEC(V9_LV_COORD_MAX);

////////////////////////////////////////////////////////////////////////////////

const versions = {
"8.3": {
wasmFlowRuntime: "project-editor/flow/runtime/lvgl_runtime_v8.3.js",

_LV_COORD_TYPE_SHIFT: 13,
LV_COORD: {
LV_COORD_MAX: V8_LV_COORD_MAX,
LV_SIZE_CONTENT: V8_LV_SIZE_CONTENT,
LV_PCT: V8_LV_PCT
},

bitmapColorFormats: [
{ id: CF_ALPHA_1_BIT, label: "ALPHA 1 BIT" },
Expand Down Expand Up @@ -197,7 +242,11 @@ const versions = {
"9.0": {
wasmFlowRuntime: "project-editor/flow/runtime/lvgl_runtime_v9.0.js",

_LV_COORD_TYPE_SHIFT: 29,
LV_COORD: {
LV_COORD_MAX: V9_LV_COORD_MAX,
LV_SIZE_CONTENT: V9_LV_SIZE_CONTENT,
LV_PCT: V9_LV_PCT
},

bitmapColorFormats: [
{ id: CF_L8, label: "L8" },
Expand Down Expand Up @@ -488,8 +537,8 @@ export function getLvglStylePropCode(
return code[ProjectEditor.getProject(object).settings.general.lvglVersion];
}

export function getLvglCoordTypeShift(object: IEezObject) {
return getVersionProperty(object, "_LV_COORD_TYPE_SHIFT");
export function getLvglCoord(object: IEezObject) {
return getVersionProperty(object, "LV_COORD");
}

export function getLvglBitmapPtr(
Expand Down
7 changes: 2 additions & 5 deletions packages/project-editor/lvgl/style-definition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
getSelectorBuildCode,
getSelectorCode
} from "project-editor/lvgl/style-helper";
import { getLvglCoordTypeShift } from "./lvgl-versions";
import { getLvglCoord } from "./lvgl-versions";
import { getThemedColor } from "project-editor/features/style/theme";
import { isValid } from "eez-studio-shared/color";
import type { LVGLStyle } from "./style";
Expand Down Expand Up @@ -554,10 +554,7 @@ export class LVGLStylesDefinition extends EezObject {
)
: value;

const _LV_COORD_TYPE_SHIFT =
getLvglCoordTypeShift(widget);
const LV_COORD_MAX =
(1 << _LV_COORD_TYPE_SHIFT) - 1;
const { LV_COORD_MAX } = getLvglCoord(widget);
const LV_GRID_TEMPLATE_LAST = LV_COORD_MAX;

arrValue.push(LV_GRID_TEMPLATE_LAST);
Expand Down
7 changes: 2 additions & 5 deletions packages/project-editor/lvgl/style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {
text_font_property_info
} from "project-editor/lvgl/style-catalog";
import type { LVGLWidget } from "project-editor/lvgl/widgets";
import { getLvglCoordTypeShift } from "./lvgl-versions";
import { getLvglCoord } from "./lvgl-versions";

////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -566,10 +566,7 @@ export class LVGLStyle extends EezObject {
)
: value;

const _LV_COORD_TYPE_SHIFT =
getLvglCoordTypeShift(this);
const LV_COORD_MAX =
(1 << _LV_COORD_TYPE_SHIFT) - 1;
const { LV_COORD_MAX } = getLvglCoord(this);
const LV_GRID_TEMPLATE_LAST = LV_COORD_MAX;

arrValue.push(LV_GRID_TEMPLATE_LAST);
Expand Down
14 changes: 2 additions & 12 deletions packages/project-editor/lvgl/widgets/Base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ import { LVGLStyle } from "project-editor/lvgl/style";
import { showGenericDialog } from "eez-studio-ui/generic-dialog";
import { validators } from "eez-studio-shared/validation";
import {
getLvglCoordTypeShift,
getLvglCoord,
getLvglEvents,
getLvglFlagCodes
} from "project-editor/lvgl/lvgl-versions";
Expand Down Expand Up @@ -2264,17 +2264,7 @@ export class LVGLWidget extends Widget {
return page.rect;
}

const _LV_COORD_TYPE_SHIFT = getLvglCoordTypeShift(this);
const _LV_COORD_TYPE_SPEC = 1 << _LV_COORD_TYPE_SHIFT;
function LV_COORD_SET_SPEC(x: number) {
return x | _LV_COORD_TYPE_SPEC;
}

function LV_PCT(x: number) {
return x < 0 ? LV_COORD_SET_SPEC(1000 - x) : LV_COORD_SET_SPEC(x);
}

const LV_SIZE_CONTENT = LV_COORD_SET_SPEC(2001);
const { LV_SIZE_CONTENT, LV_PCT } = getLvglCoord(this);

let left;
if (this.leftUnit == "%") {
Expand Down
27 changes: 7 additions & 20 deletions resources/eez-framework-amalgamation/eez-flow.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Autogenerated on January 26, 2025 5:54:00 PM from eez-framework commit 4d6976602ece58918a4bb20ba0f56bbaaa70949c */
/* Autogenerated on January 29, 2025 3:46:07 PM from eez-framework commit bc909755c9b83d15689e53474f6339176a299ac7 */
/*
* eez-framework
*
Expand Down Expand Up @@ -7538,8 +7538,8 @@ extern "C" void flowPropagateValueUint32(void *flowState, unsigned componentInde
eez::flow::propagateValue((eez::flow::FlowState *)flowState, componentIndex, outputIndex, eez::Value(value, eez::VALUE_TYPE_UINT32));
}
extern "C" void flowPropagateValueLVGLEvent(void *flowState, unsigned componentIndex, unsigned outputIndex, lv_event_t *event) {
lv_event_code_t event_code = lv_event_get_code(event);
if (eez::flow::hasAnyDataConnection((eez::flow::FlowState *)flowState, componentIndex, outputIndex)) {
lv_event_code_t event_code = lv_event_get_code(event);
uint32_t code = (uint32_t)event_code;
void *currentTarget = (void *)lv_event_get_current_target(event);
void *target = (void *)lv_event_get_target(event);
Expand Down Expand Up @@ -7586,9 +7586,11 @@ extern "C" void flowPropagateValueLVGLEvent(void *flowState, unsigned componentI
} else {
eez::flow::propagateValue((eez::flow::FlowState *)flowState, componentIndex, outputIndex);
}
g_currentLVGLEvent = event;
eez::flow::tick();
g_currentLVGLEvent = 0;
if (!lv_disp_get_default()->rendering_in_progress) {
g_currentLVGLEvent = event;
eez::flow::tick();
g_currentLVGLEvent = 0;
}
}
#ifndef EEZ_LVGL_TEMP_STRING_BUFFER_SIZE
#define EEZ_LVGL_TEMP_STRING_BUFFER_SIZE 1024
Expand Down Expand Up @@ -10359,21 +10361,6 @@ void propagateValueThroughSeqout(FlowState *flowState, unsigned componentIndex)
}
}
}
bool hasAnyDataConnection(FlowState *flowState, unsigned componentIndex, unsigned outputIndex) {
if ((int)componentIndex == -1) {
return false;
}
auto component = flowState->flow->components[componentIndex];
auto componentOutput = component->outputs[outputIndex];
for (unsigned connectionIndex = 0; connectionIndex < componentOutput->connections.count; connectionIndex++) {
auto connection = componentOutput->connections[connectionIndex];
auto isDataInput = !(flowState->flow->componentInputs[connection->targetInputIndex] & COMPONENT_INPUT_FLAG_IS_SEQ_INPUT);
if (isDataInput) {
return true;
}
}
return false;
}
#if EEZ_OPTION_GUI
void getValue(uint16_t dataId, DataOperationEnum operation, const WidgetCursor &widgetCursor, Value &value) {
if (!isFlowStopped()) {
Expand Down
3 changes: 1 addition & 2 deletions resources/eez-framework-amalgamation/eez-flow.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Autogenerated on January 26, 2025 5:54:00 PM from eez-framework commit 4d6976602ece58918a4bb20ba0f56bbaaa70949c */
/* Autogenerated on January 29, 2025 3:46:07 PM from eez-framework commit bc909755c9b83d15689e53474f6339176a299ac7 */
/*
* eez-framework
*
Expand Down Expand Up @@ -2359,7 +2359,6 @@ void resetSequenceInputs(FlowState *flowState);
void propagateValue(FlowState *flowState, unsigned componentIndex, unsigned outputIndex, const Value &value);
void propagateValue(FlowState *flowState, unsigned componentIndex, unsigned outputIndex);
void propagateValueThroughSeqout(FlowState *flowState, unsigned componentIndex);
bool hasAnyDataConnection(FlowState *flowState, unsigned componentIndex, unsigned outputIndex);
#if EEZ_OPTION_GUI
void getValue(uint16_t dataId, DataOperationEnum operation, const WidgetCursor &widgetCursor, Value &value);
void setValue(uint16_t dataId, const WidgetCursor &widgetCursor, const Value& value);
Expand Down
2 changes: 1 addition & 1 deletion wasm/eez-framework
Loading

0 comments on commit ef6a4dc

Please sign in to comment.