From: Lukáš Jiřiště Date: Tue, 12 Nov 2024 10:58:43 +0000 (+0100) Subject: Initialize m_time_start, add m_size increment X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=5cc9a28aff273b2bdbb83f0fe489d652f6251c20;p=Servomatic.git Initialize m_time_start, add m_size increment The m_time_start should be initialized, so that the time measurement does not overflow sooner then 49 days after the start. Additionally the m_time_start is reset in clear() method for the same reason. The m_size was not adjusted upon creating a new measurement. This means that no measurement but the last is was saved. This is now fixed. --- diff --git a/Measurement.ino b/Measurement.ino index b882ade..082a45a 100644 --- a/Measurement.ino +++ b/Measurement.ino @@ -4,6 +4,7 @@ Measurement::Measurement(const PressureSensor &sensor) : m_size{0} , m_sensor{sensor} , m_interval_ms{START_INTERVAL_MS} + , m_start_time{millis()} { } @@ -17,6 +18,7 @@ void Measurement::get_measurement() thin_out(); m_pressure[m_size] = m_sensor.get_pressure(); m_time[m_size] = millis() - m_start_time; + ++m_size; } void Measurement::thin_out() @@ -33,6 +35,7 @@ void Measurement::thin_out() void Measurement::clear() { m_size = 0; + m_start_time = millis(); } // The function calls get_measurement repeatedly. It uses these measurements to