Refactored config

This commit is contained in:
Magnus
2021-03-29 18:37:37 +02:00
parent fb9fde73a4
commit 09cc5e35b6
5 changed files with 35 additions and 35 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
{ "project":"gravmon", "version":"0.2.3", "html": [ "index.min.htm", "device.min.htm", "config.min.htm", "about.min.htm" ] } { "project":"gravmon", "version":"0.2.4", "html": [ "index.min.htm", "device.min.htm", "config.min.htm", "about.min.htm" ] }

View File

@ -26,7 +26,7 @@ build_flags = #-O0 -Wl,-Map,output.map
#-D SKIP_SLEEPMODE #-D SKIP_SLEEPMODE
-D USE_LITTLEFS=true -D USE_LITTLEFS=true
#-D EMBED_HTML #-D EMBED_HTML
-D CFG_APPVER="\"0.2.3\"" -D CFG_APPVER="\"0.2.4\""
lib_deps = lib_deps =
# https://github.com/jrowberg/i2cdevlib.git # Using local copy of this library # https://github.com/jrowberg/i2cdevlib.git # Using local copy of this library
https://github.com/codeplea/tinyexpr https://github.com/codeplea/tinyexpr

View File

@ -86,23 +86,23 @@ class Config {
bool saveNeeded; bool saveNeeded;
// Device configuration // Device configuration
char id[10]; String id;
char mDNS[30]; String mDNS;
char otaURL[200]; String otaURL;
char tempFormat; // C, F char tempFormat; // C, F
float voltageFactor; float voltageFactor;
float tempSensorAdj; // This value will be added to the read sensor value float tempSensorAdj; // This value will be added to the read sensor value
// Push target settings // Push target settings
char brewfatherPushTarget[200]; String brewfatherPushTarget;
char httpPushTarget[200]; String httpPushTarget;
char httpPushTarget2[200]; String httpPushTarget2;
int pushInterval; int pushInterval;
// Gravity and temperature calculations // Gravity and temperature calculations
char gravityFormula[200]; String gravityFormula;
bool gravityTempAdj; // true, false bool gravityTempAdj; // true, false
char gravityFormat; // G, P char gravityFormat; // G, P
// Gyro calibration data // Gyro calibration data
RawGyroData gyroCalibration; // Holds the gyro calibration constants (6 * int16_t) RawGyroData gyroCalibration; // Holds the gyro calibration constants (6 * int16_t)
@ -112,30 +112,30 @@ class Config {
public: public:
Config(); Config();
const char* getID() { return &id[0]; }; const char* getID() { return id.c_str(); };
const char* getMDNS() { return &mDNS[0]; } const char* getMDNS() { return mDNS.c_str(); }
void setMDNS( const char* s ) { strncpy( &mDNS[0], s, sizeof(mDNS)-1); saveNeeded = true; } void setMDNS( String s ) { mDNS = s; saveNeeded = true; }
const char* getOtaURL() { return &otaURL[0]; } const char* getOtaURL() { return otaURL.c_str(); }
void setOtaURL( const char* s ) { strncpy( &otaURL[0], s, sizeof(otaURL)-1); saveNeeded = true; } void setOtaURL( String s ) { otaURL = s; saveNeeded = true; }
bool isOtaActive() { return strlen(&otaURL[0])>0?true:false; } bool isOtaActive() { return otaURL.length()>0?true:false; }
const char* getBrewfatherPushTarget() { return &brewfatherPushTarget[0]; } const char* getBrewfatherPushTarget() { return brewfatherPushTarget.c_str(); }
void setBrewfatherPushTarget( const char* s ) { strncpy(&brewfatherPushTarget[0], s, sizeof(brewfatherPushTarget)-1); saveNeeded = true; } void setBrewfatherPushTarget( String s ) { brewfatherPushTarget = s; saveNeeded = true; }
bool isBrewfatherActive() { return strlen(&brewfatherPushTarget[0])>0?true:false; } bool isBrewfatherActive() { return brewfatherPushTarget.length()>0?true:false; }
const char* getHttpPushTarget() { return &httpPushTarget[0]; } const char* getHttpPushTarget() { return httpPushTarget.c_str(); }
void setHttpPushTarget( const char* s ) { strncpy(&httpPushTarget[0], s, sizeof(httpPushTarget)-1); saveNeeded = true; } void setHttpPushTarget( String s ) { httpPushTarget = s; saveNeeded = true; }
bool isHttpActive() { return strlen(&httpPushTarget[0])>0?true:false; } bool isHttpActive() { return httpPushTarget.length()>0?true:false; }
const char* getHttpPushTarget2() { return &httpPushTarget2[0]; } const char* getHttpPushTarget2() { return httpPushTarget2.c_str(); }
void setHttpPushTarget2( const char* s ) { strncpy(&httpPushTarget2[0], s, sizeof(httpPushTarget2)-1); saveNeeded = true; } void setHttpPushTarget2( String s ) { httpPushTarget2 = s; saveNeeded = true; }
bool isHttpActive2() { return strlen(&httpPushTarget2[0])>0?true:false; } bool isHttpActive2() { return httpPushTarget2.length()>0?true:false; }
int getPushInterval() { return pushInterval; } int getPushInterval() { return pushInterval; }
void setPushInterval( int v ) { pushInterval = v; saveNeeded = true; } void setPushInterval( int v ) { pushInterval = v; saveNeeded = true; }
void setPushInterval( const char* s ) { pushInterval = atoi(s); saveNeeded = true; } void setPushInterval( String s ) { pushInterval = s.toInt(); saveNeeded = true; }
char getTempFormat() { return tempFormat; } char getTempFormat() { return tempFormat; }
void setTempFormat( char c ) { tempFormat = c; saveNeeded = true; } void setTempFormat( char c ) { tempFormat = c; saveNeeded = true; }
@ -144,14 +144,14 @@ class Config {
float getVoltageFactor() { return voltageFactor; } float getVoltageFactor() { return voltageFactor; }
void setVoltageFactor( float f ) { voltageFactor = f; saveNeeded = true; } void setVoltageFactor( float f ) { voltageFactor = f; saveNeeded = true; }
void setVoltageFactor( const char* s ) { voltageFactor = atof(s); saveNeeded = true; } void setVoltageFactor( String s ) { voltageFactor = s.toFloat(); saveNeeded = true; }
float getTempSensorAdj() { return tempSensorAdj; } float getTempSensorAdj() { return tempSensorAdj; }
void setTempSensorAdj( float f ) { tempSensorAdj = f; saveNeeded = true; } void setTempSensorAdj( float f ) { tempSensorAdj = f; saveNeeded = true; }
void setTempSensorAdj( const char* s ) { tempSensorAdj = atof(s); saveNeeded = true; } void setTempSensorAdj( String s ) { tempSensorAdj = s.toFloat(); saveNeeded = true; }
const char* getGravityFormula() { return &gravityFormula[0]; } const char* getGravityFormula() { return gravityFormula.c_str(); }
void setGravityFormula( const char* s ) { strncpy(&gravityFormula[0], s, sizeof(gravityFormula)-1); saveNeeded = true; } void setGravityFormula( String s ) { gravityFormula = s; saveNeeded = true; }
bool isGravityTempAdj() { return gravityTempAdj; } bool isGravityTempAdj() { return gravityTempAdj; }
void setGravityTempAdj( bool b ) { gravityTempAdj = b; saveNeeded = true; } void setGravityTempAdj( bool b ) { gravityTempAdj = b; saveNeeded = true; }