-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from lizard-brain/multi-device
Multi Device Working
- Loading branch information
Showing
9 changed files
with
195 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// giggletech_osc.rs | ||
|
||
// GiggleTech OSC Module | ||
// Data Sender, Tx & Rx Socket Setup | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// handle_proximity_parameter.rs | ||
|
||
use async_osc::Result; | ||
use async_std::sync::Arc; | ||
use std::{ | ||
sync::atomic::{AtomicBool}, | ||
time::Instant, | ||
}; | ||
|
||
|
||
use crate::osc_timeout; | ||
use crate::terminator; | ||
use crate::giggletech_osc; | ||
use crate::data_processing; | ||
|
||
|
||
pub(crate) async fn handle_proximity_parameter( | ||
running: Arc<AtomicBool>, | ||
device_ip: &Arc<String>, | ||
value: f32, | ||
max_speed: f32, | ||
min_speed: f32, | ||
speed_scale: f32, | ||
proximity_parameters_multi: &String, | ||
) -> Result<()> { | ||
terminator::stop(running.clone()).await?; | ||
|
||
// Update Last Signal Time for timeout clock | ||
let mut device_last_signal_times = osc_timeout::DEVICE_LAST_SIGNAL_TIME.lock().unwrap(); | ||
device_last_signal_times.insert(device_ip.to_string(), Instant::now()); | ||
|
||
if value == 0.0 { | ||
println!("Stopping pats..."); | ||
terminator::start(running.clone(), &device_ip).await?; | ||
|
||
for _ in 0..5 { | ||
giggletech_osc::send_data(&device_ip, 0i32).await?; | ||
} | ||
} else { | ||
giggletech_osc::send_data(&device_ip, | ||
data_processing::process_pat(value, max_speed, min_speed, speed_scale, proximity_parameters_multi)).await?; | ||
|
||
} | ||
Ok(()) | ||
} |
Oops, something went wrong.