mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-14 06:23:07 +01:00
allow to set a read only mode for config items, output compiler messages for overwritten configs, add m5 gps unit defs
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#define CFG_MESSAGES
|
||||
#include "GWConfig.h"
|
||||
#include <ArduinoJson.h>
|
||||
#include <string.h>
|
||||
@@ -159,20 +160,20 @@ void GwConfigHandler::toHex(unsigned long v, char *buffer, size_t bsize)
|
||||
buffer[2 * i] = 0;
|
||||
}
|
||||
|
||||
std::vector<String> GwConfigHandler::getHidden() const{
|
||||
std::vector<String> GwConfigHandler::getSpecial() const{
|
||||
std::vector<String> rt;
|
||||
rt.reserve(numHidden());
|
||||
rt.reserve(numSpecial());
|
||||
for (int i=0L;i<getNumConfig();i++){
|
||||
if (configs[i]->isHidden()){
|
||||
if (configs[i]->getType() != GwConfigInterface::NORMAL){
|
||||
rt.push_back(configs[i]->getName());
|
||||
};
|
||||
}
|
||||
return rt;
|
||||
}
|
||||
int GwConfigHandler::numHidden() const{
|
||||
int GwConfigHandler::numSpecial() const{
|
||||
int rt=0;
|
||||
for (int i=0L;i<getNumConfig();i++){
|
||||
if (configs[i]->isHidden()) rt++;
|
||||
if (configs[i]->getType() != GwConfigInterface::NORMAL) rt++;
|
||||
}
|
||||
return rt;
|
||||
}
|
||||
|
||||
@@ -30,8 +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;
|
||||
std::vector<String> getSpecial() const;
|
||||
int numSpecial() const;
|
||||
/**
|
||||
* change the value of a config item
|
||||
* will become a noop after stopChanges has been called
|
||||
|
||||
@@ -5,19 +5,25 @@
|
||||
|
||||
class GwConfigHandler;
|
||||
class GwConfigInterface{
|
||||
public:
|
||||
typedef enum {
|
||||
NORMAL=0,
|
||||
HIDDEN=1,
|
||||
READONLY=2
|
||||
} ConfigType;
|
||||
private:
|
||||
String name;
|
||||
const char * initialValue;
|
||||
String value;
|
||||
bool secret=false;
|
||||
bool hidden=false;
|
||||
ConfigType type=NORMAL;
|
||||
public:
|
||||
GwConfigInterface(const String &name, const char * initialValue, bool secret=false, bool hidden=false){
|
||||
GwConfigInterface(const String &name, const char * initialValue, bool secret=false,ConfigType type=NORMAL){
|
||||
this->name=name;
|
||||
this->initialValue=initialValue;
|
||||
this->value=initialValue;
|
||||
this->secret=secret;
|
||||
this->hidden=hidden;
|
||||
this->type=type;
|
||||
}
|
||||
virtual String asString() const{
|
||||
return value;
|
||||
@@ -43,8 +49,8 @@ class GwConfigInterface{
|
||||
String getDefault() const {
|
||||
return initialValue;
|
||||
}
|
||||
bool isHidden() const {
|
||||
return hidden;
|
||||
ConfigType getType() const {
|
||||
return type;
|
||||
}
|
||||
friend class GwConfigHandler;
|
||||
};
|
||||
@@ -67,5 +73,7 @@ class GwNmeaFilter{
|
||||
String toString();
|
||||
};
|
||||
|
||||
|
||||
#define __XSTR(x) __STR(x)
|
||||
#define __STR(x) #x
|
||||
#define __MSG(x) _Pragma (__STR(message (x)))
|
||||
#endif
|
||||
@@ -17,7 +17,7 @@
|
||||
#define GWSERIAL_TYPE_BI 2
|
||||
#define GWSERIAL_TYPE_RX 3
|
||||
#define GWSERIAL_TYPE_TX 4
|
||||
|
||||
#include <GwConfigItem.h>
|
||||
#include <HardwareSerial.h>
|
||||
#include "GwUserTasks.h"
|
||||
|
||||
@@ -148,8 +148,8 @@
|
||||
#ifdef M5_GPS_KIT
|
||||
#define GWSERIAL_RX BOARD_LEFT1
|
||||
#define GWSERIAL_TYPE GWSERIAL_TYPE_RX
|
||||
#define CFGGDEFAULT_serialBaud "9600"
|
||||
#define CFGHIDE_serialBaud
|
||||
#define CFGDEFAULT_serialBaud "9600"
|
||||
#define CFGMODE_serialBaud GwConfigInterface::READONLY
|
||||
#endif
|
||||
|
||||
//below we define the final device config based on the above
|
||||
@@ -181,6 +181,21 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//http://docs.m5stack.com/en/unit/gps
|
||||
#ifdef M5_GPS_UNIT
|
||||
#ifdef GWSERIAL_TYPE
|
||||
#define GWSERIAL2_RX GROOVE_PIN_2
|
||||
#define GWSERIAL2_TYPE GWSERIAL_TYPE_RX
|
||||
#define CFGDEFAULT_serialBaud "9600"
|
||||
#define CFGMODE_serialBaud GwConfigInterface::READONLY
|
||||
#else
|
||||
#define GWSERIAL_RX GROOVE_PIN_2
|
||||
#define GWSERIAL_TYPE GWSERIAL_TYPE_RX
|
||||
#define CFGDEFAULT_serial2Baud "9600"
|
||||
#define CFGMODE_serial2Baud GwConfigInterface::READONLY
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//can kit for M5 Atom
|
||||
#ifdef M5_CAN_KIT
|
||||
#define ESP32_CAN_TX_PIN BOARD_LEFT1
|
||||
|
||||
Reference in New Issue
Block a user