154 lines
3.5 KiB
C++
154 lines
3.5 KiB
C++
/**
|
|
* @file menuInformationSites.h
|
|
* @author Alexander Klein (alex@kleiax.de)
|
|
* @brief Contains a class to print informations over more pages
|
|
* @version 0.1
|
|
* @date 2022-12-27
|
|
*
|
|
* @copyright Copyright (c) 2022
|
|
*
|
|
*/
|
|
#ifndef MENU_INFORMATION_SITES_H
|
|
#define MENU_INFORMATION_SITES_H
|
|
|
|
#include "menuControl.h"
|
|
|
|
/**
|
|
* @brief A Menu interface to show informations
|
|
*
|
|
* The informations a organized by multiple pages
|
|
*/
|
|
class MenuInformationSites : public MenuControl
|
|
{
|
|
public:
|
|
/**
|
|
* @brief Construct a new Menu Information Sites object
|
|
*
|
|
* @param pages amount of the available pages
|
|
*/
|
|
MenuInformationSites(uint8_t pages = 1);
|
|
|
|
/**
|
|
* @brief Next page
|
|
*/
|
|
void down() override;
|
|
|
|
/**
|
|
* @brief Previous page
|
|
*/
|
|
void up() override;
|
|
|
|
/**
|
|
* @brief Update information
|
|
*/
|
|
void right() override;
|
|
|
|
/**
|
|
* @brief Go to the parent menu
|
|
*/
|
|
void left() override;
|
|
|
|
/**
|
|
* @brief Calls runCommandNo()
|
|
*/
|
|
void no() override;
|
|
|
|
/**
|
|
* @brief Calls runCommand()
|
|
*/
|
|
void yes() override;
|
|
|
|
/**
|
|
* @brief Prints the Information to display and console
|
|
*
|
|
* Prints the selected page.
|
|
*/
|
|
void printMenu() override;
|
|
|
|
protected:
|
|
/**
|
|
* @brief Change the amount of available pages
|
|
*
|
|
* @param pages
|
|
* @return true successful
|
|
* @return false
|
|
*/
|
|
bool setCountPages(uint8_t pages);
|
|
|
|
/**
|
|
* @brief Get the amount of available pages
|
|
*
|
|
* @return uint8_t
|
|
*/
|
|
uint8_t getCountPages() const;
|
|
|
|
/**
|
|
* @brief Get the selected page number
|
|
*
|
|
* @return uint8_t
|
|
*/
|
|
uint8_t getCurrentPage() const;
|
|
|
|
/**
|
|
* @brief Print a page with informations
|
|
*
|
|
* This function have to be overwritten.
|
|
* The function have to use the print() function to access the display.
|
|
* The printed informations should be depends from the current page,
|
|
* which can determine by call getCurrentPage().
|
|
*/
|
|
virtual void printPage() const = 0;
|
|
|
|
/**
|
|
* @brief Function to adds actions
|
|
*
|
|
* If this function is overwritten, the menu can be extended
|
|
* with extra functionality. The executed action should be depends on
|
|
* the current page, which can determine by call getCurrentPage().
|
|
*
|
|
* This function is called if no() is called.
|
|
*/
|
|
virtual void runCommandNo() {}
|
|
|
|
/**
|
|
* @brief Function to adds actions
|
|
*
|
|
* If this function is overwritten, the menu can be extended
|
|
* with extra functionality. The executed action should be depends on
|
|
* the current page, which can determine by call getCurrentPage().
|
|
*
|
|
* This function is called if yes() is called.
|
|
*/
|
|
virtual void runCommand() {}
|
|
|
|
/**
|
|
* @brief Function to prepare dependencies
|
|
*
|
|
* This function is called when the menu is entered.
|
|
*/
|
|
virtual void init() {}
|
|
|
|
/**
|
|
* @brief Prints default informations
|
|
*
|
|
* The default informations are the current page number
|
|
* and the amount of available pages.
|
|
*
|
|
* Can be used by printPage() if the current page is not available.
|
|
*/
|
|
void printDefault() const;
|
|
|
|
uint8_t lastPageNumber = 0;
|
|
bool leaved = true;
|
|
bool noEqualLeft = false;
|
|
|
|
private:
|
|
uint8_t countPages;
|
|
uint8_t currentPage;
|
|
|
|
const uint16_t delay = 5000;
|
|
uint32_t lastMillis = 0;
|
|
};
|
|
|
|
#endif // MENU_INFORMATION_SITES_H
|