Enabled gyro temp

This commit is contained in:
Magnus Persson 2022-01-11 09:04:09 +01:00
parent df1981e3dd
commit 57f5816f63
15 changed files with 89 additions and 50 deletions

View File

@ -283,6 +283,14 @@
<input type="number" step=".1" class="form-control" name="temp-adjustment-value" id="temp-adjustment-value"> <input type="number" step=".1" class="form-control" name="temp-adjustment-value" id="temp-adjustment-value">
</div> </div>
</div> </div>
<div class="form-group row">
<label class="col-sm-4 form-check-label" for="gyro-temp">
Use gyro temperature (Experimental)
</label>
<div class="col-sm-8 form-check">
<input class="col-sm-1 form-check-input" type="checkbox" name="gyro-temp" id="gyro-temp">
</div>
</div>
<div class="form-group row"> <div class="form-group row">
<label for="ota-url" class="col-sm-4 col-form-label">OTA base URL:</label> <label for="ota-url" class="col-sm-4 col-form-label">OTA base URL:</label>
<div class="col-sm-8"> <div class="col-sm-8">
@ -332,7 +340,7 @@
var i = $("#sleep-interval").val() var i = $("#sleep-interval").val()
$("#sleep-interval-info").text( Math.floor(i/60) + " m " + (i%60) + " s" ) $("#sleep-interval-info").text( Math.floor(i/60) + " m " + (i%60) + " s" )
if(i<300) if(i>0 && i<300)
showWarning("A sleep-interval of <300s will reduce battery life, consider using 900s"); showWarning("A sleep-interval of <300s will reduce battery life, consider using 900s");
else else
hideWarning(); hideWarning();
@ -380,6 +388,7 @@
$("#gravity-formula").val(cfg["gravity-formula"]); $("#gravity-formula").val(cfg["gravity-formula"]);
$("#temp-adjustment-value").val(cfg["temp-adjustment-value"]); $("#temp-adjustment-value").val(cfg["temp-adjustment-value"]);
$("#gravity-temp-adjustment").prop( "checked", cfg["gravity-temp-adjustment"] ); $("#gravity-temp-adjustment").prop( "checked", cfg["gravity-temp-adjustment"] );
$("#gyro-temp").prop( "checked", cfg["gyro-temp"] );
$("#gyro-calibration-data").text( cfg["gyro-calibration-data"]["ax"] + "," + cfg["gyro-calibration-data"]["ay"] + "," + cfg["gyro-calibration-data"]["az"] + "," + cfg["gyro-calibration-data"]["gx"] + "," + cfg["gyro-calibration-data"]["gy"] + "," + cfg["gyro-calibration-data"]["gz"] ); $("#gyro-calibration-data").text( cfg["gyro-calibration-data"]["ax"] + "," + cfg["gyro-calibration-data"]["ay"] + "," + cfg["gyro-calibration-data"]["az"] + "," + cfg["gyro-calibration-data"]["gx"] + "," + cfg["gyro-calibration-data"]["gy"] + "," + cfg["gyro-calibration-data"]["gz"] );
$("#battery").text(cfg["battery"] + " V"); $("#battery").text(cfg["battery"] + " V");
$("#angle").text(cfg["angle"]); $("#angle").text(cfg["angle"]);

File diff suppressed because one or more lines are too long

View File

