Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LVGL add lv.str_arr #20480

Merged
merged 1 commit into from Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
- Berry `debug.caller` (#20470)
- GPIO Viewer user selection of assets website now defaults to `https://ota.tasmota.com/tasmota|tasmota32/gpio_viewer/assets`
- Support for HardwareSerial invert (#15461)
- LVGL add `lv.str_arr`

### Breaking Changed

Expand Down
5 changes: 4 additions & 1 deletion lib/libesp32/berry/src/be_introspectlib.c
Expand Up @@ -108,7 +108,10 @@ static int m_toptr(bvm *vm)
int top = be_top(vm);
if (top >= 1) {
bvalue *v = be_indexof(vm, 1);
if (var_basetype(v) >= BE_FUNCTION || var_type(v) == BE_COMPTR) {
if (var_type(v) == BE_STRING) {
be_pushcomptr(vm, be_tostring(vm, 1));
be_return(vm);
} else if (var_basetype(v) >= BE_FUNCTION || var_type(v) == BE_COMPTR) {
be_pushcomptr(vm, var_toobj(v));
be_return(vm);
} else if (var_type(v) == BE_INT) {
Expand Down
17 changes: 15 additions & 2 deletions lib/libesp32_lvgl/lv_binding_berry/src/embedded/lvgl_extra.be
Expand Up @@ -37,7 +37,6 @@ end
class lv_point_arr : bytes
def init(l)
if type(l) != 'instance' || !isinstance(l, list) raise "value_error", "argument must be a list" end
# size of the array is 2x number of elements
super(self).init(size(l) * 4)

for e: l
Expand All @@ -51,7 +50,6 @@ end
class lv_style_prop_arr : bytes
def init(l)
if type(l) != 'instance' || !isinstance(l, list) raise "value_error", "argument must be a list" end
# size of the array is 2x number of elements
super(self).init(size(l) * 4)

for e: l
Expand All @@ -60,9 +58,23 @@ class lv_style_prop_arr : bytes
end
end

class lv_str_arr : bytes
var l # keep a copy of the list because we want the pointer to strings to remain valid
def init(l)
self.l = l
super(self).init(size(l) * 4)

import introspect
for e: l
self.add(int(introspect.toptr(e)), 4)
end
end
end

lv_extra.lv_coord_arr = lv_coord_arr
lv_extra.lv_point_arr = lv_point_arr
lv_extra.lv_style_prop_arr = lv_style_prop_arr
lv_extra.lv_str_arr = lv_str_arr

lv_extra.init = def (m)
import global
Expand All @@ -73,6 +85,7 @@ lv_extra.init = def (m)
lv.coord_arr = m.lv_coord_arr
lv.point_arr = m.lv_point_arr
lv.style_prop_arr = m.lv_style_prop_arr
lv.str_arr = m.lv_str_arr

return m
end
Expand Down