Skip to content

Commit 8aa7a1d

Browse files
committed
examples: Make ET200B example slightly more pleasant
Replace the fast cycling debug code with a 1Hz blinking pattern on the outputs.
1 parent b7086eb commit 8aa7a1d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

examples/remote-io-et200b.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ fn main() {
7373
println!("Connecting to the bus...");
7474
let mut phy = phy::SerialPortPhy::new(BUS_DEVICE, fdl.parameters().baudrate);
7575

76+
let start = profirust::time::Instant::now();
77+
7678
fdl.set_online();
7779
dp_master.enter_operate();
7880
loop {
@@ -92,11 +94,11 @@ fn main() {
9294
if io.is_running() {
9395
println!("Inputs: {:08b}", io.pi_i()[0]);
9496

95-
if io.pi_q_mut()[0] == 0x55 {
96-
io.pi_q_mut()[0] = 0xAA;
97+
io.pi_q_mut()[0] = if (now - start).secs() % 2 == 0 {
98+
0xAA
9799
} else {
98-
io.pi_q_mut()[0] = 0x55;
99-
}
100+
0x55
101+
};
100102
}
101103
}
102104

0 commit comments

Comments
 (0)