Skip to content

SetPulseWidthTable

SetPulseWidthTable is a command that sets the conversion table from intensity (0–255) to the PWM pulse width.

SetPulseWidthTable { table };
Field Type Description
table [PulseWidth; PWE_TABLE_SIZE] Pulse width per intensity index (0–255) (256 elements)

A PulseWidth is made with PulseWidth::new(u16) (a pulse width in 512 steps per period) or PulseWidth::from_duty(f32) (a duty ratio).

The default command sets an arcsin-shaped table. This is a table that makes the output sound pressure (theoretically) linear with respect to intensity, and it is the same table the device holds at boot.

SetPulseWidthTable::default();

empty_table returns a table whose entries are all 0.

let table = SetPulseWidthTable::empty_table();
use autd3_rs::commands::{Clear, SetPulseWidthTable, Synchronize};
use autd3_rs::geometry::{Autd3, Geometry};
use autd3_rs::Client;
use autd3_rs::udp::TransportOption;
use autd3_rs::value::PulseWidth;
let geometry = Geometry::new(vec![Autd3::default()]);
let option = TransportOption::default();
let mut client = Client::open(&geometry, &option).await?;
client.send(Clear).await?;
client.send(Synchronize).await?;
let mut table = SetPulseWidthTable::empty_table();
for (width, i) in table.iter_mut().zip(0..) {
*width = PulseWidth::new(i)?;
}
client.send(SetPulseWidthTable { table }).await?;