@ -23,7 +23,6 @@ build_flags =
-Wl,-Map,output.map -Wl,-Map,output.map
-D BAUD=${common_env_data.monitor_speed} -D BAUD=${common_env_data.monitor_speed}
-D ACTIVATE_OTA -D ACTIVATE_OTA
#-D USE_GYRO_TEMP # If this is enabled the DS18 will not be used, temp is read from the gyro.
#-D DEBUG_ESP_HTTP_CLIENT #-D DEBUG_ESP_HTTP_CLIENT
#-D DEBUG_ESP_HTTP_SERVER #-D DEBUG_ESP_HTTP_SERVER
#-D DEBUG_ESP_PORT=Serial #-D DEBUG_ESP_PORT=Serial
@ -66,9 +65,10 @@ extra_scripts =
build_unflags = build_unflags =
${common_env_data.build_unflags} ${common_env_data.build_unflags}
-D MAIN_DISABLE_LOGGING -D MAIN_DISABLE_LOGGING
-D WEB_DISABLE_LOGGING
build_flags = build_flags =
${common_env_data.build_flags} ${common_env_data.build_flags}
#-D PIO_FRAMEWORK_ARDUINO_ENABLE_EXCEPTIONS -D PIO_FRAMEWORK_ARDUINO_ENABLE_EXCEPTIONS
#-D SKIP_SLEEPMODE #-D SKIP_SLEEPMODE
-D DOUBLERESETDETECTOR_DEBUG=true -D DOUBLERESETDETECTOR_DEBUG=true
-D COLLECT_PERFDATA # This option will collect runtime data for a few defined methods to measure time, dumped to serial and/or influxdb -D COLLECT_PERFDATA # This option will collect runtime data for a few defined methods to measure time, dumped to serial and/or influxdb

View File

