From a7338085ec52a5cdb297823886468f7b8bf4b8cb Mon Sep 17 00:00:00 2001 From: manison Date: Thu, 28 Feb 2019 09:07:07 +0100 Subject: [PATCH 1/6] mbox: introduce lv_mbox_get_btnm API --- lv_objx/lv_mbox.c | 12 ++++++++++++ lv_objx/lv_mbox.h | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/lv_objx/lv_mbox.c b/lv_objx/lv_mbox.c index adaf4ad42..4fcdb5fc3 100644 --- a/lv_objx/lv_mbox.c +++ b/lv_objx/lv_mbox.c @@ -390,6 +390,18 @@ bool lv_mbox_get_recolor(const lv_obj_t * mbox) return lv_btnm_get_recolor(ext->btnm); } +/** + * Get message box button matrix + * @param mbox pointer to a message box object + * @return pointer to button matrix object + * @remarks return value will be NULL unless `lv_mbox_add_btns` has been already called + */ +lv_obj_t * lv_mbox_get_btnm(lv_obj_t * mbox) +{ + lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox); + return ext->btnm; +} + /********************** * STATIC FUNCTIONS diff --git a/lv_objx/lv_mbox.h b/lv_objx/lv_mbox.h index 9a25a76e3..2aa182b34 100644 --- a/lv_objx/lv_mbox.h +++ b/lv_objx/lv_mbox.h @@ -189,6 +189,14 @@ lv_style_t * lv_mbox_get_style(const lv_obj_t *mbox, lv_mbox_style_t type); */ bool lv_mbox_get_recolor(const lv_obj_t * mbox); +/** + * Get message box button matrix + * @param mbox pointer to a message box object + * @return pointer to button matrix object + * @remarks return value will be NULL unless `lv_mbox_add_btns` has been already called + */ +lv_obj_t * lv_mbox_get_btnm(lv_obj_t * mbox); + /********************** * MACROS **********************/ From 4a54b6e4faefc358abaf2471e586388767b4a95c Mon Sep 17 00:00:00 2001 From: manison Date: Thu, 28 Feb 2019 09:08:53 +0100 Subject: [PATCH 2/6] fix argument documentation --- lv_objx/lv_mbox.c | 2 +- lv_objx/lv_mbox.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lv_objx/lv_mbox.c b/lv_objx/lv_mbox.c index 4fcdb5fc3..9948714b2 100644 --- a/lv_objx/lv_mbox.c +++ b/lv_objx/lv_mbox.c @@ -377,7 +377,7 @@ lv_style_t * lv_mbox_get_style(const lv_obj_t * mbox, lv_mbox_style_t type) /** * Get whether recoloring is enabled - * @param btnm pointer to button matrix object + * @param mbox pointer to a message box object * @return whether recoloring is enabled */ bool lv_mbox_get_recolor(const lv_obj_t * mbox) diff --git a/lv_objx/lv_mbox.h b/lv_objx/lv_mbox.h index 2aa182b34..0526fae88 100644 --- a/lv_objx/lv_mbox.h +++ b/lv_objx/lv_mbox.h @@ -184,7 +184,7 @@ lv_style_t * lv_mbox_get_style(const lv_obj_t *mbox, lv_mbox_style_t type); /** * Get whether recoloring is enabled - * @param btnm pointer to button matrix object + * @param mbox pointer to a message box object * @return whether recoloring is enabled */ bool lv_mbox_get_recolor(const lv_obj_t * mbox); From 4e9df1679e10eb167e8e95914678e4c2758075b5 Mon Sep 17 00:00:00 2001 From: manison Date: Thu, 28 Feb 2019 09:09:58 +0100 Subject: [PATCH 3/6] fix formatting --- lv_objx/lv_mbox.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lv_objx/lv_mbox.c b/lv_objx/lv_mbox.c index 9948714b2..06f636d5e 100644 --- a/lv_objx/lv_mbox.c +++ b/lv_objx/lv_mbox.c @@ -382,12 +382,12 @@ lv_style_t * lv_mbox_get_style(const lv_obj_t * mbox, lv_mbox_style_t type) */ bool lv_mbox_get_recolor(const lv_obj_t * mbox) { - lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox); + lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox); - if(!ext->btnm) - return false; + if(!ext->btnm) + return false; - return lv_btnm_get_recolor(ext->btnm); + return lv_btnm_get_recolor(ext->btnm); } /** From 513a7e0a4e77052e220f1cdf312233c3463876b9 Mon Sep 17 00:00:00 2001 From: manison Date: Thu, 28 Feb 2019 09:27:25 +0100 Subject: [PATCH 4/6] btnm: introduce lv_btnm_set_pressed API --- lv_objx/lv_btnm.c | 19 +++++++++++++++++++ lv_objx/lv_btnm.h | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/lv_objx/lv_btnm.c b/lv_objx/lv_btnm.c index 78a8f5a04..1b750d909 100644 --- a/lv_objx/lv_btnm.c +++ b/lv_objx/lv_btnm.c @@ -303,6 +303,25 @@ void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_action_t action) ext->action = action; } +/** + * Set the pressed button + * @param btnm pointer to button matrix object + * @param id index of the currently pressed button (`LV_BTNM_PR_NONE` to unpress) + */ +void lv_btnm_set_pressed(const lv_obj_t * btnm, uint16_t id) +{ + lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); + + if (id >= ext->btn_cnt && id != LV_BTNM_PR_NONE) + return; + + if (id == ext->btn_id_pr) + return; + + ext->btn_id_pr = id; + lv_obj_invalidate(btnm); +} + /** * Enable or disable button toggling * @param btnm pointer to button matrix object diff --git a/lv_objx/lv_btnm.h b/lv_objx/lv_btnm.h index 36f3241d5..7eef895a5 100644 --- a/lv_objx/lv_btnm.h +++ b/lv_objx/lv_btnm.h @@ -141,6 +141,13 @@ void lv_btnm_set_ctrl_map(const lv_obj_t * btnm, const lv_btnm_ctrl_t * ctrl_map */ void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_action_t action); +/** + * Set the pressed button + * @param btnm pointer to button matrix object + * @param id index of the currently pressed button (`LV_BTNM_PR_NONE` to unpress) + */ +void lv_btnm_set_pressed(const lv_obj_t * btnm, uint16_t id); + /** * Enable or disable button toggling * @param btnm pointer to button matrix object From 4608f72098eff89856e3bc09c01bad788612109b Mon Sep 17 00:00:00 2001 From: canardos Date: Fri, 1 Mar 2019 15:25:29 +0800 Subject: [PATCH 5/6] add lv_cb_set_static_text function --- lv_objx/lv_cb.c | 16 ++++++++++++++-- lv_objx/lv_cb.h | 13 +++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/lv_objx/lv_cb.c b/lv_objx/lv_cb.c index e6fc49454..63a8005ce 100644 --- a/lv_objx/lv_cb.c +++ b/lv_objx/lv_cb.c @@ -120,9 +120,10 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy) *====================*/ /** - * Set the text of a check box + * Set the text of a check box. `txt` will be copied and may be deallocated + * after this function returns. * @param cb pointer to a check box - * @param txt the text of the check box + * @param txt the text of the check box. NULL to refresh with the current text. */ void lv_cb_set_text(lv_obj_t * cb, const char * txt) { @@ -130,6 +131,17 @@ void lv_cb_set_text(lv_obj_t * cb, const char * txt) lv_label_set_text(ext->label, txt); } +/** + * Set the text of a check box. `txt` must not be deallocated during the life + * of this checkbox. + * @param cb pointer to a check box + * @param txt the text of the check box. NULL to refresh with the current text. + */ +void lv_cb_set_static_text(lv_obj_t * cb, const char * txt) { + lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb); + lv_label_set_static_text(ext->label, txt); +} + /** * Set a style of a check box * @param cb pointer to check box object diff --git a/lv_objx/lv_cb.h b/lv_objx/lv_cb.h index b58773341..45f33ee87 100644 --- a/lv_objx/lv_cb.h +++ b/lv_objx/lv_cb.h @@ -78,12 +78,21 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy); *====================*/ /** - * Set the text of a check box + * Set the text of a check box. `txt` will be copied and may be deallocated + * after this function returns. * @param cb pointer to a check box - * @param txt the text of the check box + * @param txt the text of the check box. NULL to refresh with the current text. */ void lv_cb_set_text(lv_obj_t * cb, const char * txt); +/** + * Set the text of a check box. `txt` must not be deallocated during the life + * of this checkbox. + * @param cb pointer to a check box + * @param txt the text of the check box. NULL to refresh with the current text. + */ +void lv_cb_set_static_text(lv_obj_t * cb, const char * txt); + /** * Set the state of the check box * @param cb pointer to a check box object From 2ffb0a83b07e34e2e7b2d4599e0229269cfb4dfd Mon Sep 17 00:00:00 2001 From: canardos Date: Fri, 1 Mar 2019 15:56:27 +0800 Subject: [PATCH 6/6] Fix incorrect kb_ctrl_num_map --- lv_objx/lv_kb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lv_objx/lv_kb.c b/lv_objx/lv_kb.c index 01f654681..a5545bcfa 100644 --- a/lv_objx/lv_kb.c +++ b/lv_objx/lv_kb.c @@ -82,6 +82,7 @@ static const char * kb_map_num[] = { }; static const lv_btnm_ctrl_t kb_ctrl_num_map[] = { + 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1