mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-14 06:23:07 +01:00
allow to set default and hide for cfg values in hardware defs
This commit is contained in:
@@ -159,6 +159,24 @@ void GwConfigHandler::toHex(unsigned long v, char *buffer, size_t bsize)
|
||||
buffer[2 * i] = 0;
|
||||
}
|
||||
|
||||
std::vector<String> GwConfigHandler::getHidden() const{
|
||||
std::vector<String> rt;
|
||||
rt.reserve(numHidden());
|
||||
for (int i=0L;i<getNumConfig();i++){
|
||||
if (configs[i]->isHidden()){
|
||||
rt.push_back(configs[i]->getName());
|
||||
};
|
||||
}
|
||||
return rt;
|
||||
}
|
||||
int GwConfigHandler::numHidden() const{
|
||||
int rt=0;
|
||||
for (int i=0L;i<getNumConfig();i++){
|
||||
if (configs[i]->isHidden()) rt++;
|
||||
}
|
||||
return rt;
|
||||
}
|
||||
|
||||
void GwNmeaFilter::handleToken(String token, int index){
|
||||
switch(index){
|
||||
case 0:
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
#include <Preferences.h>
|
||||
#include "GwLog.h"
|
||||
#include "GwConfigItem.h"
|
||||
#include "GwHardware.h"
|
||||
#include "GwConfigDefinitions.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
class GwConfigHandler: public GwConfigDefinitions{
|
||||
@@ -28,6 +30,8 @@ class GwConfigHandler: public GwConfigDefinitions{
|
||||
int getInt(const String name,int defaultv=0) const;
|
||||
GwConfigInterface * getConfigItem(const String name, bool dummy=false) const;
|
||||
bool checkPass(String hash);
|
||||
std::vector<String> getHidden() const;
|
||||
int numHidden() const;
|
||||
/**
|
||||
* change the value of a config item
|
||||
* will become a noop after stopChanges has been called
|
||||
|
||||
@@ -10,12 +10,14 @@ class GwConfigInterface{
|
||||
const char * initialValue;
|
||||
String value;
|
||||
bool secret=false;
|
||||
bool hidden=false;
|
||||
public:
|
||||
GwConfigInterface(const String &name, const char * initialValue, bool secret=false){
|
||||
GwConfigInterface(const String &name, const char * initialValue, bool secret=false, bool hidden=false){
|
||||
this->name=name;
|
||||
this->initialValue=initialValue;
|
||||
this->value=initialValue;
|
||||
this->secret=secret;
|
||||
this->hidden=hidden;
|
||||
}
|
||||
virtual String asString() const{
|
||||
return value;
|
||||
@@ -41,6 +43,9 @@ class GwConfigInterface{
|
||||
String getDefault() const {
|
||||
return initialValue;
|
||||
}
|
||||
bool isHidden() const {
|
||||
return hidden;
|
||||
}
|
||||
friend class GwConfigHandler;
|
||||
};
|
||||
|
||||
|
||||
@@ -144,6 +144,14 @@
|
||||
#define GWSERIAL_TYPE GWSERIAL_TYPE_UNI
|
||||
#endif
|
||||
|
||||
//M5 GPS (Atomic GPS Base)
|
||||
#ifdef M5_GPS_KIT
|
||||
#define GWSERIAL_RX BOARD_LEFT1
|
||||
#define GWSERIAL_TYPE GWSERIAL_TYPE_RX
|
||||
#define CFGGDEFAULT_serialBaud "9600"
|
||||
#define CFGHIDE_serialBaud
|
||||
#endif
|
||||
|
||||
//below we define the final device config based on the above
|
||||
//boards and peripherals
|
||||
//this allows us to easily also set them from outside
|
||||
|
||||
Reference in New Issue
Block a user