Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jackra1n committed Nov 22, 2024
1 parent 53c208b commit 9dcb551
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Display, Box<dyn std::error::Error>> {
Expand All @@ -83,7 +89,7 @@ fn initialize_display(i2c: I2cdev) -> Result<Display, Box<dyn std::error::Error>
.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)
}

6 changes: 3 additions & 3 deletions src/fan_controller.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -105,7 +105,7 @@ fn main() -> Result<(), Box<dyn Error>> {
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));
}
Expand Down

0 comments on commit 9dcb551

Please sign in to comment.