Skip to content

Commit

Permalink
Emit integers, not floats
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordy F committed Nov 10, 2024
1 parent 34a2d75 commit 733410e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ impl RunArgs {

task::spawn(async move {
let mut interval = time::interval(Duration::from_millis(1000));
let mut last_input_value = 0.0;
let mut last_output_value = 0.0;
let mut last_input_value: f32 = 0.0;
let mut last_output_value: u8 = 0;
loop {
interval.tick().await;

Expand All @@ -53,9 +53,10 @@ impl RunArgs {
let output = pid
.next_control_output(last_input_value)
.output
.clamp(0.0, 100.0);
.clamp(0.0, 100.0)
.round() as u8;

if (last_output_value - output).abs() >= 1.0 {
if last_output_value != output {
last_output_value = output;
client
.publish(
Expand Down

0 comments on commit 733410e

Please sign in to comment.