diff --git a/examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_021_dynUpdatedContent.ino b/examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_021_dynUpdatedContent.ino index d7c4d70..2b11735 100644 --- a/examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_021_dynUpdatedContent.ino +++ b/examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_021_dynUpdatedContent.ino @@ -182,7 +182,7 @@ uint8_t dyn_sec = 0; { // only update the menu when a dynamic content function is called // This variable is set in the LCDML_display_menu Tab on line 59/60 - if(g_status_if_dyn_content_external_refresh_is_displayed == true) + if(LCDML.MENU_checkDynRContent() == true) { LCDML.MENU_display(); } @@ -201,4 +201,4 @@ uint8_t dyn_sec = 0; // call the "normaly" menu content LCDML.loop_menu(); - } + } \ No newline at end of file diff --git a/examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_display_dynFunction.ino b/examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_display_dynFunction.ino index d66bc18..62bf770 100644 --- a/examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_display_dynFunction.ino +++ b/examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_display_dynFunction.ino @@ -101,18 +101,18 @@ void mDyn_time(uint8_t line) char buf[20]; // http://www.c-howto.de/tutorial/benutzerinteraktion/bildschirmausgaben/ - sprintf (buf, "%02d:%02d:%02d", dyn_hour, dyn_min, dyn_sec); + sprintf (buf, "Time %02d:%02d:%02d", dyn_hour, dyn_min, dyn_sec); // use the line from function parameters lcd.setCursor(1, line); lcd.print(buf); // reset initscreen timer when this function is displayed - LCDML.SCREEN_resetTimer(); + //LCDML.SCREEN_resetTimer(); // check if this function is active (cursor stands on this line) if (line == LCDML.MENU_getCursorPos()) { // ... } -} +} \ No newline at end of file diff --git a/examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_display_menu.ino b/examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_display_menu.ino index 4b549b8..6a261c1 100644 --- a/examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_display_menu.ino +++ b/examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_display_menu.ino @@ -8,9 +8,9 @@ void lcdml_menu_clear() /* ******************************************************************** */ { - if (g_status_if_dyn_content_external_refresh_is_displayed == false) + if (LCDML.MENU_checkDynRContent() == false) { - // clear only the display when the external refreshed content is not shown + // clear only the display when the external content refresh is not displayed lcd.clear(); } } @@ -31,41 +31,12 @@ void lcdml_menu_display() // some limit values uint8_t i = LCDML.MENU_getScroll(); uint8_t maxi = _LCDML_DISP_rows + i; - uint8_t n = 0; - - // reset a state - g_status_if_dyn_content_external_refresh_is_displayed = false; - - if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) - { - // loop to display lines - do - { - // check if a menu element has a condition and if the condition be true - if (tmp->checkCondition()) - { - // call a dyn content element - if(tmp->checkType_dynParam_enabledCustomRefresh() == true) - { - g_status_if_dyn_content_external_refresh_is_displayed = true; - } - // increment some values - i++; - n++; - } - // try to go to the next sibling and check the number of displayed rows - } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi)); - } + uint8_t n = 0; // clear menu // *************** LCDML.DISP_clear(); - // reset variables - i = LCDML.MENU_getScroll(); - maxi = _LCDML_DISP_rows + i; - n = 0; - // check if this element has children if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) { @@ -120,7 +91,7 @@ void lcdml_menu_display() //set cursor char if (n == LCDML.MENU_getCursorPos()) { lcd.write(_LCDML_DISP_cfg_cursor); - if(g_status_if_dyn_content_external_refresh_is_displayed == true) + if(LCDML.MENU_checkDynRContent() == true) { LCDML.MENU_getDisplayedObj()->callback(n); } @@ -161,4 +132,4 @@ void lcdml_menu_display() } } } -} +} \ No newline at end of file diff --git a/keywords.txt b/keywords.txt index d5be3b8..912bfaa 100644 --- a/keywords.txt +++ b/keywords.txt @@ -243,6 +243,9 @@ MENU_clearDynFunctionContentUpdate KEYWORD2 MENU_allCondetionRefresh KEYWORD2 MENU_enRefreshAllOnButtonAction KEYWORD2 MENU_disRefreshAllOnButtonAction KEYWORD2 +MENU_setDynRContent KEYWORD2 +MENU_clearDynRContent KEYWORD2 +MENU_checkDynRContent KEYWORD2 BT_setup KEYWORD2 BT_enter KEYWORD2 diff --git a/library.properties b/library.properties index d71faba..5fe40e5 100644 --- a/library.properties +++ b/library.properties @@ -1,7 +1,7 @@ name=LCDMenuLib2 -version=2.2.7 beta-4 -author=Jomelo -maintainer=Jomelo +version=2.2.7 beta-5 +author=Jomelo +maintainer=Community https://github.com/Jomelo/LCDMenuLib2 sentence=Easy creation of a multi layer tree menu with screensaver and other stuff. paragraph=Examples for the basic function and different output types [console (serial monitor), lcd displays, glcd displays, gfx displays] category=Display diff --git a/src/LCDMenuLib2.cpp b/src/LCDMenuLib2.cpp index 72940b6..3da038e 100644 --- a/src/LCDMenuLib2.cpp +++ b/src/LCDMenuLib2.cpp @@ -821,6 +821,37 @@ void LCDMenuLib2::loop_menu(void) { // do nothing } + + // + // detect if dynamic refreshed content is currently displayed + // some limit values + cnt = MENU_getScroll(); + uint8_t maxi = window_rows + cnt; + + MENU_clearDynRContent(); + + if ((tmp = MENU_getDisplayedObj()) != NULL) + { + // loop to display lines + do + { + // check if a menu element has a condition and if the condition be true + if (tmp->checkCondition()) + { + // call a dyn content element + if(tmp->checkType_dynParam_enabledCustomRefresh() == true) + { + // new function in version 2.2.7 to set a flag that dynamic enabled content is displayed + MENU_setDynRContent(); + break; + } + // increment some values + cnt++; + } + // try to go to the next sibling and check the number of displayed rows + } while (((tmp = tmp->getSibling(1)) != NULL) && (cnt < maxi)); + } + // end of detection of dynamic refreshed content // update content callback_contentUpdate(); @@ -1879,6 +1910,36 @@ void LCDMenuLib2::MENU_disRefreshAllOnButtonAction(void) } +/* ******************************************************************** */ +void LCDMenuLib2::MENU_setDynRContent(void) +/* ******************************************************************** */ +{ + // debug information + DBG_println(LCDML_DBG_function_name_OTHER, F("LCDML.MENU_setDynRContent")); + + bitSet(REG_control, _LCDML_REG_control_content_ref_is_displayed); +} + + +/* ******************************************************************** */ +void LCDMenuLib2::MENU_clearDynRContent(void) +/* ******************************************************************** */ +{ + // debug information + DBG_println(LCDML_DBG_function_name_OTHER, F("LCDML.MENU_clearDynRContent")); + + bitClear(REG_control, _LCDML_REG_control_content_ref_is_displayed); +} + +/* ******************************************************************** */ +bool LCDMenuLib2::MENU_checkDynRContent(void) +/* ******************************************************************** */ +{ + // debug information + DBG_println(LCDML_DBG_function_name_OTHER, F("LCDML.MENU_checkDynRContent")); + + return bitRead(REG_control, _LCDML_REG_control_content_ref_is_displayed); +} /* ******************************************************************** */ @@ -2526,6 +2587,7 @@ void LCDMenuLib2::OTHER_jumpToFunc(LCDML_FuncPtr_pu8 p_search, uint8_t p_para) bitSet(REG_special, _LCDML_REG_special_OTHER_function_active); bitClear(REG_special, _LCDML_REG_special_setCursorTo); + MENU_clearDynRContent(); // Save last active Menu ID actMenu_lastFuncID = actMenu_id; @@ -2584,7 +2646,8 @@ void LCDMenuLib2::OTHER_jumpToID(uint8_t p_id, uint8_t p_para) DBG_println(LCDML_DBG_function_name_OTHER, F("LCDML.OTHER_jumpToID - start")); bitSet(REG_special, _LCDML_REG_special_OTHER_function_active); - bitClear(REG_special, _LCDML_REG_special_setCursorTo); + bitClear(REG_special, _LCDML_REG_special_setCursorTo); + MENU_clearDynRContent(); // Save last active Menu ID actMenu_lastFuncID = actMenu_id; @@ -2648,6 +2711,7 @@ void LCDMenuLib2::OTHER_setCursorToFunc(LCDML_FuncPtr_pu8 p_search) // enable jump to Func bitSet(REG_special, _LCDML_REG_special_OTHER_function_active); bitSet(REG_special, _LCDML_REG_special_setCursorTo); + MENU_clearDynRContent(); jT_id = 0; // Save last active Menu ID @@ -2699,6 +2763,7 @@ void LCDMenuLib2::OTHER_setCursorToID(uint8_t p_id) // enable jump to Func bitSet(REG_special, _LCDML_REG_special_OTHER_function_active); bitSet(REG_special, _LCDML_REG_special_setCursorTo); + MENU_clearDynRContent(); jT_id = p_id; // Save last active Menu ID diff --git a/src/LCDMenuLib2.h b/src/LCDMenuLib2.h index 38a7e1a..bb74af2 100644 --- a/src/LCDMenuLib2.h +++ b/src/LCDMenuLib2.h @@ -80,7 +80,7 @@ #endif // Version - #define _LCDML_VERSION "LCDML2 v2.2.7 beta-4" + #define _LCDML_VERSION "LCDML2 v2.2.7 beta-5" // this makro is for unused variables which exists for compatibility things ... #define LCDML_UNUSED(expr) do { (void)(expr); } while (0) @@ -112,7 +112,7 @@ // Bit pos control flags #define _LCDML_REG_control_free_7 7 #define _LCDML_REG_control_ce_init_setup 6 - #define _LCDML_REG_control_free_5 5 + #define _LCDML_REG_control_content_ref_is_displayed 5 #define _LCDML_REG_control_bt_init_setup 4 #define _LCDML_REG_control_update_direct 3 #define _LCDML_REG_control_refresh_all_on_button_action 2 @@ -295,6 +295,9 @@ void MENU_disUseDynElementsWithSubElements(void); // disable subelements for dynamic menu elements void MENU_enRefreshAllOnButtonAction(void); // enable update on every button action the complete menu void MENU_disRefreshAllOnButtonAction(void); // disable update on every button action the complete menu + void MENU_setDynRContent(void); // enable dynamic refreshed content is shown + void MENU_clearDynRContent(void); // disable dynamic refreshed content is shown + bool MENU_checkDynRContent(void); // get dynamic refreshed content is shown LCDMenuLib2_menu * MENU_getDisplayedObj(void); // get the objection with the current content to display LCDMenuLib2_menu * MENU_getCurrentObj(void); // get the current menu child object