diff --git a/docs/src/details/auxiliary-modules/observer/observer.rst b/docs/src/details/auxiliary-modules/observer/observer.rst index 064a1ff07d..dff76c7ac9 100644 --- a/docs/src/details/auxiliary-modules/observer/observer.rst +++ b/docs/src/details/auxiliary-modules/observer/observer.rst @@ -456,7 +456,7 @@ Subject's value to be set to ``1`` or ``0`` respectively. Specific Widget Types ~~~~~~~~~~~~~~~~~~~~~ -To learn how to bind subjects to Arcs, Labels, Slider, etc. visit the "Data binding" +To learn how to bind subjects to Arcs, Labels, Sliders, etc. visit the "Data binding" section of the given widget's documentation. For example: :ref:`Data binding for lv_label `. Change Subject on Event diff --git a/docs/src/details/widgets/label.rst b/docs/src/details/widgets/label.rst index 8442935ff5..77378ae6f0 100644 --- a/docs/src/details/widgets/label.rst +++ b/docs/src/details/widgets/label.rst @@ -197,7 +197,7 @@ To get familiar with observers, subjects, and data bindings in general visit the :ref:`Observer ` page. This method of subscribing to a Subject affects a Label Widget's -``text``. The Subject can be an STRING, POINTER or INTEGER type. +``text``. The Subject can be a STRING, POINTER, INTEGER, or FLOAT type. When the subscription occurs, and each time the Subject's value is changed thereafter, the Subject's value is used to update the Label's text as follows: diff --git a/src/widgets/label/lv_label.h b/src/widgets/label/lv_label.h index 54ccf89c97..ea0382d522 100644 --- a/src/widgets/label/lv_label.h +++ b/src/widgets/label/lv_label.h @@ -236,9 +236,8 @@ bool lv_label_get_recolor(const lv_obj_t * obj); * @param fmt optional printf-like format string with 1 format specifier (e.g. "%d °C") * or NULL to bind to the value directly. * @return pointer to newly-created Observer - * @note `fmt == NULL` can be used only with string and pointer Subjects. - * @note If Subject is a pointer and `fmt == NULL`, pointer must point - * to a `\0` terminated string. + * @note If `fmt == NULL` strings and pointers (`\0` terminated string) will be shown + * as text as they are, integers as %d, floats as %0.1f */ lv_observer_t * lv_label_bind_text(lv_obj_t * obj, lv_subject_t * subject, const char * fmt); #endif diff --git a/src/widgets/scale/lv_scale.c b/src/widgets/scale/lv_scale.c index 5bc400d403..fcb2456eb3 100644 --- a/src/widgets/scale/lv_scale.c +++ b/src/widgets/scale/lv_scale.c @@ -528,7 +528,8 @@ int32_t lv_scale_get_range_max_value(lv_obj_t * obj) lv_observer_t * lv_scale_bind_section_min_value(lv_obj_t * obj, lv_scale_section_t * section, lv_subject_t * subject) { LV_ASSERT_NULL(subject); - LV_ASSERT_NULL(obj); + LV_ASSERT_OBJ(obj, MY_CLASS); + LV_ASSERT_NULL(section); if(subject->type != LV_SUBJECT_TYPE_INT) { LV_LOG_WARN("Incompatible subject type: %d", subject->type); @@ -543,7 +544,8 @@ lv_observer_t * lv_scale_bind_section_min_value(lv_obj_t * obj, lv_scale_section lv_observer_t * lv_scale_bind_section_max_value(lv_obj_t * obj, lv_scale_section_t * section, lv_subject_t * subject) { LV_ASSERT_NULL(subject); - LV_ASSERT_NULL(obj); + LV_ASSERT_OBJ(obj, MY_CLASS); + LV_ASSERT_NULL(section); if(subject->type != LV_SUBJECT_TYPE_INT) { LV_LOG_WARN("Incompatible subject type: %d", subject->type); diff --git a/src/widgets/slider/lv_slider.h b/src/widgets/slider/lv_slider.h index dee05ceb00..5fb0120b0b 100644 --- a/src/widgets/slider/lv_slider.h +++ b/src/widgets/slider/lv_slider.h @@ -186,7 +186,7 @@ bool lv_slider_is_symmetrical(lv_obj_t * obj); #if LV_USE_OBSERVER /** - * Bind an integer Subject to a Slider's value. + * Bind an integer or float Subject to a Slider's value. * @param obj pointer to Slider * @param subject pointer to Subject * @return pointer to newly-created Observer diff --git a/src/widgets/span/lv_span.c b/src/widgets/span/lv_span.c index 554ac3f7b2..f9d4c311ef 100644 --- a/src/widgets/span/lv_span.c +++ b/src/widgets/span/lv_span.c @@ -49,6 +49,7 @@ typedef struct { void * element; /**< span of a span group*/ const char * fmt; } bind_element_string_t; + /********************** * STATIC PROTOTYPES **********************/ diff --git a/src/widgets/span/lv_span.h b/src/widgets/span/lv_span.h index 8e37b09087..cf20dd05c1 100644 --- a/src/widgets/span/lv_span.h +++ b/src/widgets/span/lv_span.h @@ -345,7 +345,6 @@ void lv_spangroup_refresh(lv_obj_t * obj); * @param fmt optional printf-like format string with 1 format specifier (e.g. "%d °C") * or NULL to bind to the value directly. * @return pointer to newly-created Observer - * @note `fmt == NULL` can be used only with string and pointer Subjects. * @note If `fmt == NULL` strings and pointers (`\0` terminated string) will be shown * as text as they are, integers as %d, floats as %0.1f */