1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
use std::f64::consts::PI;
use autd3_driver::Drive;
use super::{Transducer, Vector3};
pub struct LegacyTransducer {
id: usize,
pos: Vector3,
x_direction: Vector3,
y_direction: Vector3,
z_direction: Vector3,
mod_delay: u16,
}
impl Transducer for LegacyTransducer {
fn new(
id: usize,
pos: Vector3,
x_direction: Vector3,
y_direction: Vector3,
z_direction: Vector3,
) -> Self {
Self {
id,
pos,
x_direction,
y_direction,
z_direction,
mod_delay: 0,
}
}
fn align_phase_at(&self, dist: f64, sound_speed: f64) -> f64 {
let wavelength = sound_speed * 1e3 / self.frequency();
dist / wavelength
}
fn position(&self) -> &Vector3 {
&self.pos
}
fn id(&self) -> usize {
self.id
}
fn x_direction(&self) -> &Vector3 {
&self.x_direction
}
fn y_direction(&self) -> &Vector3 {
&self.y_direction
}
fn z_direction(&self) -> &Vector3 {
&self.z_direction
}
fn cycle(&self) -> u16 {
4096
}
fn frequency(&self) -> f64 {
40e3
}
fn mod_delay(&self) -> u16 {
self.mod_delay
}
fn set_mod_delay(&mut self, delay: u16) {
self.mod_delay = delay;
}
fn wavelength(&self, sound_speed: f64) -> f64 {
sound_speed * 1e3 / 40e3
}
fn wavenumber(&self, sound_speed: f64) -> f64 {
2.0 * PI * 40e3 / (sound_speed * 1e3)
}
fn pack_head(tx: &mut autd3_driver::TxDatagram) {
autd3_driver::normal_legacy_head(tx);
}
fn pack_body(
phase_sent: &mut bool,
duty_sent: &mut bool,
drives: &[Drive],
tx: &mut autd3_driver::TxDatagram,
) -> anyhow::Result<()> {
autd3_driver::normal_legacy_body(drives, tx)?;
*phase_sent = true;
*duty_sent = true;
Ok(())
}
fn gain_stm_max() -> usize {
autd3_driver::GAIN_STM_LEGACY_BUF_SIZE_MAX
}
}