Skip to content

Commit 8feddf0

Browse files
committed
Sensor reduce FIFO log frequency
1 parent 52121a1 commit 8feddf0

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/sensor/sensor.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ static void set_update_time_ms(int time_ms)
533533
#if IMU_INT_EXISTS
534534
float fifo_threshold = time_ms / 1000.0f / sensor_actual_time; // target loop rate
535535
sensor_fifo_threshold = fifo_threshold;
536-
LOG_INF("FIFO THS/WM/WTM: %.2f -> %d", (double)fifo_threshold, sensor_fifo_threshold);
536+
LOG_DBG("FIFO THS/WM/WTM: %.2f -> %d", (double)fifo_threshold, sensor_fifo_threshold);
537537
sensor_imu->setup_DRDY(sensor_fifo_threshold); // do not need to reset pin config
538538
#endif
539539
sensor_update_time_ms = time_ms; // TODO: terrible naming
@@ -738,12 +738,12 @@ int sensor_init(void)
738738
// Setup interrupt
739739
float fifo_threshold = sensor_update_time_ms / 1000.0f / sensor_actual_time; // target loop rate
740740
sensor_fifo_threshold = fifo_threshold;
741-
LOG_INF("FIFO THS/WM/WTM: %.2f -> %d", (double)fifo_threshold, sensor_fifo_threshold);
741+
LOG_DBG("FIFO THS/WM/WTM: %.2f -> %d", (double)fifo_threshold, sensor_fifo_threshold);
742742
uint8_t pin_config = sensor_imu->setup_DRDY(sensor_fifo_threshold);
743743
if (pin_config == 0)
744744
return -1;
745745
uint32_t int0_gpios = NRF_DT_GPIOS_TO_PSEL(ZEPHYR_USER_NODE, int0_gpios);
746-
LOG_INF("FIFO THS/WM/WTM GPIO pin: %u, config: %u", int0_gpios, pin_config);
746+
LOG_DBG("FIFO THS/WM/WTM GPIO pin: %u, config: %u", int0_gpios, pin_config);
747747
uint32_t pull_flags = ((pin_config >> 4) == NRF_GPIO_PIN_PULLDOWN ? GPIO_PULL_DOWN : 0) | ((pin_config >> 4) == NRF_GPIO_PIN_PULLUP ? GPIO_PULL_UP : 0);
748748
gpio_pin_configure_dt(&int0, GPIO_INPUT | pull_flags);
749749
uint32_t int_flags = ((pin_config & 0xF) == NRF_GPIO_PIN_SENSE_LOW ? GPIO_INT_EDGE_FALLING : 0) | ((pin_config & 0xF) == NRF_GPIO_PIN_SENSE_HIGH ? GPIO_INT_EDGE_RISING : 0);
@@ -856,10 +856,11 @@ void sensor_loop(void)
856856
if (mag_available && mag_enabled)
857857
sensor_mag->mag_read(raw_m); // reading mag last, and it will be processed last
858858

859+
int16_t last_sensor_fifo_threshold = sensor_fifo_threshold;
860+
859861
if (reconfig) // TODO: get rid of reconfig?
860862
{
861863
// Changing FIFO threshold here should be fine since FIFO is empty now
862-
// TODO: causing warnings since packet processing and loop timing still expects previous update_time
863864
switch (sensor_mode)
864865
{
865866
case SENSOR_SENSOR_MODE_LOW_NOISE:
@@ -1017,8 +1018,8 @@ void sensor_loop(void)
10171018
}
10181019

10191020
// Also check if expected number of timesteps when using FIFO threshold, if FIFO threshold is being used
1020-
if (sensor_fifo_threshold && processed_timesteps && processed_timesteps != sensor_fifo_threshold)
1021-
LOG_WRN("Expected %d timestep%s, got %d", sensor_fifo_threshold, sensor_fifo_threshold == 1 ? "" : "s", processed_timesteps);
1021+
if (last_sensor_fifo_threshold && processed_timesteps && processed_timesteps != last_sensor_fifo_threshold)
1022+
LOG_WRN("Expected %d timestep%s, got %d", last_sensor_fifo_threshold, last_sensor_fifo_threshold == 1 ? "" : "s", processed_timesteps);
10221023

10231024
// Update fusion gyro sanity? // TODO: use to detect drift and correct or suspend tracking
10241025
// sensor_fusion->update_gyro_sanity(g, m);

0 commit comments

Comments
 (0)