Skip to content

Commit

Permalink
v2.2.7 beta 5
Browse files Browse the repository at this point in the history
- BugFix: Screensaver / jump To action on dynamic refreshed content
- Improvement: Reduce complexity of dynamic updated content example
  • Loading branch information
Jomelo committed Apr 2, 2021
1 parent 6553d6c commit 72f530d
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -201,4 +201,4 @@ uint8_t dyn_sec = 0;

// call the "normaly" menu content
LCDML.loop_menu();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
// ...
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand All @@ -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)
{
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -161,4 +132,4 @@ void lcdml_menu_display()
}
}
}
}
}
3 changes: 3 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name=LCDMenuLib2
version=2.2.7 beta-4
author=Jomelo <[email protected]>
maintainer=Jomelo <alias.jomelo@gmail.com>
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
Expand Down
67 changes: 66 additions & 1 deletion src/LCDMenuLib2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}


/* ******************************************************************** */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions src/LCDMenuLib2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 72f530d

Please sign in to comment.