ngui: port some LVGL-based UI code from C to zig #20

Closed
x1ddos wants to merge 0 commits from modal into master
x1ddos commented 1 year ago
Owner

the changes include lots of new code in ui/lvgl.zig and ui/widget.zig to work with LVGL directly from zig. in fact, some C code is moved from ui/c/ui.c to ui/xxx.zig.

in addition, a new module ui/widget.zig is where all custom UI elements will reside. at the moment it comprises of the ported topdrop and a new modal func. the latter is an alternative to LVGL's lv_msgbox popup.

as a practical example, the changes replace the power off confirmation popup with the new modal window: part of #5. here's how it looks like now; the white border lines around are the physical screen boundaries:

image

the changes include lots of new code in ui/lvgl.zig and ui/widget.zig to work with LVGL directly from zig. in fact, some C code is moved from ui/c/ui.c to ui/xxx.zig. in addition, a new module ui/widget.zig is where all custom UI elements will reside. at the moment it comprises of the ported topdrop and a new modal func. the latter is an alternative to LVGL's lv_msgbox popup. as a practical example, the changes replace the power off confirmation popup with the new modal window: part of https://git.qcode.ch/nakamochi/ndg/issues/5. here's how it looks like now; the white border lines around are the physical screen boundaries: ![image](/attachments/16ae90d3-835f-4aaf-b789-6351ecd48edc)
x1ddos added 2 commits 1 year ago
c73867ea4d
ngui: get rid of the ambiguous ui header file
functions declared in ui.h were actually used by ui.c, the opposite of
what such a header is expected to contain. these functions are defined
in zig code and declarations are better off in the same ui.c file.

this is just a quick clean up before porting some C code to zig.
8426bb046b
ngui: port some LVGL-based UI code from C to zig
this commit includes lots of new code in ui/lvgl.zig and ui/widget.zig
to work with LVGL directly from zig. in fact, some C code is moved from
ui/c/ui.c to ui/xxx.zig.

in addition, a new module ui/widget.zig is where all custom UI elements
will reside. at the moment it comprises of the ported topdrop and a new
modal func. the latter is an alternative to LVGL's lv_msgbox popup.

as a practical example, the commit replaces the power off confirmation
popup with the new modal window.
x1ddos commented 1 year ago
Poster
Owner

ah 💩 ci failed in https://woodpecker.qcode.ch/nakamochi/ndg/build/10/5 although compiles just fine or my machine. need to investigate.

ah 💩 ci failed in https://woodpecker.qcode.ch/nakamochi/ndg/build/10/5 although compiles just fine or my machine. need to investigate.
x1ddos force-pushed modal from 8426bb046b to 77d027b347 1 year ago
x1ddos force-pushed modal from 77d027b347 to 4297c139a1 1 year ago
x1ddos commented 1 year ago
Poster
Owner

the last forced push fixes a bug in indev deinit logic:

diff --git src/ui/lvgl.zig src/ui/lvgl.zig
index 2658532e..2f805efd 100644
--- src/ui/lvgl.zig
+++ src/ui/lvgl.zig
@@ -66,8 +66,8 @@ pub const TimerCallback = *const fn (timer: *LvTimer) callconv(.C) void;
 
 /// represents lv_indev_t in C, an input device such as touchscreen or a keyboard.
 pub const LvIndev = opaque {
-    pub fn first() *LvIndev {
-        return lv_indev_get_next(null).?; // there's always at least one indev
+    pub fn first() ?*LvIndev {
+        return lv_indev_get_next(null);
     }
 
     pub fn next(self: *LvIndev) ?*LvIndev {

the lv_indev_get_next(null) can actually return null during "go to standby" mode because all input devices are temporary deleted.

the last forced push fixes a bug in indev deinit logic: ```patch diff --git src/ui/lvgl.zig src/ui/lvgl.zig index 2658532e..2f805efd 100644 --- src/ui/lvgl.zig +++ src/ui/lvgl.zig @@ -66,8 +66,8 @@ pub const TimerCallback = *const fn (timer: *LvTimer) callconv(.C) void; /// represents lv_indev_t in C, an input device such as touchscreen or a keyboard. pub const LvIndev = opaque { - pub fn first() *LvIndev { - return lv_indev_get_next(null).?; // there's always at least one indev + pub fn first() ?*LvIndev { + return lv_indev_get_next(null); } pub fn next(self: *LvIndev) ?*LvIndev { ``` the `lv_indev_get_next(null)` can actually return null during "go to standby" mode because all input devices are temporary deleted.
x1ddos closed this pull request 1 year ago
x1ddos commented 1 year ago
Poster
Owner

actually merged with master at https://git.qcode.ch/nakamochi/ndg/commit/4297c139 but forgot to enable "manual merge detection" in the repo so gitea marked it as closed.

actually merged with master at https://git.qcode.ch/nakamochi/ndg/commit/4297c139 but forgot to enable "manual merge detection" in the repo so gitea marked it as closed.
This repo is archived. You cannot comment on pull requests.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: nakamochi/ndg#20
Loading…
There is no content yet.