MenuStack.h 626 B

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * @file
  3. * @author Marek Bel
  4. */
  5. #ifndef MENUSTACK_H
  6. #define MENUSTACK_H
  7. #include <stdint.h>
  8. /** Pointer to function implementing menu.*/
  9. typedef void (*menuFunc_t)();
  10. /**
  11. * @brief Stack implementation for navigating menu structure
  12. */
  13. class MenuStack
  14. {
  15. public:
  16. struct Record
  17. {
  18. menuFunc_t menu;
  19. int8_t position;
  20. };
  21. MenuStack():m_stack(),m_index(0) {}
  22. void push(menuFunc_t menu, int8_t position);
  23. Record pop();
  24. void reset(){m_index = 0;}
  25. private:
  26. static const int max_depth = 4;
  27. Record m_stack[max_depth];
  28. uint8_t m_index;
  29. };
  30. #endif /* FIRMWARE_MENUSTACK_H_ */