MenuStack.cpp 588 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * @file
  3. * @author Marek Bel
  4. */
  5. #include "MenuStack.h"
  6. /**
  7. * @brief Push menu on stack
  8. * @param menu
  9. * @param position selected position in menu being pushed
  10. */
  11. void MenuStack::push(menuFunc_t menu, int8_t position)
  12. {
  13. if (m_index >= max_depth) return;
  14. m_stack[m_index].menu = menu;
  15. m_stack[m_index].position = position;
  16. ++m_index;
  17. }
  18. /**
  19. * @brief Pop menu from stack
  20. * @return Record containing menu function pointer and previously selected line number
  21. */
  22. MenuStack::Record MenuStack::pop()
  23. {
  24. if (m_index != 0) m_index--;
  25. return m_stack[m_index];
  26. }