Skip to content

Commit

Permalink
Merge pull request #7 from wiiznokes/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
wiiznokes authored Nov 13, 2023
2 parents 6011125 + b69fbb8 commit 4f445f7
Show file tree
Hide file tree
Showing 26 changed files with 66 additions and 154 deletions.
4 changes: 2 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[env]
LMSENSORS_STATIC = "1"
LMSENSORS_INCLUDE_DIR = { value = "libsensors_build/include", relative = true }
LMSENSORS_LIB_DIR = { value = "libsensors_build/lib", relative = true }
LMSENSORS_INCLUDE_DIR = { value = "target/libsensors_build/include", relative = true }
LMSENSORS_LIB_DIR = { value = "target/libsensors_build/lib", relative = true }
RUST_LOG = "fan_control=debug,data=info,hardware=info,ui=debug"
#RUST_BACKTRACE = "1"
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ target/

# custom

test/
.test/
.idea/
.vscode/*
!.vscode/launch.json
libsensors_build/
etc/
bin/
obj/
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "libsensors"]
path = libsensors
[submodule "hardware/libsensors"]
path = hardware/libsensors
url = https://github.com/wiiznokes/libsensors
branch = pwm
branch = pwm
17 changes: 10 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,29 @@ members = [
"data",
"hardware",
"ui",
#"tray",
]


[features]
fake_hardware = [
"hardware/fake_hardware"
]


[dependencies]
data.workspace = true
hardware.workspace = true
ui.workspace = true
clap.workspace = true
log.workspace = true
env_logger.workspace = true
hardware.workspace = true

[dev-dependencies]


[workspace.dependencies]
fan-control = { version = "0.1", path = "." }
data = { version = "0.1", path = "data" }
hardware = { version = "0.1", path = "hardware" }
ui = { version = "0.1", path = "ui" }
hardware = { path = "hardware" }
data = { path = "data" }
ui = { path = "ui" }
clap = { version = "4.3", features = ["derive"] }
serde = { version = "1.0", features = ["derive", "rc"] }
serde_json = "1.0"
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
run:
clear && cargo run

fake:
clear && cargo run --features fake_hardware -- -p ./.config

conf:
clear && cargo run -- -p ./.config

Expand All @@ -23,13 +26,13 @@ expand:
clear && cargo expand

libsensors:
make -C ./libsensors/ install PREFIX=./../libsensors_build ETCDIR=./../etc
make -C ./hardware/libsensors/ install PREFIX=./../../target/libsensors_build ETCDIR=./../../target/libsensors_build/etc

clean-libsensors:
make -C ./libsensors/ clean uninstall PREFIX=./../libsensors_build ETCDIR=./../etc
make -C ./hardware/libsensors/ clean uninstall PREFIX=./../../target/libsensors_build ETCDIR=./../../target/libsensors_build/etc

test:
clear && cargo test --workspace
clear && cargo test --all --all-features


.PHONY: clean-libsensors libsensors
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
# fan-control-rs

## References
- UI plans: https://github.com/Ax9D/pw-viz/blob/main/assets/demo.png
- Iced example on canvas: https://github.com/ua-kxie/circe


# fan-control

# Steps
- [ ] finish hardware crate (windows, upgrade abstraction)
- [ ] Upgrade Value struct (allow different type: °C, %, ...)
- [ ] package Msi, Deb, Rpm, Snap, Flatpak [cargo-bundle](https://github.com/burtonageo/cargo-bundle)
- [ ] CI for packaging
- [ ] change iced to libcosmic (this will enable new widgets, like dropdown)
- [ ] impl UI for managing configs
- [ ] impl UI for removing/adding nodes
- [ ] impl UI graph behavior
- [ ] impl UI settings page
- [ ] icons
- [ ] tray icon support
- [ ] theme
- [ ] i18n

## Repo structure
- [hardware](./hardware/README.md): define an abstraction around the hardware.
- [data](./data/README.md): define structures used in the app (Node, Config), and there logic. Depend on [hardware](./hardware/README.md)
- [ui](./ui/README.md): implement the UI. Depend on [data](./data/README.md)
- the app: integrate all this crates into on executable
- [ui](./ui/README.md): implement the UI. Depend on [data](./data/README.md) and [hardware](./hardware/README.md)
- the app: integrate all this crates in one executable


# Build
Expand Down
11 changes: 6 additions & 5 deletions data/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Architecture

Each node/item/vertice have an unique ID, stored in a global hashmap.
hardware is responsible to implement an interface for each hardware items

# Concurency

Fist, the config file is deserialized into a Config structure.
The Config struct is then used to generate a Graph where each node is an item of the config.
I.e: Control, Temp, Linear, etc...
Each node have an unique ID, and is stored in a hashmap. They implement an update fonction, that take inputs value and return a value.
A node store a ref (the node id) of it's dependencies.

We can easily pass from the graph to a Config structure to serialize it.
2 changes: 1 addition & 1 deletion data/src/config/serde_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use super::linear::Linear;
use super::target::Target;
use super::temp::Temp;

const SETTINGS_DIR_PATH: &str = "./test/config/";
const SETTINGS_DIR_PATH: &str = "./.test/config/";

const SETTINGS_PATH: &str = formatcp!("{SETTINGS_DIR_PATH}settings.toml");
const HARDWARE_PATH: &str = formatcp!("{SETTINGS_DIR_PATH}hardware.toml");
Expand Down
8 changes: 7 additions & 1 deletion hardware/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ name = "hardware"
version = "0.1.0"
edition = "2021"

[features]
fake_hardware = ["rand"]


[dependencies]
serde.workspace = true
serde_json.workspace = true
rand = "0.8"
log.workspace = true


rand = {version = "0.8", optional = true}

[target.'cfg(target_os = "linux")'.dependencies]
lm-sensors = { git = "https://github.com/wiiznokes/lm-sensors.git", branch = "pwm" }

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions hardware/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ use std::{fmt::Debug, rc::Rc};
#[macro_use]
extern crate log;

#[cfg(target_os = "linux")]
#[cfg(all(not(feature = "fake_hardware"), target_os = "linux"))]
pub mod linux;

#[cfg(target_os = "windows")]
#[cfg(all(not(feature = "fake_hardware"), target_os = "windows"))]
pub mod windows;

#[cfg(feature = "fake_hardware")]
pub mod hardware_test;

#[derive(Debug, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion src/integrated_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use hardware::{hardware_test, HardwareBridge};
fn test_config() {
env_logger::init();

let dir_manager = DirManager::new(Some(PathBuf::from("./config")));
let dir_manager = DirManager::new(Some(PathBuf::from("./.config")));
let settings = dir_manager.init_settings();

let hardware = hardware_test::TestBridge::generate_hardware();
Expand Down
12 changes: 8 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use ui::run_ui;
#[macro_use]
extern crate log;

#[cfg(test)]
#[cfg(all(test, feature = "fake_hardware"))]
mod integrated_test;

fn main() {
Expand All @@ -20,12 +20,16 @@ fn main() {
let dir_manager = DirManager::new(args.config_dir_path);
let settings = dir_manager.init_settings();

#[cfg(target_os = "linux")]
#[cfg(feature = "fake_hardware")]
let hardware = hardware::hardware_test::TestBridge::generate_hardware();
//let hardware = hardware::linux::LinuxBridge::generate_hardware();

#[cfg(all(not(feature = "fake_hardware"), target_os = "linux"))]
let hardware = hardware::linux::LinuxBridge::generate_hardware();

#[cfg(target_os = "windows")]
#[cfg(all(not(feature = "fake_hardware"), target_os = "windows"))]
let hardware = hardware::windows::WindowsBridge::generate_hardware();



let hardware_file_path = dir_manager.hardware_file_path();

Expand Down
12 changes: 0 additions & 12 deletions tray/Cargo.toml

This file was deleted.

Binary file removed tray/assets/icon.png
Binary file not shown.
101 changes: 0 additions & 101 deletions tray/src/main.rs

This file was deleted.

0 comments on commit 4f445f7

Please sign in to comment.