ntrip, testMode, zed9 gnss modul
This commit is contained in:
@@ -21,6 +21,10 @@ void Menu::addEntry(MenuAction* entry) {
|
||||
this->selectedEntry = this->entrys.begin();
|
||||
}
|
||||
|
||||
bool Menu::isInSubmenu() {
|
||||
return this->inSubmenu;
|
||||
}
|
||||
|
||||
void Menu::printMenu() {
|
||||
if (this->lcd) {
|
||||
lcd->clear();
|
||||
|
||||
@@ -31,6 +31,7 @@ class Menu : public MenuControl {
|
||||
* @param entry
|
||||
*/
|
||||
void addEntry(MenuAction* entry);
|
||||
bool isInSubmenu();
|
||||
|
||||
void printMenu() override;
|
||||
void update() override;
|
||||
|
||||
@@ -32,20 +32,20 @@ class MenuControl {
|
||||
* class.
|
||||
*/
|
||||
///@{
|
||||
virtual void down();
|
||||
virtual void up();
|
||||
virtual void right();
|
||||
virtual void left();
|
||||
virtual void yes();
|
||||
virtual void no();
|
||||
virtual void down() = 0;
|
||||
virtual void up() = 0;
|
||||
virtual void right() = 0;
|
||||
virtual void left() = 0;
|
||||
virtual void yes() = 0;
|
||||
virtual void no() = 0;
|
||||
///@}
|
||||
|
||||
/**
|
||||
* @brief can be called to update shown data
|
||||
*/
|
||||
virtual void update();
|
||||
virtual void update() {}
|
||||
|
||||
virtual void printMenu();
|
||||
virtual void printMenu() = 0;
|
||||
|
||||
/**
|
||||
* @brief Set the Parent Menu
|
||||
@@ -56,6 +56,7 @@ class MenuControl {
|
||||
* @param menu
|
||||
*/
|
||||
void setParentMenu(MenuControl* menu) { this->parentMenu = menu; }
|
||||
// MenuControl* getParentMenu() { return this->parentMenu; }
|
||||
|
||||
/**
|
||||
* @brief Set the Lcd object
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* @file menuIntInput.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-09-12
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#include "menuIntInput.h"
|
||||
|
||||
MenuIntInput::MenuIntInput(int16_t values[], char *names, uint8_t length, MenuIntInputWrapper* wrapper) {
|
||||
this->values = values;
|
||||
this->names = names;
|
||||
this->length = length;
|
||||
this->wrapper = wrapper;
|
||||
}
|
||||
|
||||
void MenuIntInput::down() {
|
||||
if (values[currentPosition] > this->min)
|
||||
values[currentPosition]--;
|
||||
|
||||
this->printMenu();
|
||||
}
|
||||
|
||||
void MenuIntInput::up() {
|
||||
if (values[currentPosition] < this->max)
|
||||
values[currentPosition]++;
|
||||
|
||||
this->printMenu();
|
||||
}
|
||||
|
||||
void MenuIntInput::right() {
|
||||
if (currentPosition < this->length - 1)
|
||||
currentPosition++;
|
||||
else
|
||||
currentPosition = 0;
|
||||
|
||||
this->printMenu();
|
||||
}
|
||||
|
||||
void MenuIntInput::left() {
|
||||
if (currentPosition > 0)
|
||||
currentPosition--;
|
||||
else
|
||||
currentPosition = this->length - 1;
|
||||
|
||||
this->printMenu();
|
||||
}
|
||||
|
||||
void MenuIntInput::no() {
|
||||
if (parentMenu)
|
||||
this->parentMenu->printMenu();
|
||||
}
|
||||
|
||||
void MenuIntInput::yes() {
|
||||
this->wrapper->action(this->values, this->length);
|
||||
if (parentMenu)
|
||||
this->parentMenu->printMenu();
|
||||
}
|
||||
|
||||
void MenuIntInput::printMenu() {
|
||||
// TODO: Name max 12 chars
|
||||
|
||||
char bufferName[17];
|
||||
if (this->currentPosition == 0 && this->length == 1) {
|
||||
// No arrow
|
||||
sprintf(bufferName, " %s ", this->names[this->currentPosition]);
|
||||
} else if (this->currentPosition > 0 && this->length - 1 == this->currentPosition) {
|
||||
// Left arrow only
|
||||
sprintf(bufferName, "< %s ", this->names[this->currentPosition]);
|
||||
} else if (this->currentPosition == 0 && this->length > 1) {
|
||||
// Right arrow only
|
||||
sprintf(bufferName, " %s >", this->names[this->currentPosition]);
|
||||
} else {
|
||||
// Both arrow
|
||||
sprintf(bufferName, "< %s >", this->names[this->currentPosition]);
|
||||
}
|
||||
|
||||
char bufferValue[17];
|
||||
sprintf(bufferValue, " -> %5.d", this->values[this->currentPosition]);
|
||||
|
||||
|
||||
if (this->lcd) {
|
||||
lcd->clear();
|
||||
lcd->setCursor(0, 0);
|
||||
lcd->print(bufferName);
|
||||
lcd->setCursor(0, 1);
|
||||
lcd->print(bufferValue);
|
||||
}
|
||||
std::cout << bufferName << " : " << bufferValue << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @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
|
||||
Reference in New Issue
Block a user