Dokumentation um Webinterface, Einstellungen und OTA-Update erweitert
This commit is contained in:
1 parent
1014df8ec7
commit
0d2ff764ea
13 files changed
+531
-85
No files matched your search
+39
-14
@@ -11,12 +11,19 @@ bfs::Ms4525do pres;
|
||||
Adafruit_BMP085 bmp;
|
||||
|
||||
float pressure_avg[10];
|
||||
float basicaltitude;
|
||||
void init_2ndi2c(){
|
||||
Wire1.begin(dp_sda, dp_scl);
|
||||
float basicaltitude = 0.0f;
|
||||
bool pressure_sensor_ready = false;
|
||||
|
||||
bool init_2ndi2c(){
|
||||
if (!Wire1.begin(dp_sda, dp_scl))
|
||||
{
|
||||
Serial.println("Error starting I2C");
|
||||
return false;
|
||||
}
|
||||
Wire1.setClock(400000);
|
||||
return true;
|
||||
}
|
||||
void init_airspeed_sensor(void)
|
||||
bool init_airspeed_sensor(void)
|
||||
{
|
||||
|
||||
/*
|
||||
@@ -27,10 +34,9 @@ void init_airspeed_sensor(void)
|
||||
if (!pres.Begin())
|
||||
{
|
||||
Serial.println("Error communicating with sensor");
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int get_airspeed_kmh(void)
|
||||
@@ -51,10 +57,22 @@ float get_airspeed(void)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
void init_pressure_sensor(void)
|
||||
bool init_pressure_sensor(void)
|
||||
{
|
||||
bmp.begin(BMP085_ULTRAHIGHRES, &Wire1);
|
||||
if (!bmp.begin(BMP085_ULTRAHIGHRES, &Wire1))
|
||||
{
|
||||
Serial.println("Error communicating with pressure sensor");
|
||||
return false;
|
||||
}
|
||||
basicaltitude=bmp.readPressure();
|
||||
if (basicaltitude <= 0.0f)
|
||||
{
|
||||
Serial.println("Invalid initial pressure");
|
||||
return false;
|
||||
}
|
||||
for (float &sample : pressure_avg)
|
||||
sample = basicaltitude;
|
||||
pressure_sensor_ready = true;
|
||||
Serial.print("Pressure = ");
|
||||
Serial.print(basicaltitude);
|
||||
Serial.println(" Pa");
|
||||
@@ -64,21 +82,28 @@ void init_pressure_sensor(void)
|
||||
Serial.print("Altitude = ");
|
||||
Serial.print(get_altitude(basicaltitude));
|
||||
Serial.println(" meters");
|
||||
return true;
|
||||
}
|
||||
|
||||
float get_pressure()
|
||||
{
|
||||
if (!pressure_sensor_ready)
|
||||
return 0.0f;
|
||||
|
||||
float pressure;
|
||||
pressure = bmp.readPressure();
|
||||
memcpy(pressure_avg, &pressure_avg[1], sizeof(pressure_avg) - sizeof(int));
|
||||
if (pressure <= 0.0f)
|
||||
return pressure_avg[9];
|
||||
|
||||
memmove(pressure_avg, &pressure_avg[1], sizeof(pressure_avg) - sizeof(pressure_avg[0]));
|
||||
pressure_avg[9] = pressure;
|
||||
return pressure;
|
||||
}
|
||||
|
||||
float get_pressure_avg(void)
|
||||
{
|
||||
float total = 0.0f;
|
||||
int i;
|
||||
float total;
|
||||
for (i = 0; i <10; i++)
|
||||
{
|
||||
total = total + pressure_avg[i];
|
||||
@@ -97,14 +122,14 @@ float get_vario_avg(void)
|
||||
float vario;
|
||||
|
||||
int i;
|
||||
float total;
|
||||
float total = 0.0f;
|
||||
for (i = 0; i <9; i++)
|
||||
{
|
||||
int n=i+1;
|
||||
vario = get_altitude(pressure_avg[n]) - get_altitude(pressure_avg[i]);
|
||||
total = total + vario;
|
||||
}
|
||||
return (total / 10);
|
||||
return (total / 9);
|
||||
}
|
||||
|
||||
float get_altitude(float pressure)
|
||||
@@ -115,5 +140,5 @@ float get_altitude(float pressure)
|
||||
}
|
||||
|
||||
float get_altitude_diff(void){
|
||||
return bmp.readPressure() - basicaltitude;
|
||||
return get_altitude(pressure_avg[9]) - get_altitude(basicaltitude);
|
||||
}
|
||||
Reference in new issue
Block a user