Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce noise #228

Merged
merged 2 commits into from
May 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/software/control/src/chip/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,21 @@ impl Chip {
let snapshot_time =
self.boot_time.unwrap() + Duration::microseconds(snapshot.systick as i64);

// Fetch last pressure value in order to reduce noise
let last_pressure = if let Some(last_pressure_inner) = self.data_pressure.get(0) {
last_pressure_inner.1
} else {
0
};

// Low pass filter
let new_point = last_pressure as i16
- ((last_pressure as i16 - snapshot.pressure as i16)
/ TELEMETRY_POINTS_LOW_PASS_DEGREE as i16);

// Points are stored as mmH20 (for more precision; though we do work in cmH20)
self.data_pressure
.push_front((snapshot_time, snapshot.pressure));
.push_front((snapshot_time, new_point as u16));
}

pub fn get_state(&self) -> &ChipState {
Expand Down
3 changes: 2 additions & 1 deletion src/software/control/src/config/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub const DISPLAY_STOPPED_MESSAGE_PADDING_BOTTOM: f64 = 22.0;

pub const TELEMETRY_POINTS_PRECISION_DIVIDE: u16 = 10;
pub const TELEMETRY_POINTS_PER_SECOND: usize = 100;
pub const TELEMETRY_POINTS_LOW_PASS_DEGREE: u16 = 4;

pub const TELEMETRY_WIDGET_SPACING_FROM_BOTTOM: f64 = 18.0;
pub const TELEMETRY_WIDGET_SIZE_WIDTH: f64 = 116.0;
Expand All @@ -82,7 +83,7 @@ pub const GRAPH_DRAW_MARGIN_TOP: u32 = 0;
pub const GRAPH_DRAW_MARGIN_BOTTOM: u32 = 10;
pub const GRAPH_DRAW_MARGIN_LEFT: u32 = 0;
pub const GRAPH_DRAW_MARGIN_RIGHT: u32 = 0;
pub const GRAPH_DRAW_LINE_SIZE: u32 = 1;
pub const GRAPH_DRAW_LINE_SIZE: u32 = 2;
pub const GRAPH_DRAW_POINT_SIZE: u32 = 0;
pub const GRAPH_DRAW_LABEL_JITTER_FIX_WIDTH: u32 = 40;
pub const GRAPH_DRAW_LABEL_WIDTH: u32 = 28;
Expand Down