From 9dcb5516774fcd16016ee37132f151fb6c0c26ec Mon Sep 17 00:00:00 2001 From: jackra1n <45038833+jackra1n@users.noreply.github.com> Date: Fri, 22 Nov 2024 02:02:30 +0100 Subject: [PATCH] Some fixes --- src/display.rs | 8 +++++++- src/fan_controller.rs | 6 +++--- src/main.rs | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/display.rs b/src/display.rs index 78f2c7d..233ded3 100644 --- a/src/display.rs +++ b/src/display.rs @@ -75,6 +75,12 @@ impl PoeDisplay { Ok(()) } + + pub fn clear(&mut self) -> Result<(), DisplayError> { + self.display.clear(BinaryColor::Off)?; + self.display.flush()?; + Ok(()) + } } fn initialize_display(i2c: I2cdev) -> Result> { @@ -83,7 +89,7 @@ fn initialize_display(i2c: I2cdev) -> Result .into_buffered_graphics_mode(); disp.init().map_err(|e| format!("Display initialization error: {:?}", e))?; - disp.set_brightness(Brightness::DIMMEST)?; + disp.set_brightness(Brightness::DIMMEST); Ok(disp) } diff --git a/src/fan_controller.rs b/src/fan_controller.rs index fcb8b84..359d760 100644 --- a/src/fan_controller.rs +++ b/src/fan_controller.rs @@ -1,5 +1,5 @@ use linux_embedded_hal::I2cdev; -use pcf857x::{OutputPin, Pcf8574, SlaveAddr}; +use pcf857x::{Pcf8574, SlaveAddr}; use anyhow::{anyhow, Result}; use log::debug; @@ -24,8 +24,8 @@ impl FanController { } let i2c = I2cdev::new(I2C_BUS_PATH)?; - debug!("I2C device initialized"); - let expander = Pcf8574::new(i2c, SlaveAddr::default()); + let address = SlaveAddr::default(); + let expander = Pcf8574::new(i2c, address); debug!("pcf8574 IO Expander initialized"); Ok(FanController { diff --git a/src/main.rs b/src/main.rs index 9dd4b55..4c39a7d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ use std::error::Error; use std::fs; use std::thread; use std::time::{Duration, Instant}; -use sysinfo::{System, Disks, RefreshKind, CpuRefreshKind, MemoryRefreshKind}; +use sysinfo::{System, Disks, RefreshKind, CpuRefreshKind, MemoryRefreshKind, Networks}; use log::{info, debug, trace}; use clap::Parser; use env_logger::{Builder, Env}; @@ -105,7 +105,7 @@ fn main() -> Result<(), Box> { if elapsed_time < SCREEN_TIMEOUT || (elapsed_time - SCREEN_TIMEOUT) % DISPLAY_OFF_DURATION < DISPLAY_ON_DURATION { poe_disp.update(&ip_address, cpu_usage, temp_str, ram_usage, &disk_usage).unwrap(); } else { - poe_disp.clear(BinaryColor::Off)?; + poe_disp.clear(); } thread::sleep(Duration::from_secs(1)); }