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.

ChangePatternBank

ChangePatternBank is a low-level command that switches the Pattern bank to be played.

ChangePatternBank {
bank,
transition_mode,
};
Field Type Description
bank PatternBank Destination bank
transition_mode TransitionMode Behavior on switching
Immediate Immediate
SyncIdx When the playback index next becomes 0
SysTime(DcSysTime, margin) At the specified DC system time (margin is optional, see below)
Gpio(GpioIn) Trigger on the specified GPIO input pin
Ext Extended mode (automatically switches to the next bank when playback within the bank finishes)
Later Does not transition (only writes to the bank)

SysTime rejects a time earlier than “now + margin” with a MISS_TRANSITION_TIME error, because the FPGA may miss a transition whose time is too close. The margin defaults to 10 ms.

Later means “only write to the bank, do not transition”. Specifying it as the transition_mode of Modulation / FociStm / PatternStm writes and configures the bank without sending the trailing bank change. Specifying it on ChangeModulationBank / ChangePatternBank themselves, which are the transition commands, is a build-time error. Because Later never transitions, it is also exempt from the LoopBehavior combination constraint.

See GPIO pins for details on Gpio(GpioIn).

When switching to the same bank, the TransitionMode and LoopBehavior settings have no effect. For details on bank operation see the bank switching tutorial.

ChangePatternBank is sent after preparing the bank with WritePatternBuffer + ConfigPattern to switch the playback target.

use core::num::NonZeroU16;
use autd3_rs::commands::{ChangePatternBank, ConfigPattern, WritePatternBuffer};
use autd3_rs::geometry::{Autd3, Geometry, offset};
use autd3_rs::units::{m, mm, s};
use autd3_rs::value::{LoopBehavior, PatternBank, SamplingConfig, TransitionMode};
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 bank = PatternBank::B0;
let mut builder = client.datagram_builder();
builder.push(WritePatternBuffer {
bank,
index: 0,
emissions: &emissions,
});
builder.push(ConfigPattern {
bank,
config: SamplingConfig::new(NonZeroU16::MAX),
size: 1,
loop_behavior: LoopBehavior::Infinite,
});
builder.push(ChangePatternBank {
bank,
transition_mode: TransitionMode::Immediate,
});
let frames = builder.build()?;
for frame in &frames {
client.send_checked(frame).await?;
}
client.close().await?;