fix(docs): fix most sphinx warnings (#6916)
Co-authored-by: Kevin Schlosser <kdschlosser@users.noreply.github.com> Co-authored-by: Liam <30486941+liamHowatt@users.noreply.github.com>
This commit is contained in:
@@ -84,7 +84,7 @@ You can use :cpp:func:`lv_file_explorer_get_cur_path` to get the current path
|
||||
and :cpp:func:`lv_file_explorer_get_sel_fn` to get the name of the currently
|
||||
selected file in the event processing function. For example:
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
static void file_explorer_event_handler(lv_event_t * e)
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ Enable :c:macro:`LV_USE_FRAGMENT` in ``lv_conf.h``.
|
||||
Create Fragment Class
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
struct sample_fragment_t {
|
||||
/* IMPORTANT: don't miss this part */
|
||||
@@ -53,7 +53,7 @@ Create Fragment Class
|
||||
Use ``lv_fragment_manager``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
/* Create fragment instance, and objects will be added to container */
|
||||
lv_fragment_manager_t *manager = lv_fragment_manager_create(container, NULL);
|
||||
@@ -63,7 +63,7 @@ Use ``lv_fragment_manager``
|
||||
Fragment Based Navigation
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
/* Add one instance into manager stack. View object of current fragment will be destroyed,
|
||||
* but instances created in class constructor will be kept.
|
||||
|
||||
@@ -13,7 +13,8 @@ Normally, an environment where :ref:`lv_keyboard` can
|
||||
run can also run ``lv_ime_pinyin``. There are two main influencing
|
||||
factors: the size of the font file and the size of the dictionary.
|
||||
|
||||
.. _ime_pinyin_example:
|
||||
|
||||
.. _ime_pinyin_usage:
|
||||
|
||||
Usage
|
||||
-----
|
||||
@@ -37,6 +38,7 @@ custom fonts and thesaurus.
|
||||
In the process of using the Pinyin input method plug-in, you can change
|
||||
the keyboard and dictionary at any time.
|
||||
|
||||
|
||||
Custom dictionary
|
||||
-----------------
|
||||
|
||||
@@ -62,7 +64,7 @@ to learn about the Hanyu Pinyin syllables and the syllable table.
|
||||
|
||||
Then, write your own dictionary according to the following format:
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
lv_100ask_pinyin_dict_t your_pinyin_dict[] = {
|
||||
{ "a", "啊阿呵吖" },
|
||||
@@ -79,6 +81,7 @@ Then, write your own dictionary according to the following format:
|
||||
**The last item** must end with ``{null, null}``, or it will not work
|
||||
properly.
|
||||
|
||||
|
||||
.. _ime_pinyin_apply_new_dictionary:
|
||||
|
||||
Apply new dictionary
|
||||
@@ -87,11 +90,12 @@ Apply new dictionary
|
||||
After writing a dictionary according to the above dictionary format, you
|
||||
only need to call this function to set up and use your dictionary:
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
lv_obj_t * pinyin_ime = lv_100ask_pinyin_ime_create(lv_screen_active());
|
||||
lv_100ask_pinyin_ime_set_dict(pinyin_ime, your_pinyin_dict);
|
||||
|
||||
|
||||
.. _ime_pinyin_modes:
|
||||
|
||||
Modes
|
||||
@@ -108,6 +112,7 @@ The ``TEXT`` modes' layout contains buttons to change mode.
|
||||
To set the mode manually, use :cpp:expr:`lv_ime_pinyin_set_mode(pinyin_ime, mode)`.
|
||||
The default mode is :cpp:enumerator:`LV_IME_PINYIN_MODE_K26`.
|
||||
|
||||
|
||||
.. _ime_pinyin_example:
|
||||
|
||||
Example
|
||||
|
||||
@@ -31,7 +31,7 @@ Set :c:macro:`LV_USE_OBJ_ID_BUILTIN` to `0` in ``lv_conf.h``.
|
||||
|
||||
Below APIs needed to be implemented and linked to lvgl.
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
void lv_obj_set_id(lv_obj_t * obj, void * id);
|
||||
void lv_obj_assign_id(const lv_obj_class_t * class_p, lv_obj_t * obj);
|
||||
@@ -51,7 +51,7 @@ currently being constructed.
|
||||
Dump obj tree
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Use API :cpp:expr:`lv_obj_dump_tree(lv_obj_t * obj, int depth)` to dump the object tree.
|
||||
Use API ``lv_obj_dump_tree(lv_obj_t * obj, int depth)`` to dump the object tree.
|
||||
It will walk through all children and print the object ID together with object address.
|
||||
|
||||
This is useful to debug UI crash. From log we can rebuilt UI the moment before crash.
|
||||
@@ -62,5 +62,5 @@ From the dump log we can clearly see that the obj does not exist.
|
||||
Find child by ID
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Use API :cpp:expr:`lv_obj_t * lv_obj_get_child_by_id(const lv_obj_t * obj, void * id);` to find a child by ID.
|
||||
Use API ``lv_obj_t * lv_obj_get_child_by_id(const lv_obj_t * obj, void * id)`` to find a child by ID.
|
||||
It will walk through all children and return the first child with the given ID.
|
||||
|
||||
@@ -18,7 +18,7 @@ Two APIs are provided to get/set widget properties. It can be enabled by setting
|
||||
|
||||
Set :c:macro:`LV_USE_OBJ_PROPERTY_NAME` to `1` in order to use property name instead of ID.
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
typedef struct {
|
||||
lv_prop_id_t id;
|
||||
@@ -75,7 +75,7 @@ additional code to convert values from dict, table etc to a C struct before sett
|
||||
Another possible use case is to ease of creating UI from lots of code. For example, you can gather
|
||||
all properties to an array now and set properties with a for loop.
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
lv_property_t props[] = {
|
||||
{ .id = LV_PROPERTY_IMAGE_SRC, .ptr = &img_demo_widgets_avatar, },
|
||||
|
||||
@@ -19,7 +19,7 @@ It consists of:
|
||||
|
||||
A typical use case looks like this:
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
//It's a global variable
|
||||
lv_subject_t my_subject;
|
||||
@@ -80,14 +80,14 @@ Subject initialization
|
||||
|
||||
Subjects have to be static or global :cpp:type:`lv_subject_t` type variables.
|
||||
|
||||
To initialize a subject use :cpp:expr:`lv_subject_init_<type>(&subject, params, init_value)`.
|
||||
To initialize a subject use ``lv_subject_init_<type>(&subject, params, init_value)``.
|
||||
The following initializations exist for types:
|
||||
|
||||
- **Integer** :cpp:expr:`void lv_subject_init_int(lv_subject_t * subject, int32_t value)`
|
||||
- **String** :cpp:expr:`void lv_subject_init_string(lv_subject_t * subject, char * buf, char * prev_buf, size_t size, const char * value)`
|
||||
- **Pointer** :cpp:expr:`void lv_subject_init_pointer(lv_subject_t * subject, void * value)`
|
||||
- **Color** :cpp:expr:`void lv_subject_init_color(lv_subject_t * subject, lv_color_t color)`
|
||||
- **Group** :cpp:expr:`void lv_subject_init_group(lv_subject_t * subject, lv_subject_t * list[], uint32_t list_len)`
|
||||
- **Integer** ``void lv_subject_init_int(lv_subject_t * subject, int32_t value)``
|
||||
- **String** ``void lv_subject_init_string(lv_subject_t * subject, char * buf, char * prev_buf, size_t size, const char * value)``
|
||||
- **Pointer** ``void lv_subject_init_pointer(lv_subject_t * subject, void * value)``
|
||||
- **Color** ``void lv_subject_init_color(lv_subject_t * subject, lv_color_t color)``
|
||||
- **Group** ``void lv_subject_init_group(lv_subject_t * subject, lv_subject_t * list[], uint32_t list_len)``
|
||||
|
||||
|
||||
Set subject value
|
||||
@@ -95,10 +95,10 @@ Set subject value
|
||||
|
||||
The following functions can be used to set a subject's value:
|
||||
|
||||
- **Integer** :cpp:expr:`void lv_subject_set_int(lv_subject_t * subject, int32_t value)`
|
||||
- **String** :cpp:expr:`void lv_subject_copy_string(lv_subject_t * subject, char * buf)`
|
||||
- **Pointer** :cpp:expr:`void lv_subject_set_pointer(lv_subject_t * subject, void * ptr)`
|
||||
- **Color** :cpp:expr:`void lv_subject_set_color(lv_subject_t * subject, lv_color_t color)`
|
||||
- **Integer** ``void lv_subject_set_int(lv_subject_t * subject, int32_t value)``
|
||||
- **String** ``void lv_subject_copy_string(lv_subject_t * subject, char * buf)``
|
||||
- **Pointer** ``void lv_subject_set_pointer(lv_subject_t * subject, void * ptr)``
|
||||
- **Color** ``void lv_subject_set_color(lv_subject_t * subject, lv_color_t color)``
|
||||
|
||||
Get subject's value
|
||||
-------------------
|
||||
@@ -106,10 +106,10 @@ Get subject's value
|
||||
The following functions can be used to get a subject's value:
|
||||
|
||||
|
||||
- **Integer** :cpp:expr:`int32_t lv_subject_get_int(lv_subject_t * subject)`
|
||||
- **String** :cpp:expr:`const char * lv_subject_get_string(lv_subject_t * subject)`
|
||||
- **Pointer** :cpp:expr:`const void * lv_subject_get_pointer(lv_subject_t * subject)`
|
||||
- **Color** :cpp:expr:`lv_color_t lv_subject_get_color(lv_subject_t * subject)`
|
||||
- **Integer** ``int32_t lv_subject_get_int(lv_subject_t * subject)``
|
||||
- **String** ``const char * lv_subject_get_string(lv_subject_t * subject)``
|
||||
- **Pointer** ``const void * lv_subject_get_pointer(lv_subject_t * subject)``
|
||||
- **Color** ``lv_color_t lv_subject_get_color(lv_subject_t * subject)``
|
||||
|
||||
|
||||
Get subject's previous value
|
||||
@@ -118,10 +118,10 @@ Get subject's previous value
|
||||
The following functions can be used to get a subject's previous value:
|
||||
|
||||
|
||||
- **Integer** :cpp:expr:`int32_t lv_subject_get_previous_int(lv_subject_t * subject)`
|
||||
- **String** :cpp:expr:`const char * lv_subject_get_previous_string(lv_subject_t * subject)`
|
||||
- **Pointer** :cpp:expr:`const void * lv_subject_get_previous_pointer(lv_subject_t * subject)`
|
||||
- **Color** :cpp:expr:`lv_color_t lv_subject_get_previous_color(lv_subject_t * subject)`
|
||||
- **Integer** ``int32_t lv_subject_get_previous_int(lv_subject_t * subject)``
|
||||
- **String** ``const char * lv_subject_get_previous_string(lv_subject_t * subject)``
|
||||
- **Pointer** ``const void * lv_subject_get_previous_pointer(lv_subject_t * subject)``
|
||||
- **Color** ``lv_color_t lv_subject_get_previous_color(lv_subject_t * subject)``
|
||||
|
||||
.. _observer_observer:
|
||||
|
||||
@@ -133,14 +133,14 @@ Subscribe to a subject
|
||||
|
||||
To subscribe to a subject the following function can be used:
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
lv_observer_t * observer = lv_subject_add_observer(&some_subject, some_observer_cb, user_data);
|
||||
|
||||
|
||||
Where the observer callback should look like this:
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
static void some_observer_cb(lv_observer_t * observer, lv_subject_t * subject)
|
||||
{
|
||||
@@ -153,14 +153,14 @@ In this case when widget is deleted, it will automatically unsubscribe from the
|
||||
|
||||
In the observer callback :cpp:expr:`lv_observer_get_target(observer)` can be used to get the saved widget.
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
lv_observer_t * observer = lv_subject_add_observer_obj(&some_subject, some_observer_cb, obj, user_data);
|
||||
|
||||
|
||||
In more generic case any pointer can be saved a target:
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
lv_observer_t * observer = lv_subject_add_observer_with_target(&some_subject, some_observer_cb, some_pointer, user_data);
|
||||
|
||||
@@ -169,16 +169,16 @@ In more generic case any pointer can be saved a target:
|
||||
Unsubscribe from a subject
|
||||
--------------------------
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
//`observer` is the return value of `lv_subject_add_observer*`
|
||||
/* `observer` is the return value of `lv_subject_add_observer*` */
|
||||
lv_observer_remove(observer);
|
||||
|
||||
To unsubscribe a widget from a given or all subject use:
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
lv_obj_remove_from_subject(obj, subject); //`subject` can be NULL to unsubcribe from all
|
||||
lv_obj_remove_from_subject(obj, subject); /* `subject` can be NULL to unsubcribe from all */
|
||||
|
||||
.. _observer_subject_groups:
|
||||
|
||||
@@ -199,7 +199,8 @@ and it needs to know all 3 parameters to compose its text.
|
||||
To handle this you can create an array from some existing subjects and pass
|
||||
this array as a parameter when you initialize a subject with group type.
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
static lv_subject_t * subject_list[3] = {&subject_1, &subject_2, &subject_3};
|
||||
lv_subject_init_group(&subject_all, subject_list, 3); /*The last parameter is the number of elements*/
|
||||
|
||||
@@ -208,7 +209,7 @@ The trick is that when any element of the group is notified the subject group wi
|
||||
|
||||
The above Voltage/Current measurement example looks like this in the practice:
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
lv_obj_t * label = lv_label_create(lv_screen_active());
|
||||
|
||||
@@ -241,6 +242,7 @@ The above Voltage/Current measurement example looks like this in the practice:
|
||||
lv_label_set_text_fmt(label, "%s: %d %s", mode ? "Current" : "Voltage", value, unit);
|
||||
}
|
||||
|
||||
|
||||
.. _observer_widget_binding:
|
||||
|
||||
Widget binding
|
||||
@@ -251,31 +253,31 @@ Base object
|
||||
|
||||
Set an object flag if an integer subject's value is equal to a reference value, clear the flag otherwise
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
observer = lv_obj_bind_flag_if_eq(obj, &subject, LV_OBJ_FLAG_*, ref_value);
|
||||
|
||||
Set an object flag if an integer subject's value is not equal to a reference value, clear the flag otherwise
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
observer = lv_obj_bind_flag_if_not_eq(obj, &subject, LV_OBJ_FLAG_*, ref_value);
|
||||
|
||||
Set an object state if an integer subject's value is equal to a reference value, clear the flag otherwise
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
observer = lv_obj_bind_state_if_eq(obj, &subject, LV_STATE_*, ref_value);
|
||||
|
||||
Set an object state if an integer subject's value is not equal to a reference value, clear the flag otherwise
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
observer = lv_obj_bind_state_if_not_eq(obj, &subject, LV_STATE_*, ref_value);
|
||||
|
||||
Set an integer subject to 1 when an object is checked and set it 0 when unchecked.
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
observer = lv_obj_bind_checked(obj, &subject);
|
||||
|
||||
@@ -286,7 +288,7 @@ Bind an integer, string, or pointer (pointing to a string) subject to a label.
|
||||
An optional format string can be added with 1 format specifier (e.g. ``"%d °C"``)
|
||||
If the format string is ``NULL`` the value will be used directly. In this case on string and pointer type subjects can be used.
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
observer = lv_label_bind_text(obj, &subject, format_string);
|
||||
|
||||
@@ -296,7 +298,7 @@ Arc
|
||||
|
||||
Bind an integer subject to an arc's value.
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
observer = lv_arc_bind_value(obj, &subject);
|
||||
|
||||
@@ -305,7 +307,7 @@ Slider
|
||||
|
||||
Bind an integer subject to a slider's value
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
observer = lv_slider_bind_value(obj, &subject);
|
||||
|
||||
@@ -314,7 +316,7 @@ Roller
|
||||
|
||||
Bind an integer subject to a roller's value
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
observer = lv_roller_bind_value(obj, &subject);
|
||||
|
||||
@@ -323,7 +325,7 @@ Drop-down
|
||||
---------
|
||||
Bind an integer subject to a drop-down's value
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
observer = lv_dropdown_bind_value(obj, &subject);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ to invalidate cache by :cpp:func:`lv_image_cache_drop` before destroy the draw b
|
||||
|
||||
Below code snippet explains usage of this API.
|
||||
|
||||
.. code:: c
|
||||
.. code-block:: c
|
||||
|
||||
void update_snapshot(lv_obj_t * obj, lv_obj_t * img_snapshot)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user