Update peak detection

This commit is contained in:
Sebastian H. Gabrielli 2024-11-23 21:00:35 +01:00
parent 898c11a67b
commit c205f1f827
3 changed files with 65 additions and 64 deletions

View File

@ -1,5 +1,5 @@
{ {
"name": "tauri-eval", "name": "IELET3109 Heart Rate Monitor",
"private": true, "private": true,
"version": "0.1.0", "version": "0.1.0",
"type": "module", "type": "module",

View File

@ -92,7 +92,7 @@ fn create_data_listener(websockets_uri: String, data: Arc<Mutex<Vec<ECGData>>>)
.collect(); .collect();
ecg_data.push(ECGData { ecg_data.push(ECGData {
value: -voltage, value: voltage,
timestamp: Utc::now(), timestamp: Utc::now(),
}); });
@ -114,7 +114,8 @@ fn calculate_heartrate(data: State<'_, Arc<Mutex<Vec<ECGData>>>>) -> Result<usiz
let filtered_data: Vec<f32> = data.into_iter().map(|entry| entry.value).collect(); let filtered_data: Vec<f32> = data.into_iter().map(|entry| entry.value).collect();
let mut peak_finder = find_peaks::PeakFinder::new(&filtered_data); let mut peak_finder = find_peaks::PeakFinder::new(&filtered_data);
peak_finder.with_min_prominence(1.); peak_finder.with_min_prominence(0.5);
peak_finder.with_max_prominence(1.5);
//peak_finder.with_min_height(0.); //peak_finder.with_min_height(0.);
Ok(peak_finder.find_peaks().len()) Ok(peak_finder.find_peaks().len())
@ -139,8 +140,8 @@ async fn main() {
let ecg_data: Arc<Mutex<Vec<ECGData>>> = Arc::new(Mutex::new(Vec::with_capacity(2 ^ 13))); let ecg_data: Arc<Mutex<Vec<ECGData>>> = Arc::new(Mutex::new(Vec::with_capacity(2 ^ 13)));
// Create the websockets listener // Create the websockets listener
//create_data_listener("ws://192.168.128.50:81".to_string(), ecg_data.clone()); create_data_listener("ws://192.168.128.50:81".to_string(), ecg_data.clone());
create_data_listener("ws://192.168.66.210:81".to_string(), ecg_data.clone()); //create_data_listener("ws://192.168.66.210:81".to_string(), ecg_data.clone());
tauri::Builder::default() tauri::Builder::default()
.plugin(tauri_plugin_shell::init()) .plugin(tauri_plugin_shell::init())

View File

@ -27,7 +27,7 @@
}, },
"windows": [ "windows": [
{ {
"title": "tauri-eval", "title": "IELET3109 Heart Rate Monitor",
"width": 800, "width": 800,
"height": 600, "height": 600,
"useHttpsScheme": true "useHttpsScheme": true