ESPectre SDK
2.8.0-280-gac7af68
Wi-Fi CSI motion sensing for ESP32 firmware
Toggle main menu visibility
Loading...
Searching...
No Matches
filtered_turbulence_ring.h
Go to the documentation of this file.
1
/*
2
* ESPectre - Filtered Turbulence Ring
3
*
4
* Shared filtered ring used by detector feature streams.
5
*
6
* Author: Francesco Pace <francesco.pace@gmail.com>
7
* SPDX-License-Identifier: GPL-3.0-only
8
* Commercial licensing available under separate agreement; see LICENSING.md.
9
*/
10
#pragma once
11
12
#include <cstdint>
13
14
#include "
filters.h
"
15
16
namespace
espectre
{
17
18
/** @brief Fixed-capacity turbulence history with optional Hampel and low-pass filtering. */
19
class
FilteredTurbulenceRing
{
20
public
:
21
/** @brief Construct an unbound history with default filter parameters. */
22
FilteredTurbulenceRing
();
23
24
/** @brief Attach caller-owned storage and reset the history. */
25
void
bind
(
float
*storage, uint16_t
capacity
);
26
/** @brief Clear samples while preserving the configured filters. */
27
void
clear
();
28
/** @brief Configure and reset the Hampel filter. */
29
void
configure_hampel
(
bool
enabled, uint8_t window_size,
float
threshold);
30
/** @brief Configure and reset the low-pass filter. */
31
void
configure_lowpass
(
bool
enabled,
float
cutoff_hz);
32
/** @brief Filter and append one turbulence sample. */
33
void
add
(
float
turbulence);
34
/** @brief Append missing-sample markers without running the filters. */
35
void
advance_missing_slots
(uint32_t
count
);
36
37
/**
38
* @brief Return the samples in chronological order.
39
* @param scratch Caller-owned storage used only after the ring wraps.
40
* @param scratch_capacity Number of elements available in @p scratch.
41
* @param count Receives the returned element count, or zero when scratch is too small.
42
* @return Internal storage before wrap, @p scratch after wrap, or nullptr when empty or invalid.
43
*/
44
const
float
*
ordered_view
(
float
*scratch, uint16_t scratch_capacity, uint16_t &
count
)
const
;
45
/** @brief Return the number of occupied slots, including missing markers. */
46
uint16_t
count
()
const
{
return
count_; }
47
/** @brief Return the number of finite samples in the history. */
48
uint16_t
valid_count
()
const
{
return
valid_count_; }
49
/** @brief Return the bound storage capacity. */
50
uint16_t
capacity
()
const
{
return
capacity_; }
51
/** @brief Return whether Hampel filtering is enabled. */
52
bool
hampel_enabled
()
const
{
return
hampel_state_.enabled; }
53
54
private
:
55
float
*storage_{
nullptr
};
56
uint16_t capacity_{0U};
57
uint16_t index_{0U};
58
uint16_t count_{0U};
59
uint16_t valid_count_{0U};
60
hampel_filter_state_t
hampel_state_{};
61
lowpass_filter_state_t lowpass_state_{};
62
};
63
64
}
// namespace espectre
espectre::FilteredTurbulenceRing::bind
void bind(float *storage, uint16_t capacity)
Attach caller-owned storage and reset the history.
espectre::FilteredTurbulenceRing::capacity
uint16_t capacity() const
Return the bound storage capacity.
Definition
filtered_turbulence_ring.h:50
espectre::FilteredTurbulenceRing::count
uint16_t count() const
Return the number of occupied slots, including missing markers.
Definition
filtered_turbulence_ring.h:46
espectre::FilteredTurbulenceRing::ordered_view
const float * ordered_view(float *scratch, uint16_t scratch_capacity, uint16_t &count) const
Return the samples in chronological order.
espectre::FilteredTurbulenceRing::add
void add(float turbulence)
Filter and append one turbulence sample.
espectre::FilteredTurbulenceRing::FilteredTurbulenceRing
FilteredTurbulenceRing()
Construct an unbound history with default filter parameters.
espectre::FilteredTurbulenceRing::hampel_enabled
bool hampel_enabled() const
Return whether Hampel filtering is enabled.
Definition
filtered_turbulence_ring.h:52
espectre::FilteredTurbulenceRing::configure_hampel
void configure_hampel(bool enabled, uint8_t window_size, float threshold)
Configure and reset the Hampel filter.
espectre::FilteredTurbulenceRing::configure_lowpass
void configure_lowpass(bool enabled, float cutoff_hz)
Configure and reset the low-pass filter.
espectre::FilteredTurbulenceRing::clear
void clear()
Clear samples while preserving the configured filters.
espectre::FilteredTurbulenceRing::valid_count
uint16_t valid_count() const
Return the number of finite samples in the history.
Definition
filtered_turbulence_ring.h:48
espectre::FilteredTurbulenceRing::advance_missing_slots
void advance_missing_slots(uint32_t count)
Append missing-sample markers without running the filters.
filters.h
espectre
Definition
espectre_sdk_version.h:62
espectre::hampel_filter_state_t
hampel_turbulence_state_t hampel_filter_state_t
Definition
filters.h:52
src
cpp
core
filtered_turbulence_ring.h
Generated by
1.17.0