WIP: Added readonly entry

This commit is contained in:
Robin Dietzel 2023-01-06 14:23:42 +01:00
parent 13116d19b7
commit cf70dcd5e5
4 changed files with 72 additions and 1 deletions

View File

@ -7,6 +7,6 @@
// Auto generated header file containing the last git revision
#define GIT_HASH "7a3009b"
#define GIT_HASH "be1b884"
#endif //FLOATPUMP_GIT_REVISION_TEMPLATE_H

View File

@ -10,6 +10,7 @@
#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"
@ -111,7 +112,14 @@ int main(void) {
Menu submenu("Submenu1");
Menu_Entry_Type_Checkable entrysub(true);
Menu_Entry sube(&entrysub, "yay dies sub!");
Menu_Entry_Type_ReadOnly<uint16_t> entryread(42);
uint16_t wurst = 0;
entryread.linkConfig(&wurst);
Menu_Entry sube2(&entryread, "Read Only test ");
submenu.addEntry(sube);
submenu.addEntry(sube2);
mainmenu.addSubmenu(&submenu);
@ -137,6 +145,8 @@ int main(void) {
}
HAL_Delay(100);
wurst++;
if(globalConfig.testbool.getValue()) {
HAL_GPIO_WritePin(OCHAN0_GPIO_Port, OCHAN0_Pin, GPIO_PIN_SET);
} else {

View File

@ -0,0 +1,51 @@
//
// 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

View File

@ -0,0 +1,10 @@
//
// Created by robtor on 06.01.23.
//
#include "Menu_Entry_Type_ReadOnly.h"
namespace floatpump {
namespace menu {
} // floatpump
} // menu