diff --git a/lib/lv_lib_qrcode/lv_qrcode.c b/lib/lv_lib_qrcode/lv_qrcode.c index 430360a4..54fe4b1c 100644 --- a/lib/lv_lib_qrcode/lv_qrcode.c +++ b/lib/lv_lib_qrcode/lv_qrcode.c @@ -271,6 +271,20 @@ lv_res_t lv_qrcode_set_text_static(lv_obj_t * qrcode, const void * text) return lv_qrcode_update(qrcode, text, strlen(text)); } +/** + * Get the text of a qrcode + * @param qrcode pointer to a qrcode object + * @return the text of the qrcode + */ +char * lv_qrcode_get_text(const lv_obj_t * qrcode) +{ + LV_ASSERT_OBJ(qrcode, LV_OBJX_NAME); + + lv_qrcode_ext_t * ext = lv_obj_get_ext_attr(qrcode); + + return ext->text; +} + /** * Set the data of a QR code object * @param qrcode pointer to aQ code object diff --git a/lib/lv_lib_qrcode/lv_qrcode.h b/lib/lv_lib_qrcode/lv_qrcode.h index dd84db3c..a9bdc107 100644 --- a/lib/lv_lib_qrcode/lv_qrcode.h +++ b/lib/lv_lib_qrcode/lv_qrcode.h @@ -84,6 +84,13 @@ lv_res_t lv_qrcode_set_text(lv_obj_t * qrcode, const void * text); */ lv_res_t lv_qrcode_set_text_static(lv_obj_t * qrcode, const void * text); +/** + * Get the text of a qrcode + * @param qrcode pointer to a qrcode object + * @return the text of the qrcode + */ +char * lv_qrcode_get_text(const lv_obj_t * qrcode); + /** * Set the data of a QR code object * @param qrcode pointer to QR code object diff --git a/src/hasp/hasp_attribute_helper.h b/src/hasp/hasp_attribute_helper.h index a82832a7..888b691c 100644 --- a/src/hasp/hasp_attribute_helper.h +++ b/src/hasp/hasp_attribute_helper.h @@ -610,6 +610,17 @@ static inline void my_btn_set_text(lv_obj_t* obj, const char* value) // OK - lvgl does not return a const char * static const char* my_qrcode_get_text(const lv_obj_t* obj) { + if(!obj) { + LOG_WARNING(TAG_ATTR, F("QR-code not defined")); + return NULL; + } + + if(obj) { + if(obj_check_type(obj, LV_HASP_QRCODE)) return lv_qrcode_get_text(obj); + } else { + LOG_WARNING(TAG_ATTR, F("my_qrcode_get_text NULL Pointer encountered")); + } + return NULL; }