Added gyro temp
This commit is contained in:
parent
09cc5e35b6
commit
22defdadc0
@ -118,7 +118,7 @@
|
|||||||
$('#spinner').show();
|
$('#spinner').show();
|
||||||
$.getJSON(url, function (cfg) {
|
$.getJSON(url, function (cfg) {
|
||||||
console.log( cfg );
|
console.log( cfg );
|
||||||
$("#app-ver").text(cfg["app-ver"] + " (html 0.2.2)");
|
$("#app-ver").text(cfg["app-ver"] + " (html 0.3.0)");
|
||||||
$("#mdns").text(cfg["mdns"]);
|
$("#mdns").text(cfg["mdns"]);
|
||||||
$("#id").text(cfg["id"]);
|
$("#id").text(cfg["id"]);
|
||||||
})
|
})
|
||||||
|
@ -14,4 +14,4 @@
|
|||||||
<button type="button" class="btn btn-warning" id="wifi-reset-btn">Factory default settings</button>
|
<button type="button" class="btn btn-warning" id="wifi-reset-btn">Factory default settings</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
--><hr class="my-4"></div><script type="text/javascript">function getConfig(){var n="/api/device";$("#spinner").show(),$.getJSON(n,function(n){console.log(n),$("#app-ver").text(n["app-ver"]+" (html 0.2.2)"),$("#mdns").text(n.mdns),$("#id").text(n.id)}).fail(function(){showError("Unable to get data from the device.")}).always(function(){$("#spinner").hide()})}window.onload=getConfig</script><!-- START FOOTER --><div class="container-fluid themed-container bg-primary text-light">(C) Copyright 2021 Magnus Persson</div></body></html>
|
--><hr class="my-4"></div><script type="text/javascript">function getConfig(){var n="/api/device";$("#spinner").show(),$.getJSON(n,function(n){console.log(n),$("#app-ver").text(n["app-ver"]+" (html 0.3.0)"),$("#mdns").text(n.mdns),$("#id").text(n.id)}).fail(function(){showError("Unable to get data from the device.")}).always(function(){$("#spinner").hide()})}window.onload=getConfig</script><!-- START FOOTER --><div class="container-fluid themed-container bg-primary text-light">(C) Copyright 2021 Magnus Persson</div></body></html>
|
@ -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.4\""
|
-D CFG_APPVER="\"0.3.0\""
|
||||||
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
|
||||||
|
@ -211,6 +211,7 @@ bool GyroSensor::read() {
|
|||||||
} else {
|
} else {
|
||||||
validValue = true;
|
validValue = true;
|
||||||
angle = calculateAngle( raw );
|
angle = calculateAngle( raw );
|
||||||
|
sensorTemp = ((float) raw.temp) / 340 + 36.53;
|
||||||
//Log.notice(F("GYRO: Calculated angle %F" CR), angle );
|
//Log.notice(F("GYRO: Calculated angle %F" CR), angle );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ class GyroSensor {
|
|||||||
bool sensorConnected = false;
|
bool sensorConnected = false;
|
||||||
bool validValue = false;
|
bool validValue = false;
|
||||||
double angle = 0;
|
double angle = 0;
|
||||||
|
float sensorTemp = 0;
|
||||||
RawGyroData calibrationOffset;
|
RawGyroData calibrationOffset;
|
||||||
|
|
||||||
void debug();
|
void debug();
|
||||||
@ -66,6 +67,7 @@ class GyroSensor {
|
|||||||
void calibrateSensor();
|
void calibrateSensor();
|
||||||
|
|
||||||
double getAngle() { return angle; };
|
double getAngle() { return angle; };
|
||||||
|
double getSensorTempC() { return sensorTemp; };
|
||||||
bool isConnected() { return sensorConnected; };
|
bool isConnected() { return sensorConnected; };
|
||||||
bool hasValue() { return validValue; };
|
bool hasValue() { return validValue; };
|
||||||
void enterSleep();
|
void enterSleep();
|
||||||
|
@ -151,17 +151,19 @@ void loop() {
|
|||||||
if( sleepModeActive || abs(millis() - lastMillis) > interval ) {
|
if( sleepModeActive || abs(millis() - lastMillis) > interval ) {
|
||||||
float angle = 90;
|
float angle = 90;
|
||||||
float volt = myBatteryVoltage.getVoltage();
|
float volt = myBatteryVoltage.getVoltage();
|
||||||
|
float sensorTemp = 0;
|
||||||
loopCounter++;
|
loopCounter++;
|
||||||
#if LOG_LEVEL==6
|
#if LOG_LEVEL==6
|
||||||
Log.verbose(F("Main: Entering main loop." CR) );
|
Log.verbose(F("Main: Entering main loop." CR) );
|
||||||
#endif
|
#endif
|
||||||
// If we dont get any readings we just skip this and try again the next interval.
|
// If we dont get any readings we just skip this and try again the next interval.
|
||||||
if( myGyro.hasValue() ) {
|
if( myGyro.hasValue() ) {
|
||||||
angle = myGyro.getAngle();
|
angle = myGyro.getAngle(); // Gyro angle
|
||||||
|
sensorTemp = myGyro.getSensorTempC(); // Temp in the Gyro
|
||||||
float temp = myTempSensor.getValueCelcius(); // The code is build around using C for temp.
|
float temp = myTempSensor.getValueCelcius(); // The code is build around using C for temp.
|
||||||
float gravity = calculateGravity( angle, temp );
|
float gravity = calculateGravity( angle, temp );
|
||||||
#if LOG_LEVEL==6
|
#if LOG_LEVEL==6
|
||||||
Log.verbose(F("Main: Sensor values gyro=%F, temp=%F, gravity=%F." CR), angle, temp, gravity );
|
Log.verbose(F("Main: Sensor values gyro angle=%F gyro temp=%F, temp=%F, gravity=%F." CR), angle, sensorTemp, temp, gravity );
|
||||||
#endif
|
#endif
|
||||||
if( myConfig.isGravityTempAdj() ) {
|
if( myConfig.isGravityTempAdj() ) {
|
||||||
gravity = gravityTemperatureCorrection( gravity, temp); // Use default correction temperature of 20C
|
gravity = gravityTemperatureCorrection( gravity, temp); // Use default correction temperature of 20C
|
||||||
@ -172,7 +174,7 @@ void loop() {
|
|||||||
|
|
||||||
// Limit the printout when sleep mode is not active.
|
// Limit the printout when sleep mode is not active.
|
||||||
if( loopCounter%10 == 0 || sleepModeActive )
|
if( loopCounter%10 == 0 || sleepModeActive )
|
||||||
Log.notice(F("Main: Gyro angle=%F, temp=%F, gravity=%F, batt=%F." CR), angle, temp, gravity, volt );
|
Log.notice(F("Main: gyro angle=%F, gyro temp=%F, DS18B20 temp=%F, gravity=%F, batt=%F." CR), angle, sensorTemp, temp, gravity, volt );
|
||||||
|
|
||||||
#if defined( ACTIVATE_PUSH )
|
#if defined( ACTIVATE_PUSH )
|
||||||
unsigned long runTime = millis() - startMillis;
|
unsigned long runTime = millis() - startMillis;
|
||||||
|
Loading…
Reference in New Issue
Block a user