mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-13 05:53:06 +01:00
allow to hide config items from the ui and allow to change config values in the init function
This commit is contained in:
@@ -114,6 +114,16 @@ int GwConfigHandler::getInt(const String name,int defaultv) const{
|
||||
if (!i) return defaultv;
|
||||
return i->asInt();
|
||||
}
|
||||
void GwConfigHandler::stopChanges(){
|
||||
allowChanges=false;
|
||||
}
|
||||
bool GwConfigHandler::setValue(String name,String value){
|
||||
if (! allowChanges) return false;
|
||||
GwConfigInterface *i=getConfigItem(name,false);
|
||||
if (!i) return false;
|
||||
i->value=value;
|
||||
return true;
|
||||
}
|
||||
|
||||
void GwNmeaFilter::handleToken(String token, int index){
|
||||
switch(index){
|
||||
|
||||
@@ -14,11 +14,13 @@ class GwConfigHandler: public GwConfigDefinitions{
|
||||
GwLog *logger;
|
||||
typedef std::map<String,String> StringMap;
|
||||
StringMap changedValues;
|
||||
boolean allowChanges=true;
|
||||
public:
|
||||
public:
|
||||
GwConfigHandler(GwLog *logger);
|
||||
bool loadConfig();
|
||||
bool saveConfig();
|
||||
void stopChanges();
|
||||
bool updateValue(String name, String value);
|
||||
bool reset(bool save);
|
||||
String toString() const;
|
||||
@@ -27,6 +29,12 @@ class GwConfigHandler: public GwConfigDefinitions{
|
||||
bool getBool(const String name,bool defaultv=false) const ;
|
||||
int getInt(const String name,int defaultv=0) const;
|
||||
GwConfigInterface * getConfigItem(const String name, bool dummy=false) const;
|
||||
/**
|
||||
* change the value of a config item
|
||||
* will become a noop after stopChanges has been called
|
||||
* !use with care! no checks of the value
|
||||
*/
|
||||
bool setValue(String name, String value);
|
||||
private:
|
||||
};
|
||||
#endif
|
||||
Reference in New Issue
Block a user