Skip to content

Commit c7a33f1

Browse files
committed
Clean up
1 parent b03491a commit c7a33f1

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

lvgltest.zig

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -53,76 +53,76 @@ pub export fn lv_demo_widgets() void {
5353
// Create Widgets
5454

5555
/// Create the LVGL Widgets that will be rendered on the display. Calls the
56-
/// LVGL API directly, without wrapping in Zig. Based on
56+
/// LVGL API that has been wrapped in Zig. Based on
5757
/// https://docs.lvgl.io/master/widgets/label.html?highlight=lv_label_create#line-wrap-recoloring-and-scrolling
58-
fn createWidgetsUnwrapped() !void {
59-
debug("createWidgetsUnwrapped: start", .{});
60-
defer { debug("createWidgetsUnwrapped: end", .{}); }
58+
fn createWidgetsWrapped() !void {
59+
debug("createWidgetsWrapped: start", .{});
60+
defer { debug("createWidgetsWrapped: end", .{}); }
6161

6262
// Get the Active Screen
63-
const screen = c.lv_scr_act().?;
63+
var screen = try lvgl.getActiveScreen();
6464

6565
// Create a Label Widget
66-
const label = c.lv_label_create(screen).?;
66+
var label = try screen.createLabel();
6767

6868
// Wrap long lines in the label text
69-
c.lv_label_set_long_mode(label, c.LV_LABEL_LONG_WRAP);
69+
label.setLongMode(c.LV_LABEL_LONG_WRAP);
7070

7171
// Interpret color codes in the label text
72-
c.lv_label_set_recolor(label, true);
72+
label.setRecolor(true);
7373

7474
// Center align the label text
75-
c.lv_obj_set_style_text_align(label, c.LV_TEXT_ALIGN_CENTER, 0);
75+
label.setAlign(c.LV_TEXT_ALIGN_CENTER);
7676

7777
// Set the label text and colors
78-
c.lv_label_set_text(
79-
label,
78+
label.setText(
8079
"#ff0000 HELLO# " ++ // Red Text
81-
"#00aa00 PINEDIO# " ++ // Green Text
82-
"#0000ff STACK!# " // Blue Text
80+
"#00aa00 LVGL ON# " ++ // Green Text
81+
"#0000ff PINEPHONE!# " // Blue Text
8382
);
8483

8584
// Set the label width
86-
c.lv_obj_set_width(label, 200);
85+
label.setWidth(200);
8786

8887
// Align the label to the center of the screen, shift 30 pixels up
89-
c.lv_obj_align(label, c.LV_ALIGN_CENTER, 0, -30);
88+
label.alignObject(c.LV_ALIGN_CENTER, 0, -30);
9089
}
9190

9291
/// Create the LVGL Widgets that will be rendered on the display. Calls the
93-
/// LVGL API that has been wrapped in Zig. Based on
92+
/// LVGL API directly, without wrapping in Zig. Based on
9493
/// https://docs.lvgl.io/master/widgets/label.html?highlight=lv_label_create#line-wrap-recoloring-and-scrolling
95-
fn createWidgetsWrapped() !void {
96-
debug("createWidgetsWrapped: start", .{});
97-
defer { debug("createWidgetsWrapped: end", .{}); }
94+
fn createWidgetsUnwrapped() !void {
95+
debug("createWidgetsUnwrapped: start", .{});
96+
defer { debug("createWidgetsUnwrapped: end", .{}); }
9897

9998
// Get the Active Screen
100-
var screen = try lvgl.getActiveScreen();
99+
const screen = c.lv_scr_act().?;
101100

102101
// Create a Label Widget
103-
var label = try screen.createLabel();
102+
const label = c.lv_label_create(screen).?;
104103

105104
// Wrap long lines in the label text
106-
label.setLongMode(c.LV_LABEL_LONG_WRAP);
105+
c.lv_label_set_long_mode(label, c.LV_LABEL_LONG_WRAP);
107106

108107
// Interpret color codes in the label text
109-
label.setRecolor(true);
108+
c.lv_label_set_recolor(label, true);
110109

111110
// Center align the label text
112-
label.setAlign(c.LV_TEXT_ALIGN_CENTER);
111+
c.lv_obj_set_style_text_align(label, c.LV_TEXT_ALIGN_CENTER, 0);
113112

114113
// Set the label text and colors
115-
label.setText(
114+
c.lv_label_set_text(
115+
label,
116116
"#ff0000 HELLO# " ++ // Red Text
117-
"#00aa00 PINEDIO# " ++ // Green Text
118-
"#0000ff STACK!# " // Blue Text
117+
"#00aa00 LVGL ON# " ++ // Green Text
118+
"#0000ff PINEPHONE!# " // Blue Text
119119
);
120120

121121
// Set the label width
122-
label.setWidth(200);
122+
c.lv_obj_set_width(label, 200);
123123

124124
// Align the label to the center of the screen, shift 30 pixels up
125-
label.alignObject(c.LV_ALIGN_CENTER, 0, -30);
125+
c.lv_obj_align(label, c.LV_ALIGN_CENTER, 0, -30);
126126
}
127127

128128
///////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)