Skip to content

Commit

Permalink
LVGL add lv.str_arr (arendst#20480)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-hadinger authored and hawa-lc4 committed Jan 20, 2024
1 parent 90091ce commit 797533f
Show file tree
Hide file tree
Showing 4 changed files with 266 additions and 166 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit 797533f

Please sign in to comment.