@ -52,6 +52,7 @@ Config::Config() {
setGravityTempAdj(false); setGravityTempAdj(false);
gyroCalibration = {0, 0, 0, 0, 0, 0}; gyroCalibration = {0, 0, 0, 0, 0, 0};
formulaData = {{0, 0, 0, 0, 0}, {1, 1, 1, 1, 1}}; formulaData = {{0, 0, 0, 0, 0}, {1, 1, 1, 1, 1}};
gyroTemp = false;
saveNeeded = false; saveNeeded = false;
} }
@ -79,6 +80,7 @@ void Config::createJson(DynamicJsonDocument& doc) {
doc[CFG_PARAM_GRAVITY_FORMAT] = String(getGravityFormat()); doc[CFG_PARAM_GRAVITY_FORMAT] = String(getGravityFormat());
doc[CFG_PARAM_TEMP_ADJ] = getTempSensorAdj(); doc[CFG_PARAM_TEMP_ADJ] = getTempSensorAdj();
doc[CFG_PARAM_GRAVITY_TEMP_ADJ] = isGravityTempAdj(); doc[CFG_PARAM_GRAVITY_TEMP_ADJ] = isGravityTempAdj();
doc[CFG_PARAM_GYRO_TEMP] = isGyroTemp();
JsonObject cal = doc.createNestedObject(CFG_PARAM_GYRO_CALIBRATION); JsonObject cal = doc.createNestedObject(CFG_PARAM_GYRO_CALIBRATION);
cal["ax"] = gyroCalibration.ax; cal["ax"] = gyroCalibration.ax;
@ -213,6 +215,8 @@ bool Config::loadFile() {
setGravityFormula(doc[CFG_PARAM_GRAVITY_FORMULA]); setGravityFormula(doc[CFG_PARAM_GRAVITY_FORMULA]);
if (!doc[CFG_PARAM_GRAVITY_TEMP_ADJ].isNull()) if (!doc[CFG_PARAM_GRAVITY_TEMP_ADJ].isNull())
setGravityTempAdj(doc[CFG_PARAM_GRAVITY_TEMP_ADJ].as<bool>()); setGravityTempAdj(doc[CFG_PARAM_GRAVITY_TEMP_ADJ].as<bool>());
if (!doc[CFG_PARAM_GYRO_TEMP].isNull())
setGyroTemp(doc[CFG_PARAM_GYRO_TEMP].as<bool>());
if (!doc[CFG_PARAM_GRAVITY_FORMAT].isNull()) { if (!doc[CFG_PARAM_GRAVITY_FORMAT].isNull()) {
String s = doc[CFG_PARAM_GRAVITY_FORMAT]; String s = doc[CFG_PARAM_GRAVITY_FORMAT];
setGravityFormat(s.charAt(0)); setGravityFormat(s.charAt(0));
@ -253,7 +257,7 @@ bool Config::loadFile() {
if (!doc[CFG_PARAM_FORMULA_DATA]["g4"].isNull()) if (!doc[CFG_PARAM_FORMULA_DATA]["g4"].isNull())
formulaData.g[3] = doc[CFG_PARAM_FORMULA_DATA]["g4"].as<double>(); formulaData.g[3] = doc[CFG_PARAM_FORMULA_DATA]["g4"].as<double>();
if (!doc[CFG_PARAM_FORMULA_DATA]["g5"].isNull()) if (!doc[CFG_PARAM_FORMULA_DATA]["g5"].isNull())
formulaData.g[4] = doc[CFG_PARAM_FORMULA_DATA]["g5"]; formulaData.g[4] = doc[CFG_PARAM_FORMULA_DATA]["g5"].as<double>();
myConfig.debug(); myConfig.debug();
saveNeeded = false; // Reset save flag saveNeeded = false; // Reset save flag
@ -303,6 +307,7 @@ void Config::debug() {
Log.verbose(F("CFG : Gravity format; '%c'." CR), getGravityFormat()); Log.verbose(F("CFG : Gravity format; '%c'." CR), getGravityFormat());
Log.verbose(F("CFG : Gravity temp adj; %s." CR), Log.verbose(F("CFG : Gravity temp adj; %s." CR),
isGravityTempAdj() ? "true" : "false"); isGravityTempAdj() ? "true" : "false");
Log.verbose(F("CFG : Gyro temp; %s." CR), isGyroTemp() ? "true" : "false");
Log.verbose(F("CFG : Push brewfather; '%s'." CR), getBrewfatherPushUrl()); Log.verbose(F("CFG : Push brewfather; '%s'." CR), getBrewfatherPushUrl());
Log.verbose(F("CFG : Push http; '%s'." CR), getHttpPushUrl()); Log.verbose(F("CFG : Push http; '%s'." CR), getHttpPushUrl());
Log.verbose(F("CFG : Push http2; '%s'." CR), getHttpPushUrl2()); Log.verbose(F("CFG : Push http2; '%s'." CR), getHttpPushUrl2());

View File

@ -69,6 +69,8 @@ SOFTWARE.
#define CFG_PARAM_TEMP_ADJ \ #define CFG_PARAM_TEMP_ADJ \
"temp-adjustment-value" // Correction value for temp sensor "temp-adjustment-value" // Correction value for temp sensor
#define CFG_PARAM_GYRO_CALIBRATION "gyro-calibration-data" // READ ONLY #define CFG_PARAM_GYRO_CALIBRATION "gyro-calibration-data" // READ ONLY
#define CFG_PARAM_GYRO_TEMP \
"gyro-temp" // True/False. Use temp sensor in gyro (only in gravity mode)
#define CFG_PARAM_FORMULA_DATA \ #define CFG_PARAM_FORMULA_DATA \
"formula-calculation-data" // Raw data for the formula calculation "formula-calculation-data" // Raw data for the formula calculation
@ -116,6 +118,7 @@ class Config {
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
int sleepInterval; int sleepInterval;
bool gyroTemp; // Experimental feature
// Wifi Config // Wifi Config
String wifiSSID; String wifiSSID;
@ -155,6 +158,12 @@ class Config {
saveNeeded = true; saveNeeded = true;
} }
const bool isGyroTemp() { return gyroTemp; }
void setGyroTemp(bool b) {
gyroTemp = b;
saveNeeded = true;
}
const char* getOtaURL() { return otaURL.c_str(); } const char* getOtaURL() { return otaURL.c_str(); }
void setOtaURL(String s) { void setOtaURL(String s) {
otaURL = s; otaURL = s;

View File

@ -220,7 +220,7 @@ void PerfLogging::pushInflux() {
"angle=%.4f,gyro-ax=%d,gyro-ay=%d,gyro-az=%d,gyro-temp=%.2f,ds-temp=%.2f", "angle=%.4f,gyro-ax=%d,gyro-ay=%d,gyro-az=%d,gyro-temp=%.2f,ds-temp=%.2f",
myGyro.getAngle(), myGyro.getLastGyroData().ax, myGyro.getAngle(), myGyro.getLastGyroData().ax,
myGyro.getLastGyroData().ay, myGyro.getLastGyroData().az, myGyro.getLastGyroData().ay, myGyro.getLastGyroData().az,
myGyro.getSensorTempC(), myTempSensor.getTempC()); myGyro.getSensorTempC(), myTempSensor.getTempC(myConfig.isGyroTemp()));
body += &buf[0]; body += &buf[0];
// Log.notice(F("PERF: data %s." CR), body.c_str() ); // Log.notice(F("PERF: data %s." CR), body.c_str() );

View File

@ -207,12 +207,12 @@ bool loopReadGravity() {
stableGyroMillis = millis(); // Reset timer stableGyroMillis = millis(); // Reset timer
LOG_PERF_START("loop-temp-read"); LOG_PERF_START("loop-temp-read");
float temp = myTempSensor.getTempC(); float temp = myTempSensor.getTempC(myConfig.isGyroTemp());
LOG_PERF_STOP("loop-temp-read"); LOG_PERF_STOP("loop-temp-read");
float gravity = calculateGravity(angle, temp); float gravity = calculateGravity(angle, temp);
float corrGravity = gravityTemperatureCorrection( float corrGravity =
gravity, temp, myConfig.getTempFormat()); gravityTemperatureCorrection(gravity, temp, myConfig.getTempFormat());
#if LOG_LEVEL == 6 && !defined(MAIN_DISABLE_LOGGING) #if LOG_LEVEL == 6 && !defined(MAIN_DISABLE_LOGGING)
Log.verbose(F("Main: Sensor values gyro angle=%F, temp=%F, gravity=%F, " Log.verbose(F("Main: Sensor values gyro angle=%F, temp=%F, gravity=%F, "
@ -249,6 +249,7 @@ void loopGravityOnInterval() {
LOG_PERF_START("loop-gyro-read"); LOG_PERF_START("loop-gyro-read");
myGyro.read(); myGyro.read();
LOG_PERF_STOP("loop-gyro-read"); LOG_PERF_STOP("loop-gyro-read");
myBatteryVoltage.read();
checkSleepMode(myGyro.getAngle(), myBatteryVoltage.getVoltage()); checkSleepMode(myGyro.getAngle(), myBatteryVoltage.getVoltage());
LOG_PERF_PUSH(); LOG_PERF_PUSH();
} }
@ -263,7 +264,7 @@ void goToSleep(int sleepInterval) {
Log.notice(F("MAIN: Entering deep sleep for %ds, run time %Fs, " Log.notice(F("MAIN: Entering deep sleep for %ds, run time %Fs, "
"battery=%FV." CR), "battery=%FV." CR),
sleepInterval, reduceFloatPrecision(runtime/1000, 2), volt); sleepInterval, reduceFloatPrecision(runtime / 1000, 2), volt);
LittleFS.end(); LittleFS.end();
myGyro.enterSleep(); myGyro.enterSleep();
LOG_PERF_STOP("run-time"); LOG_PERF_STOP("run-time");
@ -281,7 +282,6 @@ void loop() {
myWebServer.loop(); myWebServer.loop();
myWifi.loop(); myWifi.loop();
loopGravityOnInterval(); loopGravityOnInterval();
myBatteryVoltage.read();
break; break;
case RunMode::gravityMode: case RunMode::gravityMode:

View File

@ -22,8 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#include <DallasTemperature.h> #include <DallasTemperature.h>
#include <Wire.h>
#include <OneWire.h> #include <OneWire.h>
#include <Wire.h>
#include <config.hpp> #include <config.hpp>
#include <gyro.hpp> #include <gyro.hpp>
@ -35,16 +35,14 @@ SOFTWARE.
// //
float convertCtoF(float t) { return (t * 1.8) + 32.0; } float convertCtoF(float t) { return (t * 1.8) + 32.0; }
#if !defined(USE_GYRO_TEMP)
OneWire myOneWire(D6); OneWire myOneWire(D6);
DallasTemperature mySensors(&myOneWire); DallasTemperature mySensors(&myOneWire);
#define TEMPERATURE_PRECISION 9 #define TEMPERATURE_PRECISION 9
#endif
TempSensor myTempSensor; TempSensor myTempSensor;
// //
// Setup temp sensors // Setup DS18B20 temp sensor. Doing setup is not that time consuming.
// //
void TempSensor::setup() { void TempSensor::setup() {
#if defined(SIMULATE_TEMP) #if defined(SIMULATE_TEMP)
@ -52,9 +50,6 @@ void TempSensor::setup() {
return; return;
#endif #endif
#if defined(USE_GYRO_TEMP)
Log.notice(F("TSEN: Using temperature from gyro." CR));
#else
#if LOG_LEVEL == 6 && !defined(TSEN_DISABLE_LOGGING) #if LOG_LEVEL == 6 && !defined(TSEN_DISABLE_LOGGING)
Log.verbose(F("TSEN: Looking for temp sensors." CR)); Log.verbose(F("TSEN: Looking for temp sensors." CR));
#endif #endif
@ -67,7 +62,6 @@ void TempSensor::setup() {
#endif #endif
mySensors.setResolution(TEMPERATURE_PRECISION); mySensors.setResolution(TEMPERATURE_PRECISION);
} }
#endif
float t = myConfig.getTempSensorAdj(); float t = myConfig.getTempSensorAdj();
@ -89,21 +83,22 @@ void TempSensor::setup() {
// //
// Retrieving value from sensor, value is in Celcius // Retrieving value from sensor, value is in Celcius
// //
float TempSensor::getValue() { float TempSensor::getValue(bool useGyro) {
#if defined(SIMULATE_TEMP) #if defined(SIMULATE_TEMP)
return 21; return 21;
#endif #endif
#if defined(USE_GYRO_TEMP) if (useGyro) {
// When using the gyro temperature only the first read value will be accurate // When using the gyro temperature only the first read value will be
// so we will use this for processing. // accurate so we will use this for processing.
float c = myGyro.getInitialSensorTempC(); float c = myGyro.getInitialSensorTempC();
hasSensor = true;
return c;
#if LOG_LEVEL == 6 && !defined(TSEN_DISABLE_LOGGING) #if LOG_LEVEL == 6 && !defined(TSEN_DISABLE_LOGGING)
Log.verbose(F("TSEN: Reciving temp value for gyro sensor %F C." CR), c); Log.verbose(F("TSEN: Reciving temp value for gyro sensor %F C." CR), c);
#endif #endif
#else hasSensor = true;
return c;
}
// If we dont have sensors just return 0 // If we dont have sensors just return 0
if (!mySensors.getDS18Count()) { if (!mySensors.getDS18Count()) {
Log.error(F("TSEN: No temperature sensors found. Skipping read." CR)); Log.error(F("TSEN: No temperature sensors found. Skipping read." CR));
@ -119,12 +114,11 @@ float TempSensor::getValue() {
c = mySensors.getTempCByIndex(0); c = mySensors.getTempCByIndex(0);
#if LOG_LEVEL == 6 && !defined(TSEN_DISABLE_LOGGING) #if LOG_LEVEL == 6 && !defined(TSEN_DISABLE_LOGGING)
Log.verbose(F("TSEN: Reciving temp value for sensor %F C." CR), c); Log.verbose(F("TSEN: Reciving temp value for DS18B20 sensor %F C." CR), c);
#endif #endif
hasSensor = true; hasSensor = true;
} }
return c; return c;
#endif
} }
// EOF // EOF

View File

@ -33,13 +33,17 @@ class TempSensor {
bool hasSensor = false; bool hasSensor = false;
float tempSensorAdjF = 0; float tempSensorAdjF = 0;
float tempSensorAdjC = 0; float tempSensorAdjC = 0;
float getValue(); float getValue(bool useGyro);
public: public:
void setup(); void setup();
bool isSensorAttached() { return hasSensor; } bool isSensorAttached() { return hasSensor; }
float getTempC() { return getValue() + tempSensorAdjC; } float getTempC(bool useGyro = false) {
float getTempF() { return convertCtoF(getValue()) + tempSensorAdjF; } return getValue(useGyro) + tempSensorAdjC;
}
float getTempF(bool useGyro = false) {
return convertCtoF(getValue(useGyro)) + tempSensorAdjF;
}
}; };
// Global instance created // Global instance created

View File

@ -41,7 +41,7 @@ extern bool sleepModeAlwaysSkip;
void WebServer::webHandleDevice() { void WebServer::webHandleDevice() {
LOG_PERF_START("webserver-api-device"); LOG_PERF_START("webserver-api-device");
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING) #if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
Log.verbose(F("WEB : webServer callback for /api/config." CR)); Log.verbose(F("WEB : webServer callback for /api/device." CR));
#endif #endif
DynamicJsonDocument doc(100); DynamicJsonDocument doc(100);
@ -69,8 +69,10 @@ void WebServer::webHandleConfig() {
DynamicJsonDocument doc(CFG_JSON_BUFSIZE); DynamicJsonDocument doc(CFG_JSON_BUFSIZE);
myConfig.createJson(doc); myConfig.createJson(doc);
doc[CFG_PARAM_PASS] = ""; // dont show the wifi password
double angle = myGyro.getAngle(); double angle = myGyro.getAngle();
double temp = myTempSensor.getTempC(); double temp = myTempSensor.getTempC(myConfig.isGyroTemp());
double gravity = calculateGravity(angle, temp); double gravity = calculateGravity(angle, temp);
doc[CFG_PARAM_ANGLE] = reduceFloatPrecision(angle); doc[CFG_PARAM_ANGLE] = reduceFloatPrecision(angle);
@ -137,7 +139,7 @@ void WebServer::webHandleUploadFile() {
} }
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING) #if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
Log.debug(F("WEB : webServer callback for /api/upload, receiving file %s, " Log.verbose(F("WEB : webServer callback for /api/upload, receiving file %s, "
"valid=%s." CR), "valid=%s." CR),
f.c_str(), validFilename ? "yes" : "no"); f.c_str(), validFilename ? "yes" : "no");
#endif #endif
@ -213,7 +215,7 @@ void WebServer::webHandleStatus() {
DynamicJsonDocument doc(256); DynamicJsonDocument doc(256);
double angle = myGyro.getAngle(); double angle = myGyro.getAngle();
double temp = myTempSensor.getTempC(); double temp = myTempSensor.getTempC(myConfig.isGyroTemp());
double gravity = calculateGravity(angle, temp); double gravity = calculateGravity(angle, temp);
doc[CFG_PARAM_ID] = myConfig.getID(); doc[CFG_PARAM_ID] = myConfig.getID();
@ -225,7 +227,8 @@ void WebServer::webHandleStatus() {
else else
doc[CFG_PARAM_GRAVITY] = reduceFloatPrecision(gravity, 4); doc[CFG_PARAM_GRAVITY] = reduceFloatPrecision(gravity, 4);
doc[CFG_PARAM_TEMP_C] = reduceFloatPrecision(temp, 1); doc[CFG_PARAM_TEMP_C] = reduceFloatPrecision(temp, 1);
doc[CFG_PARAM_TEMP_F] = reduceFloatPrecision(myTempSensor.getTempF(), 1); doc[CFG_PARAM_TEMP_F] =
reduceFloatPrecision(myTempSensor.getTempF(myConfig.isGyroTemp()), 1);
doc[CFG_PARAM_BATTERY] = reduceFloatPrecision(myBatteryVoltage.getVoltage()); doc[CFG_PARAM_BATTERY] = reduceFloatPrecision(myBatteryVoltage.getVoltage());
doc[CFG_PARAM_TEMPFORMAT] = String(myConfig.getTempFormat()); doc[CFG_PARAM_TEMPFORMAT] = String(myConfig.getTempFormat());
doc[CFG_PARAM_SLEEP_MODE] = sleepModeAlwaysSkip; doc[CFG_PARAM_SLEEP_MODE] = sleepModeAlwaysSkip;
@ -411,15 +414,18 @@ void WebServer::webHandleConfigHardware() {
} }
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING) #if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
Log.verbose(F("WEB : vf=%s, tempadj=%s, ota=%s." CR), Log.verbose(F("WEB : vf=%s, tempadj=%s, ota=%s gyrotemp=%s." CR),
server->arg(CFG_PARAM_VOLTAGEFACTOR).c_str(), server->arg(CFG_PARAM_VOLTAGEFACTOR).c_str(),
server->arg(CFG_PARAM_TEMP_ADJ).c_str(), server->arg(CFG_PARAM_TEMP_ADJ).c_str(),
server->arg(CFG_PARAM_OTA).c_str()); server->arg(CFG_PARAM_OTA).c_str(),
server->arg(CFG_PARAM_GYRO_TEMP).c_str());
#endif #endif
myConfig.setVoltageFactor(server->arg(CFG_PARAM_VOLTAGEFACTOR).toFloat()); myConfig.setVoltageFactor(server->arg(CFG_PARAM_VOLTAGEFACTOR).toFloat());
myConfig.setTempSensorAdj(server->arg(CFG_PARAM_TEMP_ADJ).toFloat()); myConfig.setTempSensorAdj(server->arg(CFG_PARAM_TEMP_ADJ).toFloat());
myConfig.setOtaURL(server->arg(CFG_PARAM_OTA).c_str()); myConfig.setOtaURL(server->arg(CFG_PARAM_OTA).c_str());
myConfig.setGyroTemp(
server->arg(CFG_PARAM_GYRO_TEMP).equalsIgnoreCase("on") ? true : false);
myConfig.saveFile(); myConfig.saveFile();
server->sendHeader("Location", "/config.htm#collapseFour", true); server->sendHeader("Location", "/config.htm#collapseFour", true);
server->send(302, "text/plain", "Hardware config updated"); server->send(302, "text/plain", "Hardware config updated");
@ -559,6 +565,7 @@ void WebServer::webHandleFormulaWrite() {
server->send(302, "text/plain", "Formula updated"); server->send(302, "text/plain", "Formula updated");
LOG_PERF_STOP("webserver-api-formula-write"); LOG_PERF_STOP("webserver-api-formula-write");
} }
// //
// Helper function to check if files exist on file system. // Helper function to check if files exist on file system.
// //

View File

@ -82,8 +82,6 @@ This is a list of C++ defines that is used to enable/disable functions in the co
- description - description
* - ACTIVATE_OTA * - ACTIVATE_OTA
- Enables the OTA functionallity in the code - Enables the OTA functionallity in the code
* - USE_GYRO_TEMP
- Uses temperature from gyro instead of DS18B20 (experimental)
* - SKIP_SLEEPMODE * - SKIP_SLEEPMODE
- THe device never goes into sleep mode, useful when developing. - THe device never goes into sleep mode, useful when developing.
* - CFG_DISABLE_LOGGING * - CFG_DISABLE_LOGGING

View File

@ -165,7 +165,13 @@ Hardware Settings
* **Temperature correction:** * **Temperature correction:**
This value will be added to the temperature reading (negative value will reduce temperature reading). This value will be added to the temperature reading (negative value will reduce temperature reading). This is applied
when the device starts. So changing this will not take affect until the device is restarted.
* **Gyro Temperature:**
Enable this feature will use the temp sensor i the gyro instead of the DS18B20, the benefit is shorter run time and
longer battery life (this is an experimental feature).
* **OTA URL:** * **OTA URL:**
@ -235,6 +241,7 @@ Other parameters are the same as in the configuration guide.
"gravity-format": "G", "gravity-format": "G",
"temp-adjustment-value": 0, "temp-adjustment-value": 0,
"gravity-temp-adjustment": false, "gravity-temp-adjustment": false,
"gyro-temp": true,
"gyro-calibration-data": { "gyro-calibration-data": {
"ax": -330, "ax": -330,
"ay": -2249, "ay": -2249,
@ -367,8 +374,8 @@ Used to update gravity settings via an HTTP POST command. Payload is in JSON for
} }
POST: /api/config/gravity POST: /api/config/hardware
========================= ==========================
Used to update hardware settings via an HTTP POST command. Payload is in JSON format. Used to update hardware settings via an HTTP POST command. Payload is in JSON format.
@ -378,6 +385,7 @@ Used to update hardware settings via an HTTP POST command. Payload is in JSON fo
"id": "ee1bfc", "id": "ee1bfc",
"voltage-factor": 1.59, "voltage-factor": 1.59,
"temp-adjustment": 0, "temp-adjustment": 0,
"gyro-temp": "off",
"ota-url": "http://192.168.1.50/firmware/gravmon/" "ota-url": "http://192.168.1.50/firmware/gravmon/"
} }
@ -461,6 +469,7 @@ present or the API call will fail.
json = { "id": id, json = { "id": id,
"voltage-factor": 1.59, # Default value for voltage calculation "voltage-factor": 1.59, # Default value for voltage calculation
"temp-adjustment": 0, # If temp sensor needs to be corrected "temp-adjustment": 0, # If temp sensor needs to be corrected
"gyro-temp": true, # Use the temp sensor in the gyro instead
"ota-url": "" # if the device should seach for a new update when active "ota-url": "" # if the device should seach for a new update when active
} }
set_config( url, json ) set_config( url, json )

View File

@ -13,6 +13,8 @@ This is features for the next release.
* Refactored main.cpp to make it easier to read * Refactored main.cpp to make it easier to read
* Tested runtime performance * Tested runtime performance
* Improved documentation * Improved documentation
* Added warning on config page when sleep is <300
* Enabled selection of gyro temperature sensor under Hardware settings.
v0.5.0 v0.5.0
------ ------

View File

@ -16,6 +16,7 @@
"gravity-format": "G", "gravity-format": "G",
"temp-adjustment-value": 0, "temp-adjustment-value": 0,
"gravity-temp-adjustment": false, "gravity-temp-adjustment": false,
"gyro-temp": true,
"gyro-calibration-data": { "gyro-calibration-data": {
"ax": -330, "ax": -330,
"ay": -2249, "ay": -2249,

View File

@ -58,6 +58,7 @@ url = "http://" + host + "/api/config/hardware"
json = { "id": id, json = { "id": id,
"voltage-factor": 1.59, # Default value for voltage calculation "voltage-factor": 1.59, # Default value for voltage calculation
"temp-adjustment": 0, # If temp sensor needs to be corrected "temp-adjustment": 0, # If temp sensor needs to be corrected
"gyro-temp": "off", # Use the temp sensor in the gyro
"ota-url": "" # if the device should seach for a new update when active "ota-url": "" # if the device should seach for a new update when active
} }
set_config( url, json ) set_config( url, json )