Segment/LoopBehavior
Segment
The data areas of Modulation
, Gain
, FociSTM
, and GainSTM
each have two Segments
.
Unless otherwise specified, Segment::S0
is used.
The Segment
to which data is written is specified with WithSegment
.
use autd3::prelude::*;
fn main() {
let _ =
WithSegment {
inner: Static::default(),
segment: Segment::S1,
transition_mode: Some(TransitionMode::Immediate),
};
}
#include<autd3.hpp>
int main() {
using namespace autd3;
WithSegment(Static{}, Segment::S1, TransitionMode::Immediate());
return 0; }
using AUTD3Sharp;
using AUTD3Sharp.Modulation;
new WithSegment(
inner: new Static(),
segment: Segment.S1,
transitionMode: TransitionMode.Immediate
);
from pyautd3 import Segment, Static, TransitionMode, WithSegment
WithSegment(
inner=Static(),
segment=Segment.S1,
transition_mode=TransitionMode.Immediate,
)
The transition_mode
specifies the conditions for switching Segments
.
-
Only available when the destination segment is in an infinite loop
Immediate
: Switch immediatelyExt
: Switch immediately and enter extended mode (automatically switch segments after outputting data from eachSegment
)
-
Only available when the destination segment is in a finite loop
SyncIdx
: Switch when the data index of the destinationSegment
becomesSysTime(DcSysTime)
: Switch at the specified timeGPIO(GPIOIn)
: Switch when a signal is input to the specified GPIO pin
NOTE:
Gain
only supportsImmediate
.
To specify the loop behavior of the destination loop, refer to
LoopBehavior
.
To write data without switching Segments
, specify None
for transition_mode
.
Switching Segments
To switch Segments
only, use SwapSegment
.
use autd3::prelude::*;
fn main() {
SwapSegment::Modulation(Segment::S1, TransitionMode::Immediate);
}
#include<autd3.hpp>
#include<autd3/link/nop.hpp>
int main() {
using namespace autd3;
SwapSegment::Modulation(Segment::S1, TransitionMode::Immediate());
return 0; }
using AUTD3Sharp;
SwapSegment.Modulation(Segment.S1, TransitionMode.Immediate);
from pyautd3 import Segment, SwapSegment, TransitionMode
SwapSegment.Modulation(Segment.S1, TransitionMode.Immediate)
LoopBehavior
Modulation
, FociSTM
, and GainSTM
can control loop behavior with WithLoopBehavior
.
use std::num::NonZeroU16;
use autd3::prelude::*;
fn main() {
let _ =
WithLoopBehavior {
inner: Static::default(),
loop_behavior: LoopBehavior::Infinite,
segment: Segment::S1,
transition_mode: Some(TransitionMode::Immediate),
};
let _ =
WithLoopBehavior {
inner: Static::default(),
loop_behavior: LoopBehavior::Finite(NonZeroU16::new(1).unwrap()),
segment: Segment::S1,
transition_mode: Some(TransitionMode::SyncIdx),
};
}
#include<autd3.hpp>
int main() {
using namespace autd3;
WithLoopBehavior(Static{}, LoopBehavior::Infinite(), Segment::S1,
TransitionMode::Immediate());
WithLoopBehavior(Static{}, LoopBehavior::Finite(1), Segment::S1,
TransitionMode::SyncIdx());
return 0; }
using AUTD3Sharp;
using AUTD3Sharp.Modulation;
new WithLoopBehavior(
inner: new Static(),
loopBehavior: LoopBehavior.Infinite,
segment: Segment.S1,
transitionMode: TransitionMode.Immediate
);
new WithLoopBehavior(
inner: new Static(),
loopBehavior: LoopBehavior.Finite(1),
segment: Segment.S1,
transitionMode: TransitionMode.SyncIdx
);
from pyautd3 import Segment, Static, TransitionMode, LoopBehavior, WithLoopBehavior
WithLoopBehavior(
inner=Static(),
loop_behavior=LoopBehavior.Infinite,
segment=Segment.S1,
transition_mode=TransitionMode.Immediate,
)
WithLoopBehavior(
inner=Static(),
loop_behavior=LoopBehavior.Finite(1),
segment=Segment.S1,
transition_mode=TransitionMode.SyncIdx,
)