Segment/FiniteLoop

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: transition_mode::Immediate,
};
}
#include<autd3.hpp>
int main() {
using namespace autd3;
WithSegment(Static{}, Segment::S1, transition_mode::Immediate());
return 0; }
using AUTD3Sharp;
using AUTD3Sharp.TransitionMode;
using AUTD3Sharp.Modulation;
new WithSegment(
    inner: new Static(),
    segment: Segment.S1,
    transitionMode: new Immediate()
);
from pyautd3 import Segment, Static, transition_mode, WithSegment
WithSegment(
    inner=Static(),
    segment=Segment.S1,
    transition_mode=transition_mode.Immediate(),
)

The transition_mode specifies the conditions for switching Segments.

  • Only available when the destination segment is in an infinite loop

    • Immediate: Switch immediately
    • Ext: Switch immediately and enter extended mode (automatically switch segments after outputting data from each Segment)
  • Only available when the destination segment is in a finite loop

    • SyncIdx: Switch when the data index of the destination Segment becomes
    • SysTime(DcSysTime): Switch at the specified time
    • GPIO(GPIOIn): Switch when a signal is input to the specified GPIO pin

NOTE: Gain only supports Immediate.

To specify the loop behavior of the destination loop, refer to FiniteLoop.

To write data without switching Segments, specify Later for transition_mode.

Switching Segments

To switch Segments only, use SwapSegment.

use autd3::prelude::*;
fn main() {
SwapSegmentModulation(Segment::S1, transition_mode::Immediate);
}
#include<autd3.hpp>
#include<autd3/link/nop.hpp>
int main() {
using namespace autd3;
SwapSegmentModulation(Segment::S1, transition_mode::Immediate());
return 0; }
using AUTD3Sharp;
using AUTD3Sharp.TransitionMode;
new SwapSegmentModulation(Segment.S1, new Immediate());
from pyautd3 import Segment, SwapSegmentModulation, transition_mode
SwapSegmentModulation(Segment.S1, transition_mode.Immediate())

FiniteLoop

Modulation, FociSTM, and GainSTM can control loop behavior with WithFiniteLoop.

use std::num::NonZeroU16;
use autd3::prelude::*;
fn main() {
let _ = 
WithFiniteLoop {
    inner: Static::default(),
    loop_count: NonZeroU16::new(1).unwrap(),
    segment: Segment::S1,
    transition_mode: transition_mode::SyncIdx,
};
}
#include<autd3.hpp>
int main() {
using namespace autd3;
WithFiniteLoop(Static{}, 1, Segment::S1, transition_mode::SyncIdx());
return 0; }
using AUTD3Sharp;
using AUTD3Sharp.TransitionMode;
using AUTD3Sharp.Modulation;
new WithFiniteLoop(
    inner: new Static(),
    loopCount: 1,
    segment: Segment.S1,
    transitionMode: new SyncIdx()
);
from pyautd3 import Segment, Static, transition_mode, WithFiniteLoop

WithFiniteLoop(
    inner=Static(),
    loop_count=1,
    segment=Segment.S1,
    transition_mode=transition_mode.SyncIdx(),
)