2020-11-27 05:33:55 -05:00
|
|
|
//
|
|
|
|
// FILE: dewpoint_test.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
|
|
|
// PURPOSE: demo
|
|
|
|
// DATE: 2020-04-04
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
|
|
|
|
#include "temperature.h"
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
uint32_t start;
|
|
|
|
uint32_t duration1;
|
|
|
|
uint32_t duration2;
|
|
|
|
|
|
|
|
float maxError;
|
|
|
|
volatile float dp;
|
|
|
|
|
2021-12-28 13:11:26 -05:00
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.println(__FILE__);
|
|
|
|
Serial.println("takes ~40 seconds");
|
|
|
|
|
|
|
|
Serial.println(dewPoint(25, 50), 2);
|
|
|
|
Serial.println(dewPointFast(25, 50), 2);
|
|
|
|
|
|
|
|
Serial.println("\ndewPoint()");
|
|
|
|
start = millis();
|
|
|
|
for (int cel = -40; cel < 80; cel++)
|
|
|
|
{
|
|
|
|
for (int hum = 1; hum < 100; hum++)
|
|
|
|
{
|
|
|
|
dp = dewPoint(cel, hum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
duration1 = millis() - start;
|
|
|
|
Serial.println(duration1);
|
|
|
|
|
|
|
|
Serial.println("\ndewPointFast()");
|
|
|
|
start = millis();
|
|
|
|
for (int cel = -40; cel < 80; cel++)
|
|
|
|
{
|
|
|
|
for (int hum = 1; hum < 100; hum++)
|
|
|
|
{
|
|
|
|
dp = dewPointFast(cel, hum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
duration2 = millis() - start;
|
|
|
|
Serial.println(duration2);
|
|
|
|
Serial.print("RATIO:\t");
|
|
|
|
Serial.println((1.0 * duration1) / duration2, 3);
|
|
|
|
|
|
|
|
|
|
|
|
Serial.println("\ndewPointFast() vs dewPoint()");
|
|
|
|
for (int cel = -40; cel < 80; cel++)
|
|
|
|
{
|
|
|
|
for (int hum = 1; hum < 100; hum++)
|
|
|
|
{
|
|
|
|
float x = abs(dewPoint(cel, hum) - dewPointFast(cel, hum));
|
|
|
|
if (x > maxError) maxError = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Serial.print("ERROR:\t");
|
|
|
|
Serial.println(maxError, 3);
|
|
|
|
|
|
|
|
|
|
|
|
Serial.print("Done...");
|
|
|
|
}
|
|
|
|
|
2021-12-28 13:11:26 -05:00
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-12-28 13:11:26 -05:00
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
// -- END OF FILE --
|
2021-12-28 13:11:26 -05:00
|
|
|
|