REWORK: Migrate completely to new menu structure
This commit is contained in:
parent
5b3bc7591d
commit
e4d5173d26
@ -7,6 +7,6 @@
|
||||
|
||||
// Auto generated header file containing the last git revision
|
||||
|
||||
#define GIT_HASH "527ebdc"
|
||||
#define GIT_HASH "49c43ab"
|
||||
|
||||
#endif //FLOATPUMP_GIT_REVISION_TEMPLATE_H
|
@ -5,18 +5,11 @@
|
||||
#include "LCD_I2C_Driver.h"
|
||||
#include "InitSequence.h"
|
||||
#include "button_input.h"
|
||||
#include "Menu.h"
|
||||
#include "Menu_Entry_Type_Checkable.h"
|
||||
#include "Menu_Entry_Type_Numeric.h"
|
||||
#include "Menu_Entry_Type_Percent.h"
|
||||
#include "Menu_Entry_Type_ReadOnly.h"
|
||||
#include "Menu_Entry_Type_Time.h"
|
||||
#include "Config_Store.h"
|
||||
#include "Menu_Controller.h"
|
||||
#include "PressureChannel.h"
|
||||
#include "RelayChannel.h"
|
||||
#include "GPIChannel.h"
|
||||
#include "Menu_Entry_Type_Execute.h"
|
||||
#include "NewMenu.h"
|
||||
|
||||
#define SLAVE_ADDRESS_LCD 0x4e
|
||||
@ -150,27 +143,9 @@ int main(void) {
|
||||
InitSequence initializer(display);
|
||||
initializer.runInitSequence();
|
||||
|
||||
using namespace floatpump::menu;
|
||||
|
||||
//EXP
|
||||
|
||||
using namespace floatpump::newmenu;
|
||||
|
||||
|
||||
|
||||
//EXP
|
||||
|
||||
|
||||
///
|
||||
///
|
||||
/// LOGICAL CODE BEGIN
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
using namespace floatpump;
|
||||
|
||||
|
||||
newmenu::Menu tankmenu("Tank");
|
||||
Menu tankmenu("Tank");
|
||||
|
||||
bool a_caliblow, a_calibhigh = false;
|
||||
tankmenu.addEntry<MenuEntryExecute>(&a_caliblow, "Kal. Unt. Punkt");
|
||||
@ -185,7 +160,7 @@ int main(void) {
|
||||
tankmenu.addEntry<MenuEntryCheckable>(globalConfig.TankPumpInvert.getLink(), "Inv Relais");
|
||||
|
||||
|
||||
newmenu::Menu refillmenu("Nachspeisung");
|
||||
Menu refillmenu("Nachspeisung");
|
||||
|
||||
refillmenu.addEntry<MenuEntryCheckable>(globalConfig.RefillEnable.getLink(), "Nachsp. akt.");
|
||||
refillmenu.addEntry<MenuEntryCheckable>(globalConfig.RefillBlockEnable.getLink(), "Notabschalt.");
|
||||
@ -197,12 +172,11 @@ int main(void) {
|
||||
refillmenu.addEntry<MenuEntryNumeric>(globalConfig.RefillCooldown.getLink(), "Wartezeit");
|
||||
|
||||
|
||||
newmenu::Menu mainmenu("Hauptmenu");
|
||||
Menu mainmenu("Hauptmenu");
|
||||
mainmenu.addSubmenu(&tankmenu);
|
||||
mainmenu.addSubmenu(&refillmenu);
|
||||
|
||||
newmenu::Menu_Controller controller(&mainmenu, display);
|
||||
static int old_pos = 0;
|
||||
|
||||
|
||||
//Instantiate Input and Output modules
|
||||
io::PressureChannel tankLevel0(&hadc1, MPWR0_GPIO_Port, MPWR0_Pin, 50);
|
||||
@ -216,16 +190,11 @@ int main(void) {
|
||||
uint32_t last_backlight_retrigger = 0;
|
||||
|
||||
bool f_store = false, f_restore = false;
|
||||
// menu::Menu_Entry_Type_Execute t_MStore;
|
||||
// menu::Menu_Entry_Type_Execute t_MRestore;
|
||||
// t_MStore.linkConfig(&f_store);
|
||||
// t_MRestore.linkConfig(&f_restore);
|
||||
// menu::Menu_Entry MStore(t_MStore, "Speichern");
|
||||
// menu::Menu_Entry MRestore(t_MRestore, "Laden");
|
||||
//
|
||||
//
|
||||
// mainmenu.addEntry(MStore);
|
||||
// mainmenu.addEntry(MRestore);
|
||||
mainmenu.addEntry<MenuEntryExecute>(&f_store, "Speichern");
|
||||
mainmenu.addEntry<MenuEntryExecute>(&f_restore, "Laden");
|
||||
|
||||
Menu_Controller controller(&mainmenu, display);
|
||||
static int old_pos = 0;
|
||||
|
||||
while (1) {
|
||||
|
||||
@ -276,11 +245,11 @@ int main(void) {
|
||||
|
||||
//Check for rotation to enable display backlight
|
||||
if (old_pos < rot_counter) {
|
||||
controller.pushEvent(newmenu::Menu_Controller::Event::Increase);
|
||||
controller.pushEvent(menu::Menu_Controller::Event::Increase);
|
||||
old_pos = rot_counter;
|
||||
last_backlight_retrigger = HAL_GetTick();
|
||||
} else if (old_pos > rot_counter) {
|
||||
controller.pushEvent(newmenu::Menu_Controller::Event::Decrease);
|
||||
controller.pushEvent(menu::Menu_Controller::Event::Decrease);
|
||||
old_pos = rot_counter;
|
||||
last_backlight_retrigger = HAL_GetTick();
|
||||
}
|
||||
@ -301,16 +270,16 @@ int main(void) {
|
||||
controller.execute();
|
||||
if (rot_button) {
|
||||
rot_button = false;
|
||||
controller.pushEvent(newmenu::Menu_Controller::Event::Push);
|
||||
controller.pushEvent(menu::Menu_Controller::Event::Push);
|
||||
last_menu_retrigger = HAL_GetTick();
|
||||
}
|
||||
|
||||
if (old_pos < rot_counter) {
|
||||
controller.pushEvent(newmenu::Menu_Controller::Event::Increase);
|
||||
controller.pushEvent(menu::Menu_Controller::Event::Increase);
|
||||
old_pos = rot_counter;
|
||||
last_menu_retrigger = HAL_GetTick();
|
||||
} else if (old_pos > rot_counter) {
|
||||
controller.pushEvent(newmenu::Menu_Controller::Event::Decrease);
|
||||
controller.pushEvent(menu::Menu_Controller::Event::Decrease);
|
||||
old_pos = rot_counter;
|
||||
last_menu_retrigger = HAL_GetTick();
|
||||
}
|
||||
|
@ -1,54 +0,0 @@
|
||||
//
|
||||
// Created by robtor on 09.12.22.
|
||||
//
|
||||
|
||||
#ifndef FLOATPUMP_MENU_H
|
||||
#define FLOATPUMP_MENU_H
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <typeinfo>
|
||||
#include "Menu_Entry.h"
|
||||
#include "LCD_I2C_Driver.h"
|
||||
|
||||
namespace floatpump::menu {
|
||||
|
||||
class Menu {
|
||||
|
||||
public:
|
||||
|
||||
explicit Menu(std::string name) : m_name(std::move(name)) {}
|
||||
|
||||
//Add specific components
|
||||
void addEntry(const Menu_Entry &entry);
|
||||
|
||||
void addSubmenu(Menu *submenu);
|
||||
|
||||
//Get this menu as string
|
||||
[[nodiscard]] std::string printLine() const;
|
||||
|
||||
//Get all submenus and entries as string vector
|
||||
std::vector<std::string> getDisplayList();
|
||||
|
||||
//Get number of all entries
|
||||
[[nodiscard]] unsigned int getAllEntriesNum() const;
|
||||
|
||||
//Retrieve specific submenu, returns nullptr on error
|
||||
Menu *getSubmenu(int index);
|
||||
|
||||
//Retrieve specific entry, returns nullptr on error
|
||||
Menu_Entry *getEntry(int index);
|
||||
|
||||
//Returns parent menu pointer or nullptr
|
||||
Menu *getParent();
|
||||
|
||||
private:
|
||||
std::vector<Menu_Entry> m_entries; //normal menu entries
|
||||
std::vector<Menu *> m_submenus; //all submenu entries
|
||||
Menu *m_parent = nullptr; //the parent menu, if it is a submenu
|
||||
std::string m_name = "Menu"; //the name of this menu (displayed if it is an submenu)
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //FLOATPUMP_MENU_H
|
@ -8,7 +8,7 @@
|
||||
#include "NewMenu.h"
|
||||
#include "LCD_I2C_Driver.h"
|
||||
|
||||
namespace floatpump::newmenu {
|
||||
namespace floatpump::menu {
|
||||
|
||||
class Menu_Controller {
|
||||
public:
|
||||
|
@ -1,38 +0,0 @@
|
||||
//
|
||||
// Created by robtor on 04.01.23.
|
||||
//
|
||||
|
||||
#ifndef FLOATPUMP_MENU_ENTRY_H
|
||||
#define FLOATPUMP_MENU_ENTRY_H
|
||||
|
||||
#include <Menu_Entry_Type_Delegate.h>
|
||||
|
||||
|
||||
namespace floatpump::menu {
|
||||
|
||||
class Menu_Entry {
|
||||
public:
|
||||
Menu_Entry(Menu_Entry_Type_Delegate &type, std::string name) : m_type(type), m_name(name) {};
|
||||
|
||||
|
||||
|
||||
//Retreive string for putting on display
|
||||
std::string printLine();
|
||||
|
||||
void action_press();
|
||||
|
||||
void action_increase();
|
||||
|
||||
void action_decrease();
|
||||
|
||||
//Check if currently entered
|
||||
bool isEntered();
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
menu::Menu_Entry_Type_Delegate &m_type; //Saves type of this menu entry
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //FLOATPUMP_MENU_ENTRY_H
|
@ -1,34 +0,0 @@
|
||||
//
|
||||
// Created by robtor on 09.12.22.
|
||||
//
|
||||
|
||||
#ifndef FLOATPUMP_MENU_ENTRY_TYPE_CHECKABLE_H
|
||||
#define FLOATPUMP_MENU_ENTRY_TYPE_CHECKABLE_H
|
||||
|
||||
#include "Menu_Entry_Type_Delegate.h"
|
||||
|
||||
namespace floatpump::menu {
|
||||
|
||||
class Menu_Entry_Type_Checkable : public Menu_Entry_Type_Delegate {
|
||||
public:
|
||||
explicit Menu_Entry_Type_Checkable(bool mState);
|
||||
|
||||
std::string toString() override;
|
||||
|
||||
void u_press() override;
|
||||
|
||||
void u_increase(uint16_t steps) override;
|
||||
|
||||
void u_decrease(uint16_t steps) override;
|
||||
|
||||
bool isEntered() override;
|
||||
|
||||
void linkConfig(bool *link);
|
||||
|
||||
private:
|
||||
bool *m_state;
|
||||
};
|
||||
|
||||
} // menu
|
||||
|
||||
#endif //FLOATPUMP_MENU_ENTRY_TYPE_CHECKABLE_H
|
@ -1,26 +0,0 @@
|
||||
//
|
||||
// Created by robtor on 09.12.22.
|
||||
//
|
||||
|
||||
#ifndef FLOATPUMP_MENU_ENTRY_DELEGATE_H
|
||||
#define FLOATPUMP_MENU_ENTRY_DELEGATE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace floatpump {
|
||||
namespace menu {
|
||||
|
||||
|
||||
class Menu_Entry_Type_Delegate {
|
||||
public:
|
||||
virtual std::string toString() = 0;
|
||||
virtual void u_press() = 0;
|
||||
virtual void u_increase(uint16_t steps = 1) = 0;
|
||||
virtual void u_decrease(uint16_t steps = 1) = 0;
|
||||
virtual bool isEntered() = 0;
|
||||
};
|
||||
|
||||
} // floatpump
|
||||
} // menu
|
||||
|
||||
#endif //FLOATPUMP_MENU_ENTRY_DELEGATE_H
|
@ -1,34 +0,0 @@
|
||||
//
|
||||
// Created by robtor on 09.12.22.
|
||||
//
|
||||
|
||||
#ifndef FLOATPUMP_MENU_ENTRY_TYPE_EXECUTE_H
|
||||
#define FLOATPUMP_MENU_ENTRY_TYPE_EXECUTE_H
|
||||
|
||||
#include "Menu_Entry_Type_Delegate.h"
|
||||
|
||||
namespace floatpump::menu {
|
||||
|
||||
class Menu_Entry_Type_Execute : public Menu_Entry_Type_Delegate {
|
||||
public:
|
||||
explicit Menu_Entry_Type_Execute() {};
|
||||
|
||||
std::string toString() override;
|
||||
|
||||
void u_press() override;
|
||||
|
||||
void u_increase(uint16_t steps) override;
|
||||
|
||||
void u_decrease(uint16_t steps) override;
|
||||
|
||||
bool isEntered() override;
|
||||
|
||||
void linkConfig(bool *link);
|
||||
|
||||
private:
|
||||
bool *m_state;
|
||||
};
|
||||
|
||||
} // menu
|
||||
|
||||
#endif //FLOATPUMP_MENU_ENTRY_TYPE_EXECUTE_H
|
@ -1,38 +0,0 @@
|
||||
//
|
||||
// Created by robtor on 04.01.23.
|
||||
//
|
||||
|
||||
#ifndef FLOATPUMP_MENU_ENTRY_TYPE_NUMERIC_H
|
||||
#define FLOATPUMP_MENU_ENTRY_TYPE_NUMERIC_H
|
||||
|
||||
#include <string>
|
||||
#include "Menu_Entry_Type_Delegate.h"
|
||||
|
||||
namespace floatpump {
|
||||
namespace menu {
|
||||
|
||||
class Menu_Entry_Type_Numeric : public Menu_Entry_Type_Delegate {
|
||||
public:
|
||||
explicit Menu_Entry_Type_Numeric(uint16_t mValue);
|
||||
|
||||
std::string toString() override;
|
||||
|
||||
void u_press() override;
|
||||
|
||||
void u_increase(uint16_t steps) override;
|
||||
|
||||
void u_decrease(uint16_t steps) override;
|
||||
|
||||
bool isEntered() override;
|
||||
|
||||
void linkConfig(uint16_t *link);
|
||||
|
||||
private:
|
||||
uint16_t *m_value = 0;
|
||||
bool m_entered = false;
|
||||
};
|
||||
|
||||
} // floatpump
|
||||
} // menu
|
||||
|
||||
#endif //FLOATPUMP_MENU_ENTRY_TYPE_NUMERIC_H
|
@ -1,39 +0,0 @@
|
||||
//
|
||||
// Created by robtor on 05.01.23.
|
||||
//
|
||||
|
||||
#ifndef FLOATPUMP_MENU_ENTRY_TYPE_PERCENT_H
|
||||
#define FLOATPUMP_MENU_ENTRY_TYPE_PERCENT_H
|
||||
|
||||
#include "Menu_Entry_Type_Delegate.h"
|
||||
|
||||
namespace floatpump::menu {
|
||||
|
||||
|
||||
class Menu_Entry_Type_Percent : public floatpump::menu::Menu_Entry_Type_Delegate {
|
||||
public:
|
||||
explicit Menu_Entry_Type_Percent(uint8_t val);;
|
||||
|
||||
std::string toString() override;
|
||||
|
||||
void u_press() override;
|
||||
|
||||
void u_increase(uint16_t steps) override;
|
||||
|
||||
void u_decrease(uint16_t steps) override;
|
||||
|
||||
bool isEntered() override;
|
||||
|
||||
void linkConfig(uint8_t *link);
|
||||
|
||||
private:
|
||||
uint8_t *m_value = nullptr;
|
||||
bool m_entered = false;
|
||||
};
|
||||
|
||||
} //floatpump
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //FLOATPUMP_MENU_ENTRY_TYPE_PERCENT_H
|
@ -1,51 +0,0 @@
|
||||
//
|
||||
// Created by robtor on 06.01.23.
|
||||
//
|
||||
|
||||
#ifndef FLOATPUMP_MENU_ENTRY_TYPE_READONLY_H
|
||||
#define FLOATPUMP_MENU_ENTRY_TYPE_READONLY_H
|
||||
|
||||
#include "Menu_Entry_Type_Delegate.h"
|
||||
|
||||
namespace floatpump {
|
||||
namespace menu {
|
||||
|
||||
template <class T>
|
||||
class Menu_Entry_Type_ReadOnly : public Menu_Entry_Type_Delegate {
|
||||
public:
|
||||
explicit Menu_Entry_Type_ReadOnly(T store) {
|
||||
m_store = new T(store);
|
||||
};
|
||||
|
||||
std::string toString() override {
|
||||
return std::to_string(*m_store);
|
||||
}
|
||||
|
||||
void u_press() override {
|
||||
|
||||
}
|
||||
|
||||
void u_increase(uint16_t steps) override {
|
||||
|
||||
}
|
||||
|
||||
void u_decrease(uint16_t steps) override {
|
||||
|
||||
}
|
||||
|
||||
bool isEntered() override {
|
||||
return false;
|
||||
}
|
||||
|
||||
void linkConfig(T *link) {
|
||||
m_store = link;
|
||||
}
|
||||
|
||||
private:
|
||||
T *m_store;
|
||||
};
|
||||
|
||||
} // floatpump
|
||||
} // menu
|
||||
|
||||
#endif //FLOATPUMP_MENU_ENTRY_TYPE_READONLY_H
|
@ -1,35 +0,0 @@
|
||||
//
|
||||
// Created by robtor on 05.01.23.
|
||||
//
|
||||
|
||||
#ifndef FLOATPUMP_MENU_ENTRY_TYPE_TIME_H
|
||||
#define FLOATPUMP_MENU_ENTRY_TYPE_TIME_H
|
||||
|
||||
#include "Menu_Entry_Type_Delegate.h"
|
||||
|
||||
namespace floatpump::menu {
|
||||
|
||||
class Menu_Entry_Type_Time : public Menu_Entry_Type_Delegate{
|
||||
public:
|
||||
Menu_Entry_Type_Time(uint8_t hour, uint8_t minute, uint8_t second);;
|
||||
|
||||
std::string toString() override;
|
||||
|
||||
void u_press() override;
|
||||
|
||||
void u_increase(uint16_t steps) override;
|
||||
|
||||
void u_decrease(uint16_t steps) override;
|
||||
|
||||
bool isEntered() override;
|
||||
|
||||
void linkConfig(uint8_t *c_hour, uint8_t *c_minute, uint8_t *c_second);
|
||||
|
||||
private:
|
||||
uint8_t m_entered = 0;
|
||||
uint8_t *m_hour, *m_minute, *m_second = nullptr;
|
||||
};
|
||||
|
||||
} // menu
|
||||
|
||||
#endif //FLOATPUMP_MENU_ENTRY_TYPE_TIME_H
|
@ -12,7 +12,7 @@
|
||||
#include <optional>
|
||||
|
||||
namespace floatpump {
|
||||
namespace newmenu {
|
||||
namespace menu {
|
||||
|
||||
struct IMenuEntry {
|
||||
virtual ~IMenuEntry() = default;
|
||||
|
@ -1,69 +0,0 @@
|
||||
//
|
||||
// Created by robtor on 09.12.22.
|
||||
//
|
||||
|
||||
#include "Menu.h"
|
||||
|
||||
namespace floatpump::menu {
|
||||
void Menu::addEntry(const Menu_Entry &entry) {
|
||||
m_entries.push_back(entry);
|
||||
}
|
||||
|
||||
void Menu::addSubmenu(Menu *submenu) {
|
||||
//Always set this menu as parent of created submenus within this menu
|
||||
submenu->m_parent = this;
|
||||
m_submenus.push_back(submenu);
|
||||
}
|
||||
|
||||
std::string Menu::printLine() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
std::vector<std::string> Menu::getDisplayList() {
|
||||
std::vector<std::string> list;
|
||||
|
||||
list.reserve(m_submenus.size() + m_entries.size());
|
||||
|
||||
//Append all Submenus
|
||||
for (auto &m_submenu: m_submenus) {
|
||||
list.push_back(m_submenu->printLine());
|
||||
}
|
||||
|
||||
//Append all Entries
|
||||
for (auto &m_entry: m_entries) {
|
||||
list.push_back(m_entry.printLine());
|
||||
}
|
||||
|
||||
//Append Go-Back-Entry if we are within a submenu
|
||||
if (m_parent != nullptr) {
|
||||
list.emplace_back("<- Go Back");
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
unsigned int Menu::getAllEntriesNum() const {
|
||||
//Add 1 to this if we have a parent menu -> makes Go-Back-Entry selectable
|
||||
return (m_entries.size() + m_submenus.size()) + ((m_parent != nullptr) ? 1 : 0);
|
||||
}
|
||||
|
||||
Menu *Menu::getSubmenu(int index) {
|
||||
if (index >= 0 && index < m_submenus.size()) {
|
||||
return m_submenus[index];
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Menu_Entry *Menu::getEntry(int index) {
|
||||
if (index >= m_submenus.size() && index < m_entries.size() + m_submenus.size()) {
|
||||
return &m_entries[index - m_submenus.size()];
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Menu *Menu::getParent() {
|
||||
return m_parent;
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "Menu_Controller.h"
|
||||
|
||||
namespace floatpump::newmenu {
|
||||
namespace floatpump::menu {
|
||||
|
||||
void Menu_Controller::execute() {
|
||||
displayMenu(m_menu);
|
||||
|
@ -1,35 +0,0 @@
|
||||
//
|
||||
// Created by robtor on 04.01.23.
|
||||
//
|
||||
|
||||
#include "Menu_Entry.h"
|
||||
|
||||
namespace floatpump {
|
||||
namespace menu {
|
||||
|
||||
std::string Menu_Entry::printLine() {
|
||||
//We have 19 characters width for displaying the entry -> fill with spaces
|
||||
int spaces = 19 - (m_name.length() + m_type.toString().length());
|
||||
std::string spacer;
|
||||
if(spaces > 0)
|
||||
spacer.append(spaces, ' ');
|
||||
return m_name + spacer + m_type.toString();
|
||||
}
|
||||
|
||||
void Menu_Entry::action_press() {
|
||||
m_type.u_press();
|
||||
}
|
||||
|
||||
void Menu_Entry::action_increase() {
|
||||
m_type.u_increase(1);
|
||||
}
|
||||
|
||||
void Menu_Entry::action_decrease() {
|
||||
m_type.u_decrease(1);
|
||||
}
|
||||
|
||||
bool Menu_Entry::isEntered() {
|
||||
return m_type.isEntered();
|
||||
}
|
||||
} // floatpump
|
||||
} // menu
|
@ -1,39 +0,0 @@
|
||||
//
|
||||
// Created by robtor on 09.12.22.
|
||||
//
|
||||
|
||||
#include "Menu_Entry_Type_Checkable.h"
|
||||
|
||||
namespace floatpump {
|
||||
namespace menu {
|
||||
|
||||
|
||||
Menu_Entry_Type_Checkable::Menu_Entry_Type_Checkable(bool mState) {
|
||||
m_state = new bool(mState);
|
||||
}
|
||||
|
||||
std::string Menu_Entry_Type_Checkable::toString() {
|
||||
return {(*m_state) ? "ON " : "OFF"};
|
||||
}
|
||||
|
||||
void Menu_Entry_Type_Checkable::u_press() {
|
||||
*m_state = !(*m_state);
|
||||
}
|
||||
|
||||
void Menu_Entry_Type_Checkable::u_increase(uint16_t steps) {
|
||||
|
||||
}
|
||||
|
||||
void Menu_Entry_Type_Checkable::u_decrease(uint16_t steps) {
|
||||
|
||||
}
|
||||
|
||||
bool Menu_Entry_Type_Checkable::isEntered() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Menu_Entry_Type_Checkable::linkConfig(bool *link) {
|
||||
m_state = link;
|
||||
}
|
||||
} // floatpump
|
||||
} // menu
|
@ -1,32 +0,0 @@
|
||||
//
|
||||
// Created by robtor on 10.01.23.
|
||||
//
|
||||
#include "Menu_Entry_Type_Execute.h"
|
||||
|
||||
namespace floatpump::menu {
|
||||
|
||||
std::string floatpump::menu::Menu_Entry_Type_Execute::toString() {
|
||||
return {(*m_state) ? "[--]" : "[XX]"};
|
||||
}
|
||||
|
||||
void floatpump::menu::Menu_Entry_Type_Execute::u_press() {
|
||||
*m_state = true;
|
||||
}
|
||||
|
||||
void floatpump::menu::Menu_Entry_Type_Execute::u_increase(uint16_t steps) {
|
||||
|
||||
}
|
||||
|
||||
void floatpump::menu::Menu_Entry_Type_Execute::u_decrease(uint16_t steps) {
|
||||
|
||||
}
|
||||
|
||||
bool floatpump::menu::Menu_Entry_Type_Execute::isEntered() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void floatpump::menu::Menu_Entry_Type_Execute::linkConfig(bool *link) {
|
||||
m_state = link;
|
||||
}
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
//
|
||||
// Created by robtor on 04.01.23.
|
||||
//
|
||||
|
||||
#include "Menu_Entry_Type_Numeric.h"
|
||||
|
||||
namespace floatpump {
|
||||
namespace menu {
|
||||
|
||||
Menu_Entry_Type_Numeric::Menu_Entry_Type_Numeric(uint16_t mValue) {
|
||||
m_value = new uint16_t(mValue);
|
||||
}
|
||||
|
||||
std::string Menu_Entry_Type_Numeric::toString() {
|
||||
if (m_entered) {
|
||||
return std::string("> " + std::to_string(*m_value));
|
||||
} else {
|
||||
return std::string(" " + std::to_string(*m_value));
|
||||
}
|
||||
}
|
||||
|
||||
void Menu_Entry_Type_Numeric::u_press() {
|
||||
m_entered = !m_entered;
|
||||
}
|
||||
|
||||
void Menu_Entry_Type_Numeric::u_increase(uint16_t steps) {
|
||||
(*m_value)++;
|
||||
}
|
||||
|
||||
void Menu_Entry_Type_Numeric::u_decrease(uint16_t steps) {
|
||||
(*m_value)--;
|
||||
}
|
||||
|
||||
bool Menu_Entry_Type_Numeric::isEntered() {
|
||||
return m_entered;
|
||||
}
|
||||
|
||||
void Menu_Entry_Type_Numeric::linkConfig(uint16_t *link) {
|
||||
m_value = link;
|
||||
}
|
||||
} // floatpump
|
||||
} // menu
|
@ -1,40 +0,0 @@
|
||||
//
|
||||
// Created by robtor on 05.01.23.
|
||||
//
|
||||
|
||||
#include "Menu_Entry_Type_Percent.h"
|
||||
|
||||
std::string floatpump::menu::Menu_Entry_Type_Percent::toString() {
|
||||
if (m_entered) {
|
||||
return std::string("> %" + std::to_string(*m_value));
|
||||
} else {
|
||||
return std::string(" %" + std::to_string(*m_value));
|
||||
}
|
||||
}
|
||||
|
||||
void floatpump::menu::Menu_Entry_Type_Percent::u_press() {
|
||||
m_entered = !m_entered;
|
||||
}
|
||||
|
||||
void floatpump::menu::Menu_Entry_Type_Percent::u_increase(uint16_t steps) {
|
||||
if (*m_value < 100)
|
||||
(*m_value)++;
|
||||
}
|
||||
|
||||
void floatpump::menu::Menu_Entry_Type_Percent::u_decrease(uint16_t steps) {
|
||||
if (*m_value > 0) {
|
||||
(*m_value)--;
|
||||
}
|
||||
}
|
||||
|
||||
bool floatpump::menu::Menu_Entry_Type_Percent::isEntered() {
|
||||
return m_entered;
|
||||
}
|
||||
|
||||
floatpump::menu::Menu_Entry_Type_Percent::Menu_Entry_Type_Percent(uint8_t val) {
|
||||
m_value = new uint8_t(val);
|
||||
}
|
||||
|
||||
void floatpump::menu::Menu_Entry_Type_Percent::linkConfig(uint8_t *link) {
|
||||
m_value = link;
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
//
|
||||
// Created by robtor on 06.01.23.
|
||||
//
|
||||
|
||||
#include "Menu_Entry_Type_ReadOnly.h"
|
||||
|
||||
namespace floatpump {
|
||||
namespace menu {
|
||||
} // floatpump
|
||||
} // menu
|
@ -1,73 +0,0 @@
|
||||
//
|
||||
// Created by robtor on 05.01.23.
|
||||
//
|
||||
|
||||
#include "Menu_Entry_Type_Time.h"
|
||||
|
||||
namespace floatpump {
|
||||
namespace menu {
|
||||
std::string Menu_Entry_Type_Time::toString() {
|
||||
switch(m_entered) {
|
||||
case 0:
|
||||
return std::string(" " + std::to_string(*m_hour) + ":" + std::to_string(*m_minute) + ":" + std::to_string(*m_second)); break;
|
||||
case 1:
|
||||
return std::string("#" + std::to_string(*m_hour) + ":" + std::to_string(*m_minute) + ":" + std::to_string(*m_second)); break;
|
||||
case 2:
|
||||
return std::string(" " + std::to_string(*m_hour) + "#" + std::to_string(*m_minute) + ":" + std::to_string(*m_second)); break;
|
||||
case 3:
|
||||
return std::string(" " + std::to_string(*m_hour) + ":" + std::to_string(*m_minute) + "#" + std::to_string(*m_second)); break;
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
void Menu_Entry_Type_Time::u_press() {
|
||||
if(m_entered < 3) {
|
||||
m_entered++;
|
||||
} else {
|
||||
m_entered = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Menu_Entry_Type_Time::u_increase(uint16_t steps) {
|
||||
switch(m_entered) {
|
||||
case 1:
|
||||
(*m_hour < 23) ? (*m_hour)++ : *m_hour = 0; break;
|
||||
case 2:
|
||||
(*m_minute < 59) ? (*m_minute)++ : *m_minute = 0; break;
|
||||
case 3:
|
||||
(*m_second < 59) ? (*m_second)++ : *m_second = 0; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Menu_Entry_Type_Time::u_decrease(uint16_t steps) {
|
||||
switch(m_entered) {
|
||||
case 1:
|
||||
(*m_hour > 0) ? (*m_hour)-- : *m_hour = 23; break;
|
||||
case 2:
|
||||
(*m_minute > 0) ? (*m_minute)-- : *m_minute = 59; break;
|
||||
case 3:
|
||||
(*m_second > 0) ? (*m_second)-- : *m_second = 59; break;
|
||||
}
|
||||
}
|
||||
|
||||
bool Menu_Entry_Type_Time::isEntered() {
|
||||
if(m_entered > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Menu_Entry_Type_Time::Menu_Entry_Type_Time(uint8_t hour, uint8_t minute, uint8_t second) {
|
||||
m_hour = new uint8_t (hour);
|
||||
m_minute = new uint8_t (minute);
|
||||
m_second = new uint8_t (second);
|
||||
}
|
||||
|
||||
void Menu_Entry_Type_Time::linkConfig(uint8_t *c_hour, uint8_t *c_minute, uint8_t *c_second) {
|
||||
m_hour = c_hour;
|
||||
m_minute = c_minute;
|
||||
m_second = c_second;
|
||||
}
|
||||
} // floatpump
|
||||
} // menu
|
Loading…
Reference in New Issue
Block a user