From 95756064b9deb44f3b26c46dbce8ba62f046582c Mon Sep 17 00:00:00 2001 From: Tushar Shah Date: Tue, 30 Jul 2024 21:52:53 -0600 Subject: [PATCH] lint and clippy fixes --- input_controller/src/main.rs | 27 +++++++++++++-------------- output_controller/src/main.rs | 20 ++++++++++---------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/input_controller/src/main.rs b/input_controller/src/main.rs index aed45a2..526df15 100644 --- a/input_controller/src/main.rs +++ b/input_controller/src/main.rs @@ -3,12 +3,10 @@ extern crate panic_halt; -use arduino_hal::hal::port::{ - PE4, PJ0, PJ1, -}; +use arduino_hal::hal::port::{PE4, PJ0, PJ1}; +use arduino_hal::port; use arduino_hal::port::mode::{Input, Output}; use arduino_hal::prelude::*; -use arduino_hal::port; use max485::Max485; use hotline::hotline_protocol::HotlineMessage; @@ -94,10 +92,9 @@ fn main() -> ! { usb.write_str("[Sign] Lighting Pilot...\n").unwrap(); } sign_pilot = true; - } else { - if sign_pilot { - usb.write_str("[Sign] Turning Off Pilot...\n").unwrap(); - } + } else if sign_pilot { + usb.write_str("[Sign] Turning Off Pilot...\n").unwrap(); + sign_pilot = false; } let all = sign_pin_all.is_low(); @@ -138,11 +135,10 @@ fn main() -> ! { usb.write_str("[MegaPoofer] Lighting Pilot...\n").unwrap(); } mp_pilot = true; - } else { - if mp_pilot { - usb.write_str("[MegaPoofer] Turning Off Pilot...\n") - .unwrap(); - } + } else if mp_pilot { + usb.write_str("[MegaPoofer] Turning Off Pilot...\n") + .unwrap(); + mp_pilot = false; } let all = mp_pin_all.is_low(); @@ -157,7 +153,10 @@ fn main() -> ! { match send_message(&mut rs485, msg) { Ok(()) => {} - Err(()) => {} + Err(()) => { + usb.write_str("[MegaPoofer] Error Sending Hotline Message\n") + .unwrap(); + } } } else { if mp_arm { diff --git a/output_controller/src/main.rs b/output_controller/src/main.rs index e89c2c5..0443573 100644 --- a/output_controller/src/main.rs +++ b/output_controller/src/main.rs @@ -32,7 +32,6 @@ fn main() -> ! { let mut pin_output_5 = pins.d32.into_output(); let mut pin_output_6 = pins.d34.into_output(); let mut pin_output_7 = pins.d36.into_output(); - // RS485 digital output pin let mut pin_rs485_enable = pins.d2.into_output(); @@ -58,14 +57,14 @@ fn main() -> ! { let mut rs485 = Max485::new(serial, pin_rs485_enable); usb.write_str("Serial Initialized\n").unwrap(); - let mut states: [bool; 4] = [false; 4]; + let mut states: [bool; 8] = [false; 8]; loop { // Read a byte from the serial connection match receive_command(&mut rs485, &mut usb) { Some(msg) => { let device_id = msg.device_id; // 0x00 - Sign, 0x01 - MegaPoofer, 0xFF - All outputs - if device_id == 0x01 || device_id == 0x00 || device_id == 0xFF { + if device_id == 0x01 || device_id == 0x00 || device_id == 0xFF { if let Some(state) = msg.get_dio_state(0) { if state != states[0] { if state { @@ -174,13 +173,14 @@ fn main() -> ! { } } } - usb.write_str("Received command - ").unwrap(); - ufmt::uwrite!( - usb, - "Device ID: {:X}, States: {:?}\n", - msg.device_id, - states, - ).unwrap(); + usb.write_str("Received command - ").unwrap(); + ufmt::uwrite!( + usb, + "Device ID: {:X}, States: {:?}\n", + msg.device_id, + states, + ) + .unwrap(); } _ => { usb.write_str("Failed to parse command.\n").unwrap();