From 57059b84f6c2e9eec500f3458b9aa8f400609fc0 Mon Sep 17 00:00:00 2001 From: caila-marashaj Date: Thu, 13 Jun 2024 10:42:07 -0400 Subject: [PATCH] default sensor_buffer_size to 0 --- include/common/core/sensor_buffer.hpp | 7 +++++-- include/sensors/core/tasks/pressure_driver.hpp | 12 +++--------- sensors/tests/test_capacitive_sensor.cpp | 2 ++ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/common/core/sensor_buffer.hpp b/include/common/core/sensor_buffer.hpp index 61d792164..3072b0170 100644 --- a/include/common/core/sensor_buffer.hpp +++ b/include/common/core/sensor_buffer.hpp @@ -1,3 +1,6 @@ #pragma once - -constexpr size_t SENSOR_BUFFER_SIZE = SENSOR_BUFF_SIZE; \ No newline at end of file +#ifndef SENSOR_BUFF_SIZE +#define SENSOR_BUFFER_SIZE = 0; +#else +constexpr size_t SENSOR_BUFFER_SIZE = SENSOR_BUFF_SIZE; +#endif \ No newline at end of file diff --git a/include/sensors/core/tasks/pressure_driver.hpp b/include/sensors/core/tasks/pressure_driver.hpp index c2cd028bb..cd667c58e 100644 --- a/include/sensors/core/tasks/pressure_driver.hpp +++ b/include/sensors/core/tasks/pressure_driver.hpp @@ -233,7 +233,7 @@ class MMR920 { sensor_buffer_index = 0; } - (*sensor_buffer).at(sensor_buffer_index) = data; + sensor_buffer->at(sensor_buffer_index) = data; sensor_buffer_index++; } @@ -330,7 +330,6 @@ class MMR920 { _registers.pressure_result.reading, sensor_version); if (max_pressure_sync) { - sensor_buffer_log(pressure); bool this_tick_over_threshold = std::fabs(pressure - current_pressure_baseline_pa) >= mmr920::get_max_pressure_reading(sensor_version); @@ -368,12 +367,8 @@ class MMR920 { if (echo_this_time) { auto response_pressure = pressure - current_pressure_baseline_pa; -#ifdef USE_SENSOR_MOVE - if (sensor_buffer_index < SENSOR_BUFFER_SIZE) { - (*sensor_buffer).at(sensor_buffer_index) = response_pressure; - sensor_buffer_index++; - } -#else + // do we want pressure or response pressure + sensor_buffer_log(pressure); can_client.send_can_message( can::ids::NodeId::host, can::messages::ReadFromSensorResponse{ @@ -382,7 +377,6 @@ class MMR920 { .sensor_id = sensor_id, .sensor_data = mmr920::reading_to_fixed_point(response_pressure)}); -#endif } } diff --git a/sensors/tests/test_capacitive_sensor.cpp b/sensors/tests/test_capacitive_sensor.cpp index 1d3e5c950..6a99c26f7 100644 --- a/sensors/tests/test_capacitive_sensor.cpp +++ b/sensors/tests/test_capacitive_sensor.cpp @@ -1,3 +1,5 @@ +#define SENSOR_BUFF_SIZE = 500 + #include "can/core/ids.hpp" #include "can/core/messages.hpp" #include "catch2/catch.hpp"