mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-24 23:07:17 +00:00
OpenHASP support for roller's text attribute
This commit is contained in:
parent
d43e5eb7b9
commit
e6411a5d69
File diff suppressed because it is too large
Load Diff
@ -875,7 +875,7 @@ const be_ntv_func_def_t lv_dropdown_func[] = {
|
||||
{ "get_options", { (const void*) &lv_dropdown_get_options, "s", "(lv.lv_obj)" } },
|
||||
{ "get_selected", { (const void*) &lv_dropdown_get_selected, "i", "(lv.lv_obj)" } },
|
||||
{ "get_selected_highlight", { (const void*) &lv_dropdown_get_selected_highlight, "b", "(lv.lv_obj)" } },
|
||||
{ "get_selected_str", { (const void*) &lv_dropdown_get_selected_str, "", "(lv.lv_obj)si" } },
|
||||
{ "get_selected_str", { (const void*) &lv_dropdown_get_selected_str, "", "(lv.lv_obj)ci" } },
|
||||
{ "get_symbol", { (const void*) &lv_dropdown_get_symbol, "s", "(lv.lv_obj)" } },
|
||||
{ "get_text", { (const void*) &lv_dropdown_get_text, "s", "(lv.lv_obj)" } },
|
||||
{ "is_open", { (const void*) &lv_dropdown_is_open, "b", "(lv.lv_obj)" } },
|
||||
@ -898,7 +898,7 @@ const be_ntv_func_def_t lv_label_func[] = {
|
||||
{ "get_letter_pos", { (const void*) &lv_label_get_letter_pos, "", "(lv.lv_obj)i(lv.lv_point)" } },
|
||||
{ "get_long_mode", { (const void*) &lv_label_get_long_mode, "i", "(lv.lv_obj)" } },
|
||||
{ "get_recolor", { (const void*) &lv_label_get_recolor, "b", "(lv.lv_obj)" } },
|
||||
{ "get_text", { (const void*) &lv_label_get_text, "s", "(lv.lv_obj)" } },
|
||||
{ "get_text", { (const void*) &lv_label_get_text, "c", "(lv.lv_obj)" } },
|
||||
{ "get_text_selection_end", { (const void*) &lv_label_get_text_selection_end, "i", "(lv.lv_obj)" } },
|
||||
{ "get_text_selection_start", { (const void*) &lv_label_get_text_selection_start, "i", "(lv.lv_obj)" } },
|
||||
{ "ins_text", { (const void*) &lv_label_ins_text, "", "(lv.lv_obj)is" } },
|
||||
@ -928,7 +928,7 @@ const be_ntv_func_def_t lv_roller_func[] = {
|
||||
{ "get_option_cnt", { (const void*) &lv_roller_get_option_cnt, "i", "(lv.lv_obj)" } },
|
||||
{ "get_options", { (const void*) &lv_roller_get_options, "s", "(lv.lv_obj)" } },
|
||||
{ "get_selected", { (const void*) &lv_roller_get_selected, "i", "(lv.lv_obj)" } },
|
||||
{ "get_selected_str", { (const void*) &lv_roller_get_selected_str, "", "(lv.lv_obj)si" } },
|
||||
{ "get_selected_str", { (const void*) &lv_roller_get_selected_str, "", "(lv.lv_obj)ci" } },
|
||||
{ "set_options", { (const void*) &lv_roller_set_options, "", "(lv.lv_obj)s(lv.lv_roller_mode)" } },
|
||||
{ "set_selected", { (const void*) &lv_roller_set_selected, "", "(lv.lv_obj)ii" } },
|
||||
{ "set_visible_row_count", { (const void*) &lv_roller_set_visible_row_count, "", "(lv.lv_obj)i" } },
|
||||
|
@ -75,7 +75,7 @@ const be_ntv_func_def_t lv_func[] = {
|
||||
{ "draw_arc_dsc_init", { (const void*) &lv_draw_arc_dsc_init, "", "(lv.lv_draw_arc_dsc)" } },
|
||||
{ "draw_arc_get_area", { (const void*) &lv_draw_arc_get_area, "", "iiiiiib(lv.lv_area)" } },
|
||||
{ "draw_img", { (const void*) &lv_draw_img, "", "(lv.lv_draw_ctx)(lv.lv_draw_img_dsc)(lv.lv_area)." } },
|
||||
{ "draw_img_decoded", { (const void*) &lv_draw_img_decoded, "", "(lv.lv_draw_ctx)(lv.lv_draw_img_dsc)(lv.lv_area)(lv.uint8)i" } },
|
||||
{ "draw_img_decoded", { (const void*) &lv_draw_img_decoded, "", "(lv.lv_draw_ctx)(lv.lv_draw_img_dsc)(lv.lv_area)ci" } },
|
||||
{ "draw_img_dsc_init", { (const void*) &lv_draw_img_dsc_init, "", "(lv.lv_draw_img_dsc)" } },
|
||||
{ "draw_init", { (const void*) &lv_draw_init, "", "" } },
|
||||
{ "draw_label", { (const void*) &lv_draw_label, "", "(lv.lv_draw_ctx)(lv.lv_draw_label_dsc)(lv.lv_area)s(lv.lv_draw_label_hint)" } },
|
||||
@ -109,6 +109,7 @@ const be_ntv_func_def_t lv_func[] = {
|
||||
{ "event_stop_bubbling", { (const void*) &lv_event_stop_bubbling, "", "(lv.lv_event)" } },
|
||||
{ "event_stop_processing", { (const void*) &lv_event_stop_processing, "", "(lv.lv_event)" } },
|
||||
{ "flex_init", { (const void*) &lv_flex_init, "", "" } },
|
||||
{ "font_get_glyph_bitmap", { (const void*) &lv_font_get_glyph_bitmap, "c", "(lv.lv_font)i" } },
|
||||
{ "font_get_glyph_dsc", { (const void*) &lv_font_get_glyph_dsc, "b", "(lv.lv_font)(lv.lv_font_glyph_dsc)ii" } },
|
||||
{ "font_get_glyph_width", { (const void*) &lv_font_get_glyph_width, "i", "(lv.lv_font)ii" } },
|
||||
{ "font_get_line_height", { (const void*) &lv_font_get_line_height, "i", "(lv.lv_font)" } },
|
||||
|
@ -35,8 +35,10 @@ return_types = {
|
||||
"int32_t": "i",
|
||||
"void *": ".",
|
||||
"const void *": ".",
|
||||
"char *": "s",
|
||||
"char *": "c",
|
||||
"uint8_t *": "c",
|
||||
"const char *": "s",
|
||||
"constchar *": "s", # special construct
|
||||
"lv_obj_user_data_t": "i",
|
||||
|
||||
"lv_objmask_mask_t *": ".",
|
||||
@ -122,6 +124,7 @@ return_types = {
|
||||
"lv_anim_start_cb_t": "c",
|
||||
|
||||
# arrays
|
||||
"constchar * []": "str_arr",
|
||||
"char * []": "str_arr",
|
||||
"lv_coord_t []": "lv_coord_arr",
|
||||
"lv_point_t []": "lv_point_arr",
|
||||
@ -161,6 +164,7 @@ return_types = {
|
||||
"lv_timer_t *": "lv_timer",
|
||||
"lv_coord_t *": "c", # treat as a simple pointer, decoding needs to be done at Berry level
|
||||
"char **": "c", # treat as a simple pointer, decoding needs to be done at Berry level
|
||||
"constchar **": "c", # treat as a simple pointer, decoding needs to be done at Berry level
|
||||
|
||||
# callbacks
|
||||
"lv_group_focus_cb_t": "lv_group_focus_cb",
|
||||
@ -229,6 +233,7 @@ with open(lv_widgets_file) as f:
|
||||
l_raw = l_raw.strip(" \t\n\r") # remove leading or trailing spaces
|
||||
l_raw = re.sub('static ', '', l_raw)
|
||||
l_raw = re.sub('inline ', '', l_raw)
|
||||
l_raw = re.sub('const\s+char\s*\*', 'constchar *', l_raw)
|
||||
l_raw = re.sub('const ', '', l_raw)
|
||||
l_raw = re.sub('struct ', '', l_raw)
|
||||
if (len(l_raw) == 0): continue
|
||||
|
Binary file not shown.
Binary file not shown.
5
tasmota/berry/openhasp_src/gen_openhasp.sh
Executable file
5
tasmota/berry/openhasp_src/gen_openhasp.sh
Executable file
@ -0,0 +1,5 @@
|
||||
# generate all openhasp tapp files
|
||||
rm openhasp.tapp; zip -j -0 openhasp.tapp openhasp_core/*
|
||||
rm openhasp_demo.tapp ; zip -j -0 openhasp_demo.tapp openhasp_demo/* openhasp_core/openhasp.be
|
||||
cp openhasp.tapp ../openhasp
|
||||
cp openhasp_demo.tapp ../openhasp
|
Binary file not shown.
@ -175,6 +175,21 @@ class lvh_obj
|
||||
return bool(re.search("color$", str(t)))
|
||||
end
|
||||
|
||||
#- remove trailing NULL chars from a bytes buffer before converting to string -#
|
||||
#- Berry strings can contain NULL, but this messes up C-Berry interface -#
|
||||
static def remove_trailing_zeroes(b)
|
||||
var sz = size(b)
|
||||
var i = 0
|
||||
while i < sz
|
||||
if b[-1-i] != 0 break end
|
||||
i += 1
|
||||
end
|
||||
if i > 0
|
||||
b.resize(size(b)-i)
|
||||
end
|
||||
return b
|
||||
end
|
||||
|
||||
#################################################################################
|
||||
# Parses a color attribute
|
||||
#
|
||||
@ -324,7 +339,13 @@ class lvh_obj
|
||||
try
|
||||
# try to get the new val
|
||||
var val = self.val
|
||||
tas_event_more = string.format(',"val":%i', val)
|
||||
if val != nil tas_event_more = string.format(',"val":%i', val) end
|
||||
var text = self.text
|
||||
if text != nil
|
||||
import json
|
||||
tas_event_more += ',"text":'
|
||||
tas_event_more += json.dump(text)
|
||||
end
|
||||
except ..
|
||||
end
|
||||
end
|
||||
@ -1025,6 +1046,17 @@ class lvh_roller : lvh_obj
|
||||
def get_options()
|
||||
return self._lv_obj.get_options()
|
||||
end
|
||||
|
||||
def set_text(t)
|
||||
raise "attribute_error", "set_text unsupported on roller"
|
||||
end
|
||||
def get_text()
|
||||
# allocate a bytes buffer
|
||||
var b = bytes().resize(256) # force 256 bytes
|
||||
self._lv_obj.get_selected_str(b._buffer(), 256)
|
||||
b = self.remove_trailing_zeroes(b)
|
||||
return b.asstring()
|
||||
end
|
||||
end
|
||||
|
||||
#################################################################################
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user