Fix handling of statistics before data is available and fix normalization factor
This commit is contained in:
parent
1694e3bbab
commit
ed2fddc427
@ -243,15 +243,35 @@ class Terminal {
|
|||||||
|
|
||||||
static void printStatistics()
|
static void printStatistics()
|
||||||
{
|
{
|
||||||
m_serial << F("Minimum temperature .: ") << Statistics::getMinTemperature() << F(" C") << detail::ENDL;
|
const auto minTemp = Statistics::getMinTemperature();
|
||||||
m_serial << F("Maximum temperature .: ") << Statistics::getMaxTemperature() << F(" C") << detail::ENDL;
|
const auto maxTemp = Statistics::getMaxTemperature();
|
||||||
|
|
||||||
|
m_serial << F("Minimum temperature .: ");
|
||||||
|
if (minTemp != Statistics::TEMPERATURE_RANGE) {
|
||||||
|
m_serial << minTemp << F(" C");
|
||||||
|
} else {
|
||||||
|
m_serial << F("Not available");
|
||||||
|
}
|
||||||
|
|
||||||
|
m_serial << detail::ENDL << F("Maximum temperature .: ");
|
||||||
|
if (maxTemp != Statistics::TEMPERATURE_RANGE) {
|
||||||
|
m_serial << maxTemp << F(" C");
|
||||||
|
} else {
|
||||||
|
m_serial << F("Not available");
|
||||||
|
}
|
||||||
|
m_serial << detail::ENDL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printHistogram()
|
static void printHistogram()
|
||||||
{
|
{
|
||||||
const auto totalSamples = Statistics::getTotalHistogramSamples();
|
const auto totalSamples = Statistics::getTotalHistogramSamples();
|
||||||
|
|
||||||
|
if (totalSamples > 0) {
|
||||||
const auto maximumSamples = Statistics::getHighestHistogramSamples();
|
const auto maximumSamples = Statistics::getHighestHistogramSamples();
|
||||||
const auto normalizationFactor = (maximumSamples / 100 > 1) ? (maximumSamples / 100) : 1;
|
auto normalizationFactor = (maximumSamples / 100 > 1) ? (maximumSamples / 100) : 1;
|
||||||
|
|
||||||
|
while (maximumSamples / normalizationFactor > 100)
|
||||||
|
++normalizationFactor;
|
||||||
|
|
||||||
for (uint8_t t = Statistics::getMinTemperature(); t <= Statistics::getMaxTemperature(); ++t) {
|
for (uint8_t t = Statistics::getMinTemperature(); t <= Statistics::getMaxTemperature(); ++t) {
|
||||||
const auto histogramSamples = Statistics::getHistogram(t);
|
const auto histogramSamples = Statistics::getHistogram(t);
|
||||||
@ -265,6 +285,9 @@ class Terminal {
|
|||||||
}
|
}
|
||||||
m_serial << detail::ENDL;
|
m_serial << detail::ENDL;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
m_serial << "There is no data yet!" << detail::ENDL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printVersion()
|
static void printVersion()
|
||||||
|
Loading…
Reference in New Issue
Block a user