// =====================================================================
//
// Output function
//
// =====================================================================

/* ******************************************************************** */
void lcdml_menu_clear()
/* ******************************************************************** */
{
  for(uint8_t i=0;i<15;i++) {
    Serial.println();
  }
}

/* ******************************************************************** */
void lcdml_menu_display()
/* ******************************************************************** */
{
  // init vars
  //uint8_t n_max = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds());

  // update content
  // ***************
  if (LCDML.DISP_checkMenuUpdate() || LCDML.DISP_checkMenuCursorUpdate() ) {
    // clear menu
    // ***************
    LCDML.DISP_clear();

    Serial.println(F("==========================================="));
    Serial.println(F("================  Menu ===================="));
    Serial.println(F("==========================================="));

    // declaration of some variables
    // ***************
    // content variable
    char content_text[_LCDML_DISP_cols];  // save the content text of every menu element
    // menu element object
    LCDMenuLib2_menu *tmp;
    // some limit values
    uint8_t i = LCDML.MENU_getScroll();
    uint8_t maxi = _LCDML_DISP_rows + i;
    uint8_t n = 0;

    // check if this element has children
    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())
        {
          // display cursor
          if (n == LCDML.MENU_getCursorPos())
          {
            Serial.print(F("(x) "));
          }
          else
          {
            Serial.print(F("( ) "));
          }

          // check the type off a menu element
          if(tmp->checkType_menu() == true)
          {
            // display normal content
            switch(g_lcdml_lang_select)
            {
              case LANG_DE: // custom language long name
                // get the custom language content with the short name of the language
                LCDML_getCustomContent(DE, content_text, tmp->getID());
              break;

              /*
              // this is only an example for other languages
              case LANG_EN: // custom language long name
              // get the custom language content with the short name of the language
                LCDML_getCustomContent(EN, content_text, tmp->getID());
              break;
              */
                

              default: // default language
                 LCDML_getContent(content_text, tmp->getID());
                 break;
            }
            
            Serial.print(content_text);
          }
          else
          {
            if(tmp->checkType_dynParam()) {
              tmp->callback(n);
            }
          }

          Serial.println();

          // 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));
    }
  }
}
