Skip to content

Commit bc2d692

Browse files
committed
1 parent c6a1aa4 commit bc2d692

File tree

7 files changed

+74
-18
lines changed

7 files changed

+74
-18
lines changed
231 Bytes
Binary file not shown.
220 Bytes
Binary file not shown.

packages/project-editor/lvgl/build.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,14 @@ export class LVGLBuild extends Build {
948948
this.postBuildCallbacks = [];
949949
}
950950

951+
functions: {
952+
[key: string]: () => void;
953+
} = {};
954+
955+
addFunction(name: string, callback: () => void) {
956+
this.functions[name] = callback;
957+
}
958+
951959
async buildScreensDecl() {
952960
this.startBuild();
953961
const build = this;
@@ -1094,6 +1102,8 @@ export class LVGLBuild extends Build {
10941102
build.line("");
10951103
}
10961104

1105+
Object.values(this.functions).forEach(callback => callback());
1106+
10971107
if (build.assets.projectStore.projectTypeTraits.hasFlowSupport) {
10981108
for (const page of this.pages) {
10991109
page._lvglWidgets.forEach(widget => {
@@ -2448,8 +2458,8 @@ ${source}`;
24482458

24492459
// ensure consistent newlines accross all platforms
24502460
// (LF only) to avoid unnecessary VCS diffs
2451-
source = source.replace(/\r\n/g, '\n'); // Windows
2452-
source = source.replace(/\r/g, '\n'); // old Mac OS
2461+
source = source.replace(/\r\n/g, "\n"); // Windows
2462+
source = source.replace(/\r/g, "\n"); // old Mac OS
24532463

24542464
await writeTextFile(
24552465
this.project._store.getAbsoluteFilePath(

packages/project-editor/lvgl/widgets/Roller.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,39 @@ import type { LVGLCode } from "project-editor/lvgl/to-lvgl-code";
1818

1919
////////////////////////////////////////////////////////////////////////////////
2020

21+
const COMPARE_ROLLER_OPTIONS_FUNCTION = `int compareRollerOptions(lv_roller_t *roller, const char *new_val, const char *cur_val, lv_roller_mode_t mode) {
22+
(void)(mode);
23+
24+
uint32_t new_option_count = 1;
25+
26+
for (int i = 0; ; i++) {
27+
if (new_val[i] == '\\0') {
28+
if (cur_val[i] != '\\0' && cur_val[i] != '\\n') {
29+
return 1;
30+
}
31+
break;
32+
}
33+
34+
if (new_val[i] != cur_val[i]) {
35+
return 1;
36+
}
37+
38+
if (new_val[i] == '\\n') {
39+
new_option_count++;
40+
}
41+
}
42+
43+
#if LVGL_VERSION_MAJOR >= 9
44+
return lv_roller_get_option_count((const lv_obj_t *)roller) == new_option_count ? 0 : 1;
45+
#else
46+
return lv_roller_get_option_cnt((const lv_obj_t *)roller) == new_option_count ? 0 : 1;
47+
#endif
48+
}
49+
50+
`;
51+
52+
////////////////////////////////////////////////////////////////////////////////
53+
2154
export class LVGLRollerWidget extends LVGLWidget {
2255
options: string;
2356
optionsType: LVGLPropertyType;
@@ -159,6 +192,13 @@ export class LVGLRollerWidget extends LVGLWidget {
159192

160193
if (code.lvglBuild) {
161194
const build = code.lvglBuild;
195+
196+
if (!code.hasFlowSupport) {
197+
build.addFunction("compareRollerOptions", () => {
198+
build.text(COMPARE_ROLLER_OPTIONS_FUNCTION);
199+
});
200+
}
201+
162202
build.blockStart(
163203
`if (compareRollerOptions((lv_roller_t *)${code.objectAccessor}, new_val, cur_val, LV_ROLLER_MODE_${this.mode}) != 0) {`
164204
);

resources/eez-framework-amalgamation/eez-flow.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Autogenerated on August 31, 2025 10:03:55 AM from eez-framework commit d872c9b5473b578cbca111732726fb5c562692b3 */
1+
/* Autogenerated on September 1, 2025 11:27:52 AM from eez-framework commit 228083aa29bd547ccfabd472cb45b681fad58efe */
22
/*
33
* eez-framework
44
*
@@ -8013,22 +8013,28 @@ void *getFlowState(void *flowState, unsigned userWidgetComponentIndexOrPageIndex
80138013
void deletePageFlowState(unsigned pageIndex) {
80148014
eez::flow::deletePageFlowState(eez::g_mainAssets, (int16_t)pageIndex);
80158015
}
8016-
extern "C" bool compareRollerOptions(lv_roller_t *roller, const char *new_val, const char *cur_val, lv_roller_mode_t mode) {
8017-
if (mode == LV_ROLLER_MODE_NORMAL) {
8018-
return strcmp(new_val, cur_val) != 0;
8016+
extern "C" int compareRollerOptions(lv_roller_t *roller, const char *new_val, const char *cur_val, lv_roller_mode_t mode) {
8017+
EEZ_UNUSED(mode);
8018+
uint32_t new_option_count = 1;
8019+
for (int i = 0; ; i++) {
8020+
if (new_val[i] == '\0') {
8021+
if (cur_val[i] != '\0' && cur_val[i] != '\n') {
8022+
return 1;
8023+
}
8024+
break;
8025+
}
8026+
if (new_val[i] != cur_val[i]) {
8027+
return 1;
8028+
}
8029+
if (new_val[i] == '\n') {
8030+
new_option_count++;
8031+
}
80198032
}
8020-
auto n = strlen(new_val);
80218033
#if LVGL_VERSION_MAJOR >= 9
8022-
size_t numPages = roller->inf_page_cnt;
8034+
return lv_roller_get_option_count((const lv_obj_t *)roller) == new_option_count ? 0 : 1;
80238035
#else
8024-
size_t numPages = LV_ROLLER_INF_PAGES;
8036+
return lv_roller_get_option_cnt((const lv_obj_t *)roller) == new_option_count ? 0 : 1;
80258037
#endif
8026-
for (size_t i = 0; i < numPages * (n + 1); i += n + 1) {
8027-
if (strncmp(new_val, cur_val + i, n) != 0) {
8028-
return true;
8029-
}
8030-
}
8031-
return false;
80328038
}
80338039
uint32_t eez_flow_get_selected_theme_index() {
80348040
return g_selectedThemeIndex;

resources/eez-framework-amalgamation/eez-flow.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Autogenerated on August 31, 2025 10:03:55 AM from eez-framework commit d872c9b5473b578cbca111732726fb5c562692b3 */
1+
/* Autogenerated on September 1, 2025 11:27:52 AM from eez-framework commit 228083aa29bd547ccfabd472cb45b681fad58efe */
22
/*
33
* eez-framework
44
*
@@ -3100,7 +3100,7 @@ float eez_easeOutBounce(float x);
31003100
float eez_easeInOutBounce(float x);
31013101
float getTimelinePosition(void *flowState);
31023102
extern int g_eezFlowLvlgMeterTickIndex;
3103-
bool compareRollerOptions(lv_roller_t *roller, const char *new_val, const char *cur_val, lv_roller_mode_t mode);
3103+
int compareRollerOptions(lv_roller_t *roller, const char *new_val, const char *cur_val, lv_roller_mode_t mode);
31043104
uint32_t eez_flow_get_selected_theme_index();
31053105
#ifdef __cplusplus
31063106
}

0 commit comments

Comments
 (0)