diff --git a/docs/config_builder.py b/docs/config_builder.py index 7ed6d71fad..8411bf644e 100644 --- a/docs/config_builder.py +++ b/docs/config_builder.py @@ -12,21 +12,32 @@ import sys import re base_path = os.path.dirname(__file__) -dst_config = os.path.join(base_path, 'lv_conf.h') +dest_config = os.path.join(base_path, 'lv_conf.h') src_config = os.path.abspath(os.path.join( base_path, '..', 'lv_conf_template.h' )) -disabled_option_re = re.compile(r'^\s*#define\s+\w+\s+(\b0\b)') +disabled_option_re = re.compile(r'^\s*#define\s+(LV_(?:USE|FONT)_\w+)\s+(\b0\b)') + +leave_disabled_list = [ + 'LV_USE_PROFILER', + 'LV_FONT_SIMSUN_14_CJK', + 'LV_FONT_SIMSUN_16_CJK', + 'LV_USE_DRAW_ARM2D_SYNC', + 'LV_USE_NATIVE_HELIUM_ASM', +] +# Note: The 2 LV_FONT_SIMSUN_... fonts have been deprecated in favor of +# LV_FONT_SOURCE_HAN_SANS_SC_14_CJK and LV_FONT_SOURCE_HAN_SANS_SC_16_CJK. -def run(c_path=None): - global dst_config +def run(output_cfg_path=None): + global dest_config + enable_content_macro_processed = False os.chdir(base_path) - if c_path is not None: - dst_config = c_path + if output_cfg_path is not None: + dest_config = output_cfg_path with open(src_config, 'r') as f: data = f.read() @@ -34,39 +45,34 @@ def run(c_path=None): lines = data.split('\n') for i, line in enumerate(lines): - if 'LV_USE_PROFILER' in line: - continue - - # These 2 fonts have been deprecated in favor of - # LV_FONT_SOURCE_HAN_SANS_SC_14_CJK and - # LV_FONT_SOURCE_HAN_SANS_SC_16_CJK. - if 'LV_FONT_SIMSUN_14_CJK' in line: - continue - - if 'LV_FONT_SIMSUN_16_CJK' in line: - continue - - if 'LV_USE' in line or ('LV_FONT' in line and '#define' in line): + if not enable_content_macro_processed: + if line.startswith('#if 0'): + line = line.replace('#if 0', '#if 1') + lines[i] = line + enable_content_macro_processed = True + else: match = disabled_option_re.search(line) if match: - # Replace '0' with '1' without altering any other part of line. - # Set `j` to index where '0' was found. - j = match.regs[1][0] - # Surgically insert '1' in place of '0'. - lines[i] = line[:j] + '1' + line[j + 1:] - elif line.startswith('#if 0'): - line = line.replace('#if 0', '#if 1') - lines[i] = line + # Except for these... + if match[1] in leave_disabled_list: + continue + else: + # ...replace '0' with '1' without altering any other part of line. + # Set `j` to index where '0' was found. + j = match.regs[2][0] + # Surgically insert '1' in place of '0'. Strings are immutable. + line = line[:j] + '1' + line[j + 1:] + lines[i] = line data = '\n'.join(lines) - with open(dst_config, 'w') as f: + with open(dest_config, 'w') as f: f.write(data) def cleanup(): - if os.path.exists(dst_config): - os.remove(dst_config) + if os.path.exists(dest_config): + os.remove(dest_config) if __name__ == '__main__': diff --git a/docs/src/details/auxiliary-modules/observer/observer.rst b/docs/src/details/auxiliary-modules/observer/observer.rst index b4ed5ce62c..2289569052 100644 --- a/docs/src/details/auxiliary-modules/observer/observer.rst +++ b/docs/src/details/auxiliary-modules/observer/observer.rst @@ -17,7 +17,7 @@ This implementation consists of: :Subjects: (in global memory or heap) are "logic packages", each containing the value being "observed" and its type (integer (``int32_t``), a string, a - pointer, an :cpp:type:`lv_color_t`, a :cpp_type:`float`, or a group); + pointer, an :cpp:type:`lv_color_t`, a ``float``, or a group); :Observers: (zero or more per Subject, always dynamically-allocated) are always attached to exactly one Subject, and provide user-defined notifications @@ -579,7 +579,7 @@ Increments the subject's value by `step`, clamped between `min` and `max`. For example: -:cpp:expr:`lv_obj_add_subject_increment_event(button1, subject1, LV_EVENT_CLICKED, 5, -10, 80);` +:cpp:expr:`lv_obj_add_subject_increment_event(button1, subject1, LV_EVENT_CLICKED, 5, -10, 80)` This will increment `subject1` by 5 when `button1` is clicked. The resulting value will be constrained to the range -10 to 80. diff --git a/docs/src/details/auxiliary-modules/translation.rst b/docs/src/details/auxiliary-modules/translation.rst index bf640fdd53..490c74ebb5 100644 --- a/docs/src/details/auxiliary-modules/translation.rst +++ b/docs/src/details/auxiliary-modules/translation.rst @@ -13,15 +13,19 @@ LVGL supports two ways of handling translations: - ``lv_translation``: A simpler yet more flexible solution that allows adding translations statically or dynamically. This is the method documented here. + + Add Translations **************** + Static Translations ------------------- If most translations are known at compile time, they can be defined using string arrays: .. code-block:: c + static const char * languages[] = {"en", "de", "es", NULL}; static const char * tags[] = {"tiger", "lion", "rabbit", "elephant", NULL}; static const char * translations[] = { @@ -35,6 +39,7 @@ If most translations are known at compile time, they can be defined using string This method uses only a little extra RAM, as only the pointers to the strings are stored. + Dynamic Translations -------------------- @@ -42,6 +47,8 @@ If translations are only available at runtime (e.g., from files, serial ports, o This approach involves memory allocation. See the example at the bottom of this page for reference. + + Select a Language ***************** @@ -51,6 +58,8 @@ Once translations are registered, use: to set the current language. The parameter must match one of the language names provided during registration. + + Translate Strings ***************** @@ -62,9 +71,11 @@ To retrieve a translation for a given tag, use: These return a translated string which can be used with widgets: .. code-block:: c + lv_label_set_text(label, lv_tr("settings")); lv_dropdown_set_options(dd, lv_tr("color_list")); + Fallbacks --------- @@ -75,6 +86,8 @@ If the tag is not found at all, the tag itself will be used as a fallback as wel .. _lv_translation_example: + + Example ******* @@ -82,5 +95,7 @@ Example .. _lv_translation_api: + + API *** diff --git a/docs/src/details/auxiliary-modules/xml/api.rst b/docs/src/details/auxiliary-modules/xml/api.rst index 527c4b4d51..b8bc45f27f 100644 --- a/docs/src/details/auxiliary-modules/xml/api.rst +++ b/docs/src/details/auxiliary-modules/xml/api.rst @@ -21,7 +21,7 @@ Overview While Widgets can have complex ``set``/``get`` APIs, Components are very simple. When their XML is converted to a C file, only a ``create`` function is generated, -where all the ````s are arguments. For example: +where all the ````\ s are arguments. For example: .. code-block:: xml @@ -43,7 +43,7 @@ used to modify any widget in the component, but no dedicated API functions are g Referencing properties ---------------------- -````s are simply forwarded to widget or component APIs. +````\ s are simply forwarded to widget or component APIs. For example, if a component has ````, it can be used in a label as ````. @@ -109,7 +109,7 @@ Parameters ---------- Some properties take multiple parameters. For example: -:cpp:expr:`lv_label_set_bind_text(label, subject, "%d °C");` +:cpp:expr:`lv_label_set_bind_text(label, subject, "%d °C")` It's described as: @@ -168,15 +168,15 @@ Enum values are ignored in export; the names are used and resolved by the compil XML parsers must handle mapping enum names to C enums. --------- +--------- Also exclusive to Widgets, elements define sub-widgets or internal structures (e.g., chart series, dropdown list, tab views). They support ```` and ````: -- ````s are required and used for creation. -- ````s are optional and mapped to setters. +- ````\ s are required and used for creation. +- ````\ s are optional and mapped to setters. Elements are referenced as ```` in views. @@ -290,7 +290,7 @@ Generates: void my_widget_set_item_color(lv_obj_t * parent, int32_t index, lv_color_t color); access="custom" -~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~ Used to describe any custom API functions with a custom name. "custom" elements can have only arguments and no `type` so they are pure setters. diff --git a/docs/src/details/auxiliary-modules/xml/events.rst b/docs/src/details/auxiliary-modules/xml/events.rst index 4053660b41..77aa8f13a1 100644 --- a/docs/src/details/auxiliary-modules/xml/events.rst +++ b/docs/src/details/auxiliary-modules/xml/events.rst @@ -35,7 +35,7 @@ User-defined functions can be called like this: When the XML is loaded at runtime, the callback name needs to be mapped to a function using -:cpp:expr:`lv_xml_register_event_cb("my_callback_1", an_event_handler);`. +:cpp:expr:`lv_xml_register_event_cb("my_callback_1", an_event_handler)`. The callback should follow the standard LVGL event callback signature: ``void an_event_handler(lv_event_t * e);`` diff --git a/docs/src/details/auxiliary-modules/xml/index.rst b/docs/src/details/auxiliary-modules/xml/index.rst index 91234c253e..64aa44fae5 100644 --- a/docs/src/details/auxiliary-modules/xml/index.rst +++ b/docs/src/details/auxiliary-modules/xml/index.rst @@ -28,6 +28,5 @@ XML - Declarative UI subjects animations translation - license - + test license diff --git a/docs/src/details/auxiliary-modules/xml/screens.rst b/docs/src/details/auxiliary-modules/xml/screens.rst index 4c2b4b5fd7..76de2dd59d 100644 --- a/docs/src/details/auxiliary-modules/xml/screens.rst +++ b/docs/src/details/auxiliary-modules/xml/screens.rst @@ -24,6 +24,7 @@ It's also possible to define ```` which will make the screen created automatically. + Usage ***** @@ -60,6 +61,9 @@ This example illustrates a screen in XML: + + + Screen Load and Create events ***************************** diff --git a/docs/src/details/auxiliary-modules/xml/styles.rst b/docs/src/details/auxiliary-modules/xml/styles.rst index 0b113a2a1b..07f8ef666c 100644 --- a/docs/src/details/auxiliary-modules/xml/styles.rst +++ b/docs/src/details/auxiliary-modules/xml/styles.rst @@ -22,19 +22,19 @@ In the ```` section, styles and their properties can be defined like thi border_width="2px" border_color="0xff0000"/> -Styles can be referenced like this in the ````: +Styles can be referenced like this in the ````\ : .. code-block:: xml