QR-Code extended by lv_qrcode_get_text

This commit is contained in:
marsman7 2024-03-17 14:33:50 +01:00
parent 4d25e77ea6
commit 6a819f58c7
3 changed files with 32 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
}