This is the development version of the documentation. It may change before the next release. See 0.14.x for the latest release.
SetPulseWidthTable
SetPulseWidthTable is a command that sets the conversion table from intensity (0–255) to the PWM pulse width.
SetPulseWidthTable { table };SetPulseWidthTable(table)new 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();SetPulseWidthTable()new SetPulseWidthTable();empty_table returns a table whose entries are all 0.
let table = SetPulseWidthTable::empty_table();table = SetPulseWidthTable.empty_table()var table = SetPulseWidthTable.EmptyTable();Example
Section titled “Example”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?;import asyncio
from autd3 import Client, TransportOptionfrom autd3.commands import Clear, SetPulseWidthTable, Synchronizefrom autd3.geometry import Autd3, Geometryfrom autd3.value import PulseWidth
async def main() -> None: geometry = Geometry([Autd3()]) with await Client.open(geometry, TransportOption()) as client: await client.send(Clear()) await client.send(Synchronize())
table = SetPulseWidthTable.empty_table() for i in range(len(table)): table[i] = PulseWidth(i)
await client.send(SetPulseWidthTable(table=table))
asyncio.run(main())using System.Threading.Tasks;using AUTD3;
var geometry = new Geometry(new[] { new Autd3() });using var client = await Client.OpenAsync(geometry, new TransportOption());await client.SendAsync(new Clear());await client.SendAsync(new Synchronize());
var table = SetPulseWidthTable.EmptyTable();for (var i = 0; i < table.Length; i++){ table[i] = new PulseWidth((ushort)i);}
await client.SendAsync(new SetPulseWidthTable(table));