84 lines
1.7 KiB
C++
84 lines
1.7 KiB
C++
/**
|
|
* @file menuIntInput.h
|
|
* @author Alexander Klein (alex@kleiax.de)
|
|
* @brief
|
|
* @version 0.1
|
|
* @date 2022-09-12
|
|
*
|
|
* @copyright Copyright (c) 2022
|
|
*
|
|
*/
|
|
#ifndef MENU_INT_INPUT_H
|
|
#define MENU_INT_INPUT_H
|
|
|
|
#include "menuControl.h"
|
|
#include <stdint.h>
|
|
|
|
#define MAX_NAME_LENGTH 12
|
|
|
|
class MenuIntInputWrapper {
|
|
public:
|
|
virtual void action(int16_t* values, uint8_t length) = 0;
|
|
};
|
|
|
|
class MenuIntInput : public MenuControl {
|
|
public:
|
|
MenuIntInput(int16_t values[], char *names, uint8_t length, MenuIntInputWrapper* wrapper);
|
|
|
|
void setMin(int16_t min = 0) { this->min = min; }
|
|
void setMax(int16_t max = 100) { this->max = max; }
|
|
|
|
/**
|
|
* @brief Decrement selected value
|
|
*/
|
|
void down() override;
|
|
|
|
/**
|
|
* @brief Increment selected value
|
|
*/
|
|
void up() override;
|
|
|
|
/**
|
|
* @brief Select next value
|
|
*/
|
|
void right() override;
|
|
|
|
/**
|
|
* @brief Select previous value
|
|
*/
|
|
void left() override;
|
|
|
|
/**
|
|
* @brief Leave menu without saving
|
|
*/
|
|
void no() override;
|
|
|
|
/**
|
|
* @brief Leave menu with saving
|
|
*/
|
|
void yes() override;
|
|
|
|
/**
|
|
* @brief Prints the Information to display and console
|
|
*
|
|
* The informations are only printed to the display if it
|
|
* set.
|
|
*/
|
|
void printMenu() override;
|
|
|
|
void update() override {};
|
|
|
|
private:
|
|
MenuIntInputWrapper* wrapper;
|
|
|
|
uint8_t currentPosition = 0;
|
|
uint8_t length;
|
|
int16_t *values;
|
|
int16_t min = INT16_MIN;
|
|
int16_t max = INT16_MAX;
|
|
char *names;
|
|
|
|
};
|
|
|
|
#endif // MENU_INT_INPUT_H
|