Skip to content
This is the development version of the documentation. It may change before the next release. See 0.6.x for the latest release.

Pattern

Pattern is a command that sends the Emission of each transducer to the device.

Pattern::new(&emissions);
Pattern::with_bank(bank, &emissions);
Pattern {
bank,
emissions: &emissions,
transition_mode,
};

Pattern::new sets the destination bank to PatternBank::B0. To write to another bank, use Pattern::with_bank(bank, emissions).

Field Type Default Description
bank PatternBank PatternBank::B0 Bank to write to / play back
emissions &[Vec<Emission>] Emission pattern per device
transition_mode TransitionMode TransitionMode::Immediate Behavior when switching the bank

Several helper functions are provided for computing patterns.

Pattern is equivalent to the three commands WritePatternBuffer + ConfigPattern + ChangePatternBank, which are fused into a single frame. The following is equivalent to Pattern { bank, emissions }.

When transition_mode is TransitionMode::Later, nothing is fused: the command decomposes into the two frames WritePatternBuffer + ConfigPattern and no ChangePatternBank is sent. See the TransitionMode section of ChangePatternBank for details.

WritePatternBuffer {
bank,
index: 0,
emissions,
};
ConfigPattern {
bank,
config: SamplingConfig::new(NonZeroU16::MAX),
size: 1,
loop_behavior: LoopBehavior::Infinite,
};
ChangePatternBank {
bank,
transition_mode,
};
use autd3_rs::commands::Pattern;
use autd3_rs::geometry::{Autd3, Geometry, offset};
use autd3_rs::units::{m, mm, s};
use autd3_rs::{Client, ClientConfig};
use autd3_rs_link_nop::Nop;
use autd3_rs_pattern::{FocusOption, focus, wavelength};
let geometry = Geometry::new(vec![Autd3::default()]);
let client = Client::open(&geometry, Nop, ClientConfig::default()).await?;
let mut emissions = geometry.pattern_buffer();
focus(
&geometry,
geometry.center() + offset(0.0 * mm, 0.0 * mm, 150.0 * mm),
wavelength(340.0 * m / s),
&FocusOption::default(),
&mut emissions,
);
let mut builder = client.datagram_builder();
builder.push(Pattern::new(&emissions));
let frames = builder.build()?;
for frame in &frames {
client.send_checked(frame).await?;
}
client.close().await?;