2021-04-19 07:40:11 +01:00
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
2021-10-02 08:33:59 +01:00
|
|
|
lv_widgets_file = "lv_funcs.h"
|
2021-09-09 19:24:08 +01:00
|
|
|
lv_module_file = "lv_enum.h"
|
2021-04-19 07:40:11 +01:00
|
|
|
|
|
|
|
out_prefix = "../../tasmota/lvgl_berry/"
|
|
|
|
lvgl_prefix = "../../lib/libesp32/Berry/default/"
|
|
|
|
|
|
|
|
be_lv_defines = "be_lv_defines.h"
|
|
|
|
be_lv_c_mapping = "be_lv_c_mapping.h"
|
|
|
|
be_lv_widgets_libs = "be_lvgl_widgets_lib.c"
|
2021-09-04 10:12:18 +01:00
|
|
|
be_lv_lvgl_module = "be_lvgl_module.c"
|
2021-04-19 07:40:11 +01:00
|
|
|
|
2021-05-06 09:46:17 +01:00
|
|
|
# detect a function definition all
|
|
|
|
# Ex: 'void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent);'
|
|
|
|
# Group 1: 'void'
|
|
|
|
# Group 2: 'lv_obj_set_parent'
|
|
|
|
# Group 3: 'lv_obj_t * obj, lv_obj_t * parent'
|
|
|
|
parse_func_def = re.compile("(.*?)\s(\w+)\((.*?)\)")
|
2021-04-19 07:40:11 +01:00
|
|
|
|
2021-05-06 09:46:17 +01:00
|
|
|
# parse call argument type
|
|
|
|
# Ex: 'const lv_obj_t * parent' -> 'const ', 'lv_obj_t', ' * ', 'parent'
|
|
|
|
# Ex: 'bool auto_fit' -> '', 'bool', ' ', 'auto_fit'
|
|
|
|
parse_arg = re.compile("(\w+\s+)?(\w+)([\*\s]+)(\w+)")
|
2021-04-19 07:40:11 +01:00
|
|
|
|
|
|
|
return_types = {
|
|
|
|
"void": "",
|
|
|
|
"bool": "b",
|
|
|
|
"uint8_t": "i",
|
|
|
|
"uint16_t": "i",
|
|
|
|
"int16_t": "i",
|
|
|
|
"uint32_t": "i",
|
|
|
|
"int32_t": "i",
|
2021-05-21 12:49:47 +01:00
|
|
|
"void *": ".",
|
|
|
|
"const void *": ".",
|
2021-04-19 07:40:11 +01:00
|
|
|
"char *": "s",
|
|
|
|
"const char *": "s",
|
|
|
|
"lv_obj_user_data_t": "i",
|
|
|
|
|
2021-07-21 22:17:53 +01:00
|
|
|
"lv_objmask_mask_t *": ".",
|
|
|
|
|
2021-04-19 07:40:11 +01:00
|
|
|
"lv_coord_t": "i",
|
|
|
|
"lv_res_t": "i",
|
|
|
|
"lv_style_int_t": "i",
|
|
|
|
"lv_opa_t": "i",
|
|
|
|
"lv_drag_dir_t": "i",
|
|
|
|
"lv_bidi_dir_t": "i",
|
|
|
|
"lv_state_t": "i",
|
|
|
|
"lv_arc_type_t":"i",
|
|
|
|
"lv_chart_axis_t":"i",
|
|
|
|
"lv_bar_type_t":"i",
|
|
|
|
"lv_btn_state_t":"i",
|
|
|
|
"lv_point_t":"i",
|
|
|
|
"lv_chart_type_t":"i",
|
|
|
|
"lv_fit_t":"i",
|
|
|
|
"lv_cpicker_color_mode_t":"i",
|
|
|
|
"lv_dropdown_dir_t":"i",
|
|
|
|
"lv_layout_t":"i",
|
|
|
|
"lv_color_hsv_t":"i",
|
|
|
|
"lv_label_long_mode_t": "i",
|
|
|
|
"lv_label_align_t": "i",
|
|
|
|
"lv_scrollbar_mode_t": "i",
|
|
|
|
"lv_spinbox_part_t": "i",
|
|
|
|
"lv_spinner_style_t": "i",
|
|
|
|
"lv_anim_value_t": "i",
|
|
|
|
"lv_switch_part_t": "i",
|
|
|
|
"lv_label_align_t": "i",
|
|
|
|
"lv_tabview_btns_pos_t": "i",
|
|
|
|
"lv_textarea_style_t": "i",
|
|
|
|
"lv_slider_type_t": "i",
|
|
|
|
"lv_spinner_type_t": "i",
|
|
|
|
"lv_spinner_dir_t": "i",
|
2021-05-06 09:46:17 +01:00
|
|
|
"lv_blend_mode_t": "i",
|
|
|
|
"lv_grad_dir_t": "i",
|
|
|
|
"lv_border_side_t": "i",
|
|
|
|
"lv_align_t": "i",
|
|
|
|
"lv_keyboard_mode_t": "i",
|
2021-05-07 10:51:22 +01:00
|
|
|
"lv_indev_type_t": "i",
|
2021-07-12 21:53:31 +01:00
|
|
|
"lv_event_t": "i",
|
|
|
|
"lv_signal_t": "i",
|
2021-07-21 22:17:53 +01:00
|
|
|
"lv_img_cf_t": "i",
|
|
|
|
"lv_draw_mask_line_side_t": "i",
|
2021-09-03 17:35:50 +01:00
|
|
|
"lv_style_property_t": "i",
|
2021-10-02 08:33:59 +01:00
|
|
|
"lv_dir_t": "i",
|
|
|
|
"lv_part_t": "i",
|
|
|
|
"lv_base_dir_t": "i",
|
|
|
|
"lv_text_decor_t": "i",
|
|
|
|
"lv_text_align_t": "i",
|
|
|
|
"lv_arc_mode_t": "i",
|
|
|
|
"lv_bar_mode_t": "i",
|
|
|
|
"lv_event_code_t": "i",
|
|
|
|
"lv_obj_flag_t": "i",
|
|
|
|
"lv_slider_mode_t": "i",
|
|
|
|
"lv_scroll_snap_t": "i",
|
|
|
|
"lv_style_value_t": "i",
|
|
|
|
"lv_img_src_t": "i",
|
|
|
|
"lv_colorwheel_mode_t": "i",
|
2021-10-04 18:15:27 +01:00
|
|
|
"lv_scr_load_anim_t": "i",
|
2021-10-23 14:08:33 +01:00
|
|
|
"lv_style_selector_t": "i",
|
2021-10-02 08:33:59 +01:00
|
|
|
|
|
|
|
"_lv_event_dsc_t *": "i",
|
2021-04-19 07:40:11 +01:00
|
|
|
|
2021-07-12 21:53:31 +01:00
|
|
|
# "lv_signal_cb_t": "c",
|
|
|
|
# "lv_design_cb_t": "c",
|
|
|
|
# "lv_event_cb_t": "c",
|
|
|
|
# "lv_group_focus_cb_t": "c",
|
2021-04-19 07:40:11 +01:00
|
|
|
|
2021-10-02 08:33:59 +01:00
|
|
|
# ctypes objects
|
|
|
|
"lv_area_t *": "lv_area",
|
|
|
|
"lv_meter_scale_t *": "lv_meter_scale",
|
|
|
|
"lv_meter_indicator_t *": "lv_meter_indicator",
|
|
|
|
"lv_obj_class_t *": "lv_obj_class",
|
|
|
|
|
|
|
|
"_lv_obj_t *": "lv_obj",
|
2021-04-19 07:40:11 +01:00
|
|
|
"lv_obj_t *": "lv_obj",
|
|
|
|
"lv_color_t": "lv_color",
|
|
|
|
"lv_style_t *": "lv_style",
|
|
|
|
"lv_group_t *": "lv_group",
|
2021-10-02 08:33:59 +01:00
|
|
|
"lv_font_t *": "lv_font",
|
2021-10-23 14:08:33 +01:00
|
|
|
"lv_theme_t *": "lv_theme",
|
|
|
|
"lv_disp_t *": "lv_disp",
|
|
|
|
"lv_indev_t *": "lv_indev",
|
2021-04-19 07:40:11 +01:00
|
|
|
#"lv_disp_t*": "lv_disp",
|
|
|
|
#"lv_style_list_t*": "",
|
2021-07-12 21:53:31 +01:00
|
|
|
|
|
|
|
# callbacks
|
|
|
|
"lv_group_focus_cb_t": "lv_group_focus_cb",
|
|
|
|
"lv_event_cb_t": "lv_event_cb",
|
2021-10-02 08:33:59 +01:00
|
|
|
# "lv_signal_cb_t": "lv_signal_cb", # removed in LVGL8
|
|
|
|
# "lv_design_cb_t": "lv_design_cb", # removed in LVGL8
|
|
|
|
# "lv_gauge_format_cb_t": "lv_gauge_format_cb", # removed in LVGL8
|
2021-04-19 07:40:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
lv = {}
|
|
|
|
lvs = [] # special case for case for lv_style
|
|
|
|
lv0 = [] # function in lvlg module
|
|
|
|
lv_module = []
|
2021-10-02 08:33:59 +01:00
|
|
|
lv_cb_types = ['lv_group_focus_cb', 'lv_event_cb',
|
|
|
|
'lv_constructor_cb', # 'constructor_cb', addition to LVGL8, also works for 'destructor_cb'
|
|
|
|
]
|
2021-07-12 21:53:31 +01:00
|
|
|
# list of callback types that will need each a separate C callback
|
2021-04-19 07:40:11 +01:00
|
|
|
|
2021-10-23 14:08:33 +01:00
|
|
|
# For LVGL8, need to add synthetic lv_style, lv_font, lv_color, lv_theme
|
2021-10-02 08:33:59 +01:00
|
|
|
lv['style'] = []
|
2021-10-15 18:34:37 +01:00
|
|
|
lv['font'] = []
|
|
|
|
lv['color'] = []
|
2021-10-23 14:08:33 +01:00
|
|
|
lv['theme'] = []
|
2021-10-02 08:33:59 +01:00
|
|
|
|
|
|
|
# standard widgets
|
|
|
|
lv_widgets = ['arc', 'bar', 'btn', 'btnmatrix', 'canvas', 'checkbox',
|
|
|
|
'dropdown', 'img', 'label', 'line', 'roller', 'slider',
|
|
|
|
'switch', 'table', 'textarea' ]
|
|
|
|
# extra widgets
|
|
|
|
|
2021-10-25 21:20:48 +01:00
|
|
|
lv_widgets = lv_widgets + [ 'chart', 'colorwheel', 'imgbtn', 'led', 'meter', 'msgbox', 'spinbox', 'spinner' ]
|
2021-10-23 14:08:33 +01:00
|
|
|
lv_prefix = ['obj', 'group', 'style', 'indev', 'disp'] + lv_widgets
|
2021-04-19 07:40:11 +01:00
|
|
|
|
2021-10-26 20:58:21 +01:00
|
|
|
# define here widget inheritance because it's hard to deduce from source
|
|
|
|
lv_widget_inheritance = {
|
|
|
|
"animing": "img",
|
|
|
|
"calendar": "btnmatrix",
|
|
|
|
"keyboard": "btnmatrix",
|
|
|
|
"list_btn": "btn",
|
|
|
|
"list_text": "label",
|
|
|
|
"spinbox": "textarea",
|
|
|
|
"spinner": "arc", # lv_spinner is a subclass of lv_arc
|
|
|
|
"canvas": "img",
|
|
|
|
"roller_label": "label",
|
|
|
|
}
|
|
|
|
|
2021-04-19 07:40:11 +01:00
|
|
|
def try_int(s):
|
|
|
|
try:
|
|
|
|
v = int(s)
|
|
|
|
return v
|
|
|
|
except ValueError:
|
|
|
|
return None
|
|
|
|
|
|
|
|
# convert a C return type to the string representation for the Berry parser
|
|
|
|
# using return_types
|
|
|
|
def c_convert_ret_type(c_ret):
|
|
|
|
return return_types.get(c_ret, "")
|
|
|
|
|
2021-05-06 09:46:17 +01:00
|
|
|
# parse widgets files containing most function calls
|
|
|
|
with open(lv_widgets_file) as f:
|
2021-04-19 07:40:11 +01:00
|
|
|
for l_raw in f:
|
|
|
|
l_raw = re.sub('//.*$', '', l_raw) # remove trailing comments
|
2021-07-12 21:53:31 +01:00
|
|
|
l_raw = re.sub('LV_ATTRIBUTE_FAST_MEM ', '', l_raw) # remove LV_ATTRIBUTE_FAST_MEM marker
|
2021-04-19 07:40:11 +01:00
|
|
|
l_raw = re.sub('\s+', ' ', l_raw) # replace any multi-space with a single space
|
|
|
|
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)
|
2021-10-02 08:33:59 +01:00
|
|
|
l_raw = re.sub('const ', '', l_raw)
|
|
|
|
l_raw = re.sub('struct ', '', l_raw)
|
2021-04-19 07:40:11 +01:00
|
|
|
if (len(l_raw) == 0): continue
|
|
|
|
|
2021-05-06 09:46:17 +01:00
|
|
|
g = parse_func_def.search(l_raw)
|
2021-04-19 07:40:11 +01:00
|
|
|
if g:
|
|
|
|
# if match, we parse the line
|
2021-05-06 09:46:17 +01:00
|
|
|
# Ex: 'void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent);'
|
|
|
|
ret_type = g.group(1) # return type of the function
|
|
|
|
# Ex: ret_type -> 'void'
|
2021-04-19 07:40:11 +01:00
|
|
|
|
2021-07-12 21:53:31 +01:00
|
|
|
ret_type_without_t = re.sub(r"_t$", "", ret_type)
|
|
|
|
if ret_type in return_types:
|
|
|
|
# convert return type
|
|
|
|
c_ret = c_convert_ret_type(ret_type)
|
|
|
|
elif ret_type_without_t in lv_cb_types:
|
|
|
|
c_ret = "c" # general callback, if not already captured by explicit type
|
|
|
|
else:
|
2021-04-19 07:40:11 +01:00
|
|
|
print(f" // Skipping unsupported return type: {ret_type}")
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
# convert arguments
|
2021-05-06 09:46:17 +01:00
|
|
|
c_args = ""
|
|
|
|
args_raw = [ x.strip(" \t\n\r") for x in g.group(3).split(",") ] # split by comma and strip
|
|
|
|
for arg_raw in args_raw:
|
|
|
|
# Ex: 'const lv_obj_t * parent' -> 'const ', 'lv_obj_t', ' * ', 'parent'
|
|
|
|
# Ex: 'bool auto_fit' -> '', 'bool', ' ', 'auto_fit'
|
|
|
|
ga = parse_arg.search(arg_raw)
|
|
|
|
if ga: # parsing ok?
|
|
|
|
ga_type = ga.group(2)
|
|
|
|
ga_ptr = ( ga.group(3).strip(" \t\n\r") == "*" ) # boolean
|
|
|
|
ga_name = ga.group(4)
|
|
|
|
ga_type_ptr = ga_type
|
|
|
|
if ga_ptr: ga_type_ptr += " *"
|
|
|
|
if ga_type_ptr in return_types:
|
|
|
|
ga_type = return_types[ga_type_ptr]
|
|
|
|
else:
|
|
|
|
# remove the trailing '_t' of type name if any
|
|
|
|
ga_type = re.sub(r"_t$", "", ga_type)
|
|
|
|
|
|
|
|
# if the type is a single letter, we just add it
|
2021-07-12 21:53:31 +01:00
|
|
|
if len(ga_type) == 1 and ga_type != 'c': # callbacks are different
|
2021-05-06 09:46:17 +01:00
|
|
|
c_args += ga_type
|
|
|
|
else:
|
|
|
|
if ga_type.endswith("_cb"):
|
|
|
|
# it's a callback type, we encode it differently
|
|
|
|
if ga_type not in lv_cb_types:
|
|
|
|
lv_cb_types.append(ga_type)
|
2021-10-02 08:33:59 +01:00
|
|
|
c_args += "^" + ga_type + "^"
|
2021-05-06 09:46:17 +01:00
|
|
|
else:
|
|
|
|
# we have a high-level type that we treat as a class name, enclose in parenthesis
|
2021-10-15 18:34:37 +01:00
|
|
|
c_args += "(" + "lv." + ga_type + ")"
|
2021-04-19 07:40:11 +01:00
|
|
|
|
|
|
|
# analyze function name and determine if it needs to be assigned to a specific class
|
|
|
|
func_name = g.group(2)
|
2021-05-06 09:46:17 +01:00
|
|
|
# Ex: func_name -> 'lv_obj_set_parent'
|
2021-04-19 07:40:11 +01:00
|
|
|
if func_name.startswith("_"): continue # skip low-level
|
|
|
|
if func_name.startswith("lv_debug_"): continue # skip debug
|
|
|
|
|
|
|
|
c_func_name = ""
|
|
|
|
|
2021-07-12 21:53:31 +01:00
|
|
|
if func_name == "lv_style_init":
|
|
|
|
continue # no need for init as it would collied with native init (and called behind the scene anyways)
|
|
|
|
|
2021-04-19 07:40:11 +01:00
|
|
|
found = False
|
|
|
|
for subtype in lv_prefix:
|
|
|
|
if func_name.startswith("lv_" + subtype + "_"):
|
|
|
|
be_name = re.sub("^lv_" + subtype + "_", '', func_name)
|
|
|
|
c_func_name = "lvbe_" + subtype + "_" + be_name
|
|
|
|
if subtype not in lv: lv[subtype] = [] # add entry
|
2021-10-15 18:34:37 +01:00
|
|
|
is_right_type = c_args.startswith(f"(lv.lv_{subtype})") # check if first arg matches class
|
|
|
|
is_obj_arg1 = c_args.startswith(f"(lv.lv_obj)") # or first arg is lv_obj
|
2021-10-02 08:33:59 +01:00
|
|
|
is_group_create = (subtype == 'group') and (func_name == 'lv_group_create')
|
|
|
|
if is_right_type or is_obj_arg1 or is_group_create:
|
|
|
|
lv[subtype].append( [ c_func_name, c_ret, c_args, func_name, be_name ] )
|
|
|
|
found = True
|
|
|
|
break
|
2021-04-19 07:40:11 +01:00
|
|
|
|
|
|
|
if found: continue
|
2021-07-12 21:53:31 +01:00
|
|
|
# not found, we treat it as lv top level function
|
|
|
|
be_name = re.sub("^lv_", '', func_name)
|
|
|
|
lv0.append( [ func_name, c_ret, c_args, func_name, be_name ] )
|
|
|
|
# print(lv0[-1])
|
2021-04-19 07:40:11 +01:00
|
|
|
|
2021-05-06 09:46:17 +01:00
|
|
|
print("| callback types"+str(lv_cb_types))
|
2021-04-19 07:40:11 +01:00
|
|
|
|
2021-05-06 09:46:17 +01:00
|
|
|
# parse module file containing numerical constants
|
|
|
|
with open(lv_module_file) as f:
|
2021-04-19 07:40:11 +01:00
|
|
|
for l_raw in f:
|
|
|
|
l_raw = l_raw.strip(" \t\n\r") # remove leading or trailing spaces
|
|
|
|
if l_raw.startswith("//"):
|
|
|
|
lv_module.append( [ None, l_raw ] ) # if key in None then add comment line
|
|
|
|
l_raw = re.sub('//.*$', '', l_raw) # remove trailing comments
|
|
|
|
l_raw = re.sub('\s+', '', l_raw) # remove all spaces
|
2021-05-20 18:34:51 +01:00
|
|
|
l_raw = re.sub(',.*$', '', l_raw) # remove comma and anything after it
|
2021-04-19 07:40:11 +01:00
|
|
|
if (len(l_raw) == 0): continue
|
|
|
|
|
|
|
|
k_v = l_raw.split("=")
|
2021-05-20 18:34:51 +01:00
|
|
|
if len(k_v) > 2:
|
2021-04-19 07:40:11 +01:00
|
|
|
print(f"Error: cannot match {l_raw}")
|
|
|
|
continue
|
2021-05-20 18:34:51 +01:00
|
|
|
# extract the key name
|
2021-04-19 07:40:11 +01:00
|
|
|
k = k_v[0]
|
2021-05-20 18:34:51 +01:00
|
|
|
if k.startswith("_"):
|
|
|
|
continue # skip any label starting with '_'
|
2021-04-19 07:40:11 +01:00
|
|
|
k = re.sub('^LV_', '', k) # remove remove any LV_ prefix
|
2021-10-15 18:34:37 +01:00
|
|
|
v = None
|
2021-05-20 18:34:51 +01:00
|
|
|
if len(k_v) == 2: # value is included
|
|
|
|
v = k_v[1]
|
2021-10-15 18:34:37 +01:00
|
|
|
if k is None or v is None: continue # we skip if key is void or value is void
|
2021-04-19 07:40:11 +01:00
|
|
|
|
|
|
|
if not k.isidentifier():
|
|
|
|
print(f"Error: {k} is not an identifier")
|
|
|
|
continue
|
|
|
|
|
2021-10-15 18:34:37 +01:00
|
|
|
lv_module.append( [k, v] ) # keep as string or None
|
2021-04-19 07:40:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
sys.stdout = open(out_prefix + be_lv_c_mapping, 'w')
|
|
|
|
print("""
|
|
|
|
/********************************************************************
|
|
|
|
* Generated code, don't edit
|
|
|
|
*******************************************************************/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2021-05-19 08:53:20 +01:00
|
|
|
|
2021-10-15 18:34:37 +01:00
|
|
|
#include "be_ctypes.h"
|
2021-05-19 08:53:20 +01:00
|
|
|
""")
|
|
|
|
|
|
|
|
for subtype, flv in lv.items():
|
2021-05-21 21:31:15 +01:00
|
|
|
print(f"/* `lv_{subtype}` methods */")
|
|
|
|
if subtype in lv_widgets:
|
2021-10-02 08:33:59 +01:00
|
|
|
print(f"#ifdef BE_LV_WIDGET_{subtype.upper()}")
|
2021-05-21 21:31:15 +01:00
|
|
|
print(f"const lvbe_call_c_t lv_{subtype}_func[] = {{")
|
2021-05-19 08:53:20 +01:00
|
|
|
|
|
|
|
func_out = {} # used to sort output
|
|
|
|
for f in flv:
|
|
|
|
c_func_name = f[0]
|
|
|
|
c_ret_type = f[1]
|
|
|
|
c_argc = f[2]
|
|
|
|
if c_argc is not None: c_argc = "\"" + c_argc + "\""
|
|
|
|
orig_func_name = f[3]
|
|
|
|
be_name = f[4]
|
2021-10-15 18:34:37 +01:00
|
|
|
# if c_ret_type is an object, prefix with `lv.`
|
|
|
|
if len(c_ret_type) > 1: c_ret_type = "lv." + c_ret_type
|
|
|
|
|
2021-05-19 08:53:20 +01:00
|
|
|
if c_func_name.endswith("_create"):
|
2021-10-02 08:33:59 +01:00
|
|
|
pass
|
|
|
|
# c_ret_type = f"+lv_{subtype}"
|
|
|
|
else:
|
|
|
|
func_out[be_name] = f" {{ \"{be_name}\", (void*) &{orig_func_name}, \"{c_ret_type}\", { c_argc if c_argc else 'nullptr'} }},"
|
2021-05-19 08:53:20 +01:00
|
|
|
|
|
|
|
for be_name in sorted(func_out):
|
|
|
|
print(func_out[be_name])
|
|
|
|
|
2021-05-21 21:31:15 +01:00
|
|
|
print(f"}};")
|
|
|
|
if subtype in lv_widgets:
|
|
|
|
print(f"#endif // BE_LV_WIDGET_{subtype.upper()}")
|
|
|
|
print(f"")
|
2021-05-19 08:53:20 +01:00
|
|
|
|
2021-10-15 18:34:37 +01:00
|
|
|
# extern classes
|
|
|
|
for subtype in sorted(lv):
|
|
|
|
print(f"extern const bclass be_class_lv_{subtype};");
|
|
|
|
print()
|
|
|
|
|
2021-05-19 08:53:20 +01:00
|
|
|
# print the global map of classes
|
|
|
|
print(f"""
|
|
|
|
// map of clases
|
|
|
|
const lvbe_call_c_classes_t lv_classes[] = {{""")
|
|
|
|
|
|
|
|
for subtype in sorted(lv):
|
|
|
|
# for subtype, flv in lv.items():
|
2021-05-21 21:31:15 +01:00
|
|
|
if subtype in lv_widgets:
|
2021-10-02 08:33:59 +01:00
|
|
|
print(f"#ifdef BE_LV_WIDGET_{subtype.upper()}")
|
2021-10-15 18:34:37 +01:00
|
|
|
print(f" {{ \"lv_{subtype}\", &be_class_lv_{subtype}, lv_{subtype}_func, sizeof(lv_{subtype}_func) / sizeof(lv_{subtype}_func[0]) }},")
|
2021-05-21 21:31:15 +01:00
|
|
|
if subtype in lv_widgets:
|
|
|
|
print(f"#endif // BE_LV_WIDGET_{subtype.upper()}")
|
2021-05-19 08:53:20 +01:00
|
|
|
|
|
|
|
print(f"""}};
|
|
|
|
const size_t lv_classes_size = sizeof(lv_classes) / sizeof(lv_classes[0]);
|
2021-04-19 07:40:11 +01:00
|
|
|
""")
|
|
|
|
|
2021-05-19 08:53:20 +01:00
|
|
|
# previous generation calls
|
|
|
|
|
|
|
|
# keep only create
|
2021-04-19 07:40:11 +01:00
|
|
|
for subtype, flv in lv.items():
|
|
|
|
print(f" /* `lv_{subtype}` methods */")
|
|
|
|
for f in flv:
|
|
|
|
c_func_name = f[0]
|
|
|
|
c_ret_type = f[1]
|
|
|
|
c_argc = f[2]
|
|
|
|
if c_argc is not None: c_argc = "\"" + c_argc + "\""
|
|
|
|
orig_func_name = f[3]
|
2021-10-15 18:34:37 +01:00
|
|
|
|
|
|
|
# if c_ret_type is an object, prefix with `lv.`
|
|
|
|
if len(c_ret_type) > 1: c_ret_type = "lv." + c_ret_type
|
|
|
|
|
2021-04-19 07:40:11 +01:00
|
|
|
if c_func_name.endswith("_create"):
|
2021-10-26 20:58:21 +01:00
|
|
|
c_ret_type = "+" # constructor, init method does not return any value
|
2021-05-21 21:31:15 +01:00
|
|
|
if subtype in lv_widgets:
|
2021-10-02 08:33:59 +01:00
|
|
|
print(f"#ifdef BE_LV_WIDGET_{subtype.upper()}")
|
2021-10-15 18:34:37 +01:00
|
|
|
print(f" int be_ntv_lv_{subtype}_init(bvm *vm) {{ return be_call_c_func(vm, (void*) &{orig_func_name}, \"{c_ret_type}\", { c_argc if c_argc else 'nullptr'}); }}")
|
2021-05-21 21:31:15 +01:00
|
|
|
print(f"#endif // BE_LV_WIDGET_{subtype.upper()}")
|
2021-10-15 18:34:37 +01:00
|
|
|
else:
|
|
|
|
print(f" int be_ntv_lv_{subtype}_init(bvm *vm) {{ return be_call_c_func(vm, (void*) &{orig_func_name}, \"{c_ret_type}\", { c_argc if c_argc else 'nullptr'}); }}")
|
|
|
|
|
|
|
|
print("""
|
|
|
|
// create font either empty or from parameter on stack
|
2021-10-23 14:08:33 +01:00
|
|
|
int lvbe_font_create(bvm *vm) { return be_call_c_func(vm, NULL, "+lv_font", ""); }
|
|
|
|
int lvbe_theme_create(bvm *vm) { return be_call_c_func(vm, NULL, "+lv_theme", ""); }
|
2021-10-15 18:34:37 +01:00
|
|
|
""")
|
|
|
|
|
2021-04-19 07:40:11 +01:00
|
|
|
print()
|
|
|
|
print("#ifdef __cplusplus")
|
|
|
|
print("} /* extern \"C\" */")
|
|
|
|
print("#endif")
|
|
|
|
print("/********************************************************************/")
|
|
|
|
sys.stdout.close()
|
|
|
|
|
|
|
|
|
|
|
|
sys.stdout = open(lvgl_prefix + be_lv_widgets_libs, 'w')
|
|
|
|
print("""
|
|
|
|
/********************************************************************
|
|
|
|
* Generated code, don't edit
|
|
|
|
*******************************************************************/
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* Tasmota LVGL classes for widgets
|
|
|
|
*******************************************************************/
|
2021-04-28 18:30:19 +01:00
|
|
|
#include "be_constobj.h"
|
2021-04-19 07:40:11 +01:00
|
|
|
|
|
|
|
#ifdef USE_LVGL
|
|
|
|
|
|
|
|
#include "lvgl.h"
|
|
|
|
|
2021-05-07 10:51:22 +01:00
|
|
|
extern int lv0_init(bvm *vm);
|
|
|
|
|
2021-10-15 18:34:37 +01:00
|
|
|
extern int lco_init(bvm *vm); // generic function
|
|
|
|
extern int lco_tostring(bvm *vm); // generic function
|
|
|
|
extern int lco_toint(bvm *vm); // generic function
|
2021-04-19 07:40:11 +01:00
|
|
|
|
2021-05-19 08:53:20 +01:00
|
|
|
extern int lvx_member(bvm *vm);
|
2021-04-19 07:40:11 +01:00
|
|
|
extern int lvx_tostring(bvm *vm); // generic function
|
|
|
|
|
|
|
|
extern int lvs_init(bvm *vm);
|
|
|
|
extern int lvs_tostring(bvm *vm);
|
|
|
|
|
|
|
|
BE_EXPORT_VARIABLE extern const bclass be_class_lv_obj;
|
2021-10-15 18:34:37 +01:00
|
|
|
|
|
|
|
extern int lvbe_font_create(bvm *vm);
|
2021-10-23 14:08:33 +01:00
|
|
|
extern int lvbe_theme_create(bvm *vm);
|
2021-10-15 18:34:37 +01:00
|
|
|
|
2021-04-19 07:40:11 +01:00
|
|
|
""")
|
|
|
|
|
2021-10-15 18:34:37 +01:00
|
|
|
# expose all extern definitions:
|
|
|
|
# Ex:
|
|
|
|
#
|
|
|
|
# /* `lv_canvas` external functions definitions */
|
|
|
|
# extern int lvbe_canvas_create(bvm *vm);
|
|
|
|
# extern int lvbe_canvas_set_buffer(bvm *vm);
|
|
|
|
# ...
|
|
|
|
#
|
2021-04-19 07:40:11 +01:00
|
|
|
for subtype, flv in lv.items():
|
|
|
|
print(f"/* `lv_{subtype}` external functions definitions */")
|
|
|
|
for f in flv:
|
|
|
|
c_func_name = f[0]
|
|
|
|
print(f"extern int {c_func_name}(bvm *vm);")
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
for subtype, flv in lv.items():
|
2021-10-15 18:34:37 +01:00
|
|
|
print(f"""extern int be_ntv_lv_{subtype}_init(bvm *vm);""")
|
2021-04-19 07:40:11 +01:00
|
|
|
|
|
|
|
print()
|
|
|
|
|
2021-10-26 20:58:21 +01:00
|
|
|
# extern classes
|
|
|
|
for subtype in sorted(lv):
|
|
|
|
print(f"extern const bclass be_class_lv_{subtype};");
|
|
|
|
print()
|
|
|
|
|
2021-10-15 18:34:37 +01:00
|
|
|
# Define specific classes for lv_obj
|
|
|
|
#
|
|
|
|
print("""
|
|
|
|
/********************************************************************
|
|
|
|
** Solidified class: lv_style
|
|
|
|
********************************************************************/
|
|
|
|
be_local_class(lv_style,
|
|
|
|
1,
|
|
|
|
NULL,
|
|
|
|
be_nested_map(4,
|
|
|
|
( (struct bmapnode*) &(const bmapnode[]) {
|
|
|
|
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lvs_init) },
|
|
|
|
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvs_tostring) },
|
|
|
|
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
|
|
|
|
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lvx_member) },
|
|
|
|
})),
|
|
|
|
(be_nested_const_str("lv_style", -143355747, 8))
|
|
|
|
);
|
|
|
|
/*******************************************************************/
|
2021-04-19 07:40:11 +01:00
|
|
|
|
2021-10-15 18:34:37 +01:00
|
|
|
/********************************************************************
|
|
|
|
** Solidified class: lv_obj
|
|
|
|
********************************************************************/
|
|
|
|
be_local_class(lv_obj,
|
|
|
|
1,
|
|
|
|
NULL,
|
|
|
|
be_nested_map(5,
|
|
|
|
( (struct bmapnode*) &(const bmapnode[]) {
|
|
|
|
{ be_nested_key("tostring", -1995258651, 8, 3), be_const_func(lvx_tostring) },
|
|
|
|
{ be_nested_key("member", 719708611, 6, -1), be_const_func(lvx_member) },
|
|
|
|
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
|
|
|
|
{ be_nested_key("init", 380752755, 4, 4), be_const_func(be_ntv_lv_obj_init) },
|
|
|
|
{ be_nested_key("_class", -1562820946, 6, -1), be_const_comptr(&lv_obj_class) },
|
|
|
|
})),
|
|
|
|
(be_nested_const_str("lv_obj", -37134147, 6))
|
|
|
|
);
|
|
|
|
/*******************************************************************/
|
2021-04-19 07:40:11 +01:00
|
|
|
|
2021-10-15 18:34:37 +01:00
|
|
|
/********************************************************************
|
|
|
|
** Solidified class: lv_group
|
|
|
|
********************************************************************/
|
|
|
|
be_local_class(lv_group,
|
|
|
|
1,
|
|
|
|
NULL,
|
|
|
|
be_nested_map(4,
|
|
|
|
( (struct bmapnode*) &(const bmapnode[]) {
|
|
|
|
{ be_nested_key("init", 380752755, 4, -1), be_const_func(be_ntv_lv_group_init) },
|
|
|
|
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) },
|
|
|
|
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
|
|
|
|
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lvx_member) },
|
|
|
|
})),
|
|
|
|
(be_nested_const_str("lv_group", -442928277, 8))
|
|
|
|
);
|
|
|
|
/*******************************************************************/
|
2021-04-19 07:40:11 +01:00
|
|
|
|
2021-10-15 18:34:37 +01:00
|
|
|
/********************************************************************
|
|
|
|
** Solidified class: lv_indev
|
|
|
|
********************************************************************/
|
|
|
|
be_local_class(lv_indev,
|
|
|
|
1,
|
|
|
|
NULL,
|
|
|
|
be_nested_map(4,
|
|
|
|
( (struct bmapnode*) &(const bmapnode[]) {
|
|
|
|
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lv0_init) },
|
|
|
|
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) },
|
|
|
|
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
|
|
|
|
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lvx_member) },
|
|
|
|
})),
|
|
|
|
(be_nested_const_str("lv_indev", 225602374, 8))
|
|
|
|
);
|
|
|
|
/*******************************************************************/
|
2021-04-19 07:40:11 +01:00
|
|
|
|
2021-10-23 14:08:33 +01:00
|
|
|
/********************************************************************
|
|
|
|
** Solidified class: lv_disp
|
|
|
|
********************************************************************/
|
|
|
|
be_local_class(lv_disp,
|
|
|
|
1,
|
|
|
|
NULL,
|
|
|
|
be_nested_map(4,
|
|
|
|
( (struct bmapnode*) &(const bmapnode[]) {
|
|
|
|
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lv0_init) },
|
|
|
|
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) },
|
|
|
|
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
|
|
|
|
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lvx_member) },
|
|
|
|
})),
|
|
|
|
(be_nested_const_str("lv_disp", 609712084, 8))
|
|
|
|
);
|
|
|
|
/*******************************************************************/
|
|
|
|
|
2021-10-15 18:34:37 +01:00
|
|
|
/********************************************************************
|
|
|
|
** Solidified class: lv_font
|
|
|
|
********************************************************************/
|
|
|
|
be_local_class(lv_font,
|
|
|
|
1,
|
|
|
|
NULL,
|
|
|
|
be_nested_map(3,
|
|
|
|
( (struct bmapnode*) &(const bmapnode[]) {
|
|
|
|
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lvbe_font_create) },
|
|
|
|
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) },
|
|
|
|
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
|
|
|
|
})),
|
|
|
|
(be_nested_const_str("lv_font", 1550958453, 7))
|
|
|
|
);
|
|
|
|
/*******************************************************************/
|
|
|
|
|
2021-10-23 14:08:33 +01:00
|
|
|
/********************************************************************
|
|
|
|
** Solidified class: lv_theme
|
|
|
|
********************************************************************/
|
|
|
|
be_local_class(lv_theme,
|
|
|
|
1,
|
|
|
|
NULL,
|
|
|
|
be_nested_map(3,
|
|
|
|
( (struct bmapnode*) &(const bmapnode[]) {
|
|
|
|
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lvbe_theme_create) },
|
|
|
|
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) },
|
|
|
|
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
|
|
|
|
})),
|
|
|
|
(be_nested_const_str("lv_theme", 1550958453, 7))
|
|
|
|
);
|
|
|
|
/*******************************************************************/
|
|
|
|
|
2021-10-15 18:34:37 +01:00
|
|
|
/********************************************************************
|
|
|
|
** Solidified class: lv_color
|
|
|
|
********************************************************************/
|
|
|
|
be_local_class(lv_color,
|
|
|
|
1,
|
|
|
|
NULL,
|
|
|
|
be_nested_map(4,
|
|
|
|
( (struct bmapnode*) &(const bmapnode[]) {
|
|
|
|
{ be_nested_key("toint", -681784387, 5, -1), be_const_func(lco_toint) },
|
|
|
|
{ be_nested_key("tostring", -1995258651, 8, 0), be_const_func(lco_tostring) },
|
|
|
|
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
|
|
|
|
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lco_init) },
|
|
|
|
})),
|
|
|
|
(be_nested_const_str("lv_color", 1419148319, 8))
|
|
|
|
);
|
|
|
|
/*******************************************************************/
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
|
|
for subtype, flv in lv.items():
|
|
|
|
# special version for widgets
|
|
|
|
if subtype in lv_widgets:
|
2021-10-26 20:58:21 +01:00
|
|
|
super_class = lv_widget_inheritance.get(subtype, "obj") # get superclass, default to lv_obj
|
2021-10-15 18:34:37 +01:00
|
|
|
print(f"""/********************************************************************
|
|
|
|
** Solidified class: lv_{subtype}
|
|
|
|
********************************************************************/
|
|
|
|
extern const bclass be_class_lv_obj;
|
|
|
|
be_local_class(lv_{subtype},
|
|
|
|
0,
|
2021-10-26 20:58:21 +01:00
|
|
|
&be_class_lv_{super_class},
|
2021-10-15 18:34:37 +01:00
|
|
|
be_nested_map(2,
|
|
|
|
( (struct bmapnode*) &(const bmapnode[]) {{
|
|
|
|
{{ be_nested_key("_class", -1562820946, 6, -1), be_const_comptr(&lv_{subtype}_class) }},
|
|
|
|
{{ be_nested_key("init", 380752755, 4, -1), be_const_func(be_ntv_lv_{subtype}_init) }},
|
|
|
|
}})),
|
|
|
|
(be_nested_const_str("lv_{subtype}", 1612829968, 6))
|
|
|
|
);
|
|
|
|
/*******************************************************************/
|
|
|
|
""")
|
|
|
|
# class definitions
|
|
|
|
print(f"""void be_load_lv_{subtype}_class(bvm *vm) {{
|
|
|
|
be_pushntvclass(vm, &be_class_lv_{subtype});
|
|
|
|
be_setglobal(vm, \"lv_{subtype}\");
|
|
|
|
be_pop(vm, 1);
|
|
|
|
}}
|
|
|
|
""")
|
2021-04-19 07:40:11 +01:00
|
|
|
|
|
|
|
print("""
|
|
|
|
#endif // USE_LVGL
|
|
|
|
""")
|
|
|
|
sys.stdout.close()
|
|
|
|
|
|
|
|
|
|
|
|
sys.stdout = open(lvgl_prefix + be_lv_lvgl_module, 'w')
|
|
|
|
print("/********************************************************************")
|
|
|
|
print(" * Generated code, don't edit")
|
|
|
|
print(" *******************************************************************/")
|
|
|
|
|
|
|
|
print("""/********************************************************************
|
|
|
|
* LVGL Module
|
|
|
|
*******************************************************************/
|
2021-04-28 18:30:19 +01:00
|
|
|
#include "be_constobj.h"
|
2021-04-19 07:40:11 +01:00
|
|
|
|
|
|
|
#ifdef USE_LVGL
|
|
|
|
|
|
|
|
#include "lvgl.h"
|
2021-05-20 18:34:51 +01:00
|
|
|
#include "be_lvgl.h"
|
2021-10-23 14:08:33 +01:00
|
|
|
#include "lv_theme_openhasp.h"
|
2021-04-19 07:40:11 +01:00
|
|
|
|
2021-05-19 08:53:20 +01:00
|
|
|
extern int lv0_member(bvm *vm); // resolve virtual members
|
|
|
|
|
2021-04-19 07:40:11 +01:00
|
|
|
extern int lv0_start(bvm *vm);
|
2021-05-07 10:51:22 +01:00
|
|
|
|
2021-05-07 16:24:57 +01:00
|
|
|
extern int lv0_register_button_encoder(bvm *vm); // add buttons with encoder logic
|
2021-05-07 10:51:22 +01:00
|
|
|
|
2021-04-19 07:40:11 +01:00
|
|
|
extern int lv0_load_montserrat_font(bvm *vm);
|
2021-04-27 18:05:23 +01:00
|
|
|
extern int lv0_load_seg7_font(bvm *vm);
|
2021-10-23 15:13:00 +01:00
|
|
|
extern int lv0_load_robotocondensed_latin1_font(bvm *vm);
|
2021-04-27 18:05:23 +01:00
|
|
|
extern int lv0_load_font(bvm *vm);
|
2021-05-12 10:16:10 +01:00
|
|
|
extern int lv0_load_freetype_font(bvm *vm);
|
2021-04-19 07:40:11 +01:00
|
|
|
|
2021-04-20 12:44:16 +01:00
|
|
|
extern int lv0_screenshot(bvm *vm);
|
2021-05-20 18:34:51 +01:00
|
|
|
|
|
|
|
static int lv_get_hor_res(void) {
|
|
|
|
return lv_disp_get_hor_res(lv_disp_get_default());
|
|
|
|
}
|
2021-07-12 21:53:31 +01:00
|
|
|
static int lv_get_ver_res(void) {
|
2021-05-20 18:34:51 +01:00
|
|
|
return lv_disp_get_ver_res(lv_disp_get_default());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* `lv` methods */
|
|
|
|
const lvbe_call_c_t lv_func[] = {
|
2021-07-12 21:53:31 +01:00
|
|
|
""")
|
|
|
|
|
|
|
|
func_out = {} # used to sort output
|
|
|
|
for f in lv0:
|
|
|
|
c_func_name = f[0]
|
|
|
|
c_ret_type = f[1]
|
|
|
|
c_argc = f[2]
|
|
|
|
if c_argc is not None: c_argc = "\"" + c_argc + "\""
|
|
|
|
orig_func_name = f[3]
|
|
|
|
be_name = f[4]
|
2021-10-15 18:34:37 +01:00
|
|
|
|
|
|
|
# if c_ret_type is an object, prefix with `lv.`
|
|
|
|
if len(c_ret_type) > 1: c_ret_type = "lv." + c_ret_type
|
|
|
|
|
2021-07-12 21:53:31 +01:00
|
|
|
func_out[be_name] = f" {{ \"{be_name}\", (void*) &{orig_func_name}, \"{c_ret_type}\", { c_argc if c_argc else 'nullptr'} }},"
|
|
|
|
|
|
|
|
for be_name in sorted(func_out):
|
|
|
|
print(func_out[be_name])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# // resolution
|
|
|
|
# { "get_hor_res", (void*) &lv_get_hor_res, "i", "" },
|
|
|
|
# { "get_ver_res", (void*) &lv_get_ver_res, "i", "" },
|
|
|
|
|
|
|
|
# // layers
|
|
|
|
# { "layer_sys", (void*) &lv_layer_sys, "lv_obj", "" },
|
|
|
|
# { "layer_top", (void*) &lv_layer_top, "lv_obj", "" },
|
|
|
|
|
|
|
|
# // screens
|
|
|
|
# { "scr_act", (void*) &lv_scr_act, "lv_obj", "" },
|
|
|
|
# { "scr_load", (void*) &lv_scr_load, "", "(lv_obj)" },
|
|
|
|
# { "scr_load_anim", (void*) &lv_scr_load_anim, "", "(lv_obj)iiib" },
|
|
|
|
print("""
|
2021-05-20 18:34:51 +01:00
|
|
|
};
|
|
|
|
const size_t lv_func_size = sizeof(lv_func) / sizeof(lv_func[0]);
|
|
|
|
|
2021-04-19 07:40:11 +01:00
|
|
|
""")
|
|
|
|
|
2021-05-19 08:53:20 +01:00
|
|
|
print("""
|
|
|
|
|
2021-05-28 22:13:19 +01:00
|
|
|
typedef struct be_constint_t {
|
2021-05-19 08:53:20 +01:00
|
|
|
const char * name;
|
|
|
|
int32_t value;
|
2021-05-28 22:13:19 +01:00
|
|
|
} be_constint_t;
|
2021-05-19 08:53:20 +01:00
|
|
|
|
2021-05-28 22:13:19 +01:00
|
|
|
const be_constint_t lv0_constants[] = {
|
2021-05-19 08:53:20 +01:00
|
|
|
""")
|
|
|
|
|
|
|
|
lv_module2 = {}
|
|
|
|
for k_v in lv_module:
|
|
|
|
(k,v) = k_v
|
|
|
|
if k is not None:
|
|
|
|
lv_module2[k] = v
|
|
|
|
|
2021-10-15 18:34:37 +01:00
|
|
|
# print the enums, symbols and functions
|
|
|
|
# Ex: { "ALIGN_BOTTOM_LEFT", LV_ALIGN_BOTTOM_LEFT },
|
|
|
|
#
|
|
|
|
# Encoding:
|
|
|
|
# 1. `COLOR_WHITE=0xFFFFFF` enum with explicit value
|
|
|
|
# 2. `LV_EVENT_ALL` enum with implicit value with same name resolved by C compiler
|
|
|
|
# 3. `$SYMBOL_OK="\xef\x80\x8c"` if starts with `$` then it's a string
|
|
|
|
# 4. `&seg7_font=lv0_load_seg7_font` if starts with `&` then it's a native function
|
|
|
|
#
|
|
|
|
# We need to sort ignoring the first char if it's not a letter
|
2021-05-19 08:53:20 +01:00
|
|
|
for k in sorted(lv_module2):
|
|
|
|
v = lv_module2[k]
|
2021-10-15 18:34:37 +01:00
|
|
|
# check the type of the value
|
|
|
|
# if first char is '"' then it's a string and prefix with '$'
|
|
|
|
# if first char is '&' then it's a function and prefix with '&'
|
|
|
|
# if no value, then it's an enum, prefix with `LV_`
|
|
|
|
# otherwise it's an int, leave if unchanged
|
2021-05-20 18:34:51 +01:00
|
|
|
if v is not None:
|
2021-10-15 18:34:37 +01:00
|
|
|
v_prefix = ""
|
|
|
|
if v[0] == '"': v_prefix = "$"
|
|
|
|
if v[0] == '&': v_prefix = "&"
|
|
|
|
print(f" {{ \"{v_prefix}{k}\", (int32_t) {v} }},")
|
2021-05-20 18:34:51 +01:00
|
|
|
else:
|
|
|
|
print(f" {{ \"{k}\", LV_{k} }},")
|
2021-05-19 08:53:20 +01:00
|
|
|
|
|
|
|
print("""
|
|
|
|
};
|
|
|
|
|
|
|
|
const size_t lv0_constants_size = sizeof(lv0_constants)/sizeof(lv0_constants[0]);
|
2021-04-19 07:40:11 +01:00
|
|
|
|
2021-10-15 18:34:37 +01:00
|
|
|
/* generated */
|
|
|
|
be_local_module(lv,
|
|
|
|
"lv",
|
|
|
|
be_nested_map(2,
|
|
|
|
( (struct bmapnode*) &(const bmapnode[]) {
|
|
|
|
{ be_nested_key("member", 719708611, 6, -1), be_const_func(lv0_member) },
|
|
|
|
{ be_nested_key("start", 1697318111, 5, 0), be_const_func(lv0_start) },
|
|
|
|
}))
|
|
|
|
);
|
2021-10-23 14:08:33 +01:00
|
|
|
BE_EXPORT_VARIABLE be_define_const_native_module(lv);
|
2021-04-19 07:40:11 +01:00
|
|
|
|
|
|
|
#endif // USE_LVGL
|
|
|
|
""")
|
|
|
|
|
|
|
|
print("/********************************************************************/")
|
|
|
|
sys.stdout.close()
|
|
|
|
|