const GIGABYTE_RTX3080TI_VISION_OC_ADDR: u8 = 0x63;
pub trait Machine {
- fn set_color(&mut self, color: &rgb::RGB);
+ fn set_color(&mut self, color: &rgb::RGB) {
+ self.set_color_1(&color);
+ self.set_color_2(&color);
+ }
+ fn set_color_1(&mut self, color: &rgb::RGB);
+ fn set_color_2(&mut self, color: &rgb::RGB);
fn get_gpu_tmp(&self) -> f32;
fn get_cpu_tmp(&self) -> f32;
}
}
impl Machine for MachineJiji {
- fn set_color(&mut self, color: &rgb::RGB) {
+ fn set_color_1(&mut self, color: &rgb::RGB) {
for controller in &self.ram {
controller.set_color(&color);
}
- self.b650e_device.set_color(&color);
- // if let Err(error) = self.a770.set_color(color.red, color.green, color.blue) {
- // error!("Unable to set color: {:?}", error);
- // }
+ self.b650e_device.set_color(&color).unwrap();
}
+ fn set_color_2(&mut self, color: &rgb::RGB) {} // No color 2.
+
fn get_gpu_tmp(&self) -> f32 {
// unsafe { intel_arc::GetTemperature(self.gpu_devices, 0) as f32 }
self.gpus[0].thermal_settings(None).unwrap()[0]
}
impl Machine for MachineLyssMetal {
- fn set_color(&mut self, color: &rgb::RGB) {
+ fn set_color_1(&mut self, color: &rgb::RGB) {
self.crosshair_device.set_color(&color).unwrap();
self.corsair_lignting_pro.set_color(&color);
- self.lian_li_sl_infinity.set_color(&color);
// self.set_color_3080ti(&color); // TODO.
}
+ fn set_color_2(&mut self, color: &rgb::RGB) {
+ self.lian_li_sl_infinity.set_color(&color);
+ }
+
fn get_gpu_tmp(&self) -> f32 {
self.gpus[0].thermal_settings(None).unwrap()[0]
.current_temperature
mod tests;
mod timer;
+// Important: when starting as a service, the directory where the log and config files
+// are put is 'C:\Windows\System32\config\systemprofile\AppData\Roaming\Temp2RGB'.
fn main() -> Result<()> {
let is_debug = cfg!(debug_assertions);
winring0::init();
let sleep = timer::Sleep::new();
- let settings = settings::Settings::read(consts::FILE_CONF).expect("Cannot load settings");
+
+ let file_conf_path = if cfg!(debug_assertions) {
+ String::from(consts::FILE_CONF)
+ } else {
+ String::from(
+ dirs::config_dir()
+ .unwrap()
+ .join(consts::SERVICE_NAME)
+ .join(consts::FILE_CONF)
+ .to_str()
+ .unwrap(),
+ )
+ };
+
+ let settings = settings::Settings::read(&file_conf_path).expect("Cannot load settings");
println!("Settings: {settings:?}");
let mut machine: Box<dyn machine::Machine> = match settings.machine_name {
1f32,
); // Between 0 (cold) and 1 (hot).
- let color =
- rgb::linear_interpolation(settings.cold_color, settings.hot_color, normalized_temp);
+ let color_1 =
+ rgb::linear_interpolation(settings.cold_color_1, settings.hot_color_1, normalized_temp);
+
+ let color_2 = match (settings.cold_color_2, settings.hot_color_2) {
+ (Some(cold_color), Some(hot_color)) => Some(rgb::linear_interpolation(
+ cold_color,
+ hot_color,
+ normalized_temp,
+ )),
+ _ => None,
+ };
// println!("normalized_temp: {normalized_temp}");
if tick % (consts::FREQ_TEMP_POLLING / consts::FREQ_REFRESHING_RGB) as i64 == 0 {
- println!("Update RGB: {color:?}, temp: {mean_temp}");
- machine.set_color(&color);
+ println!("Update RGB: {color_1:?}/{color_2:?}, temp: {mean_temp}");
+ machine.set_color_1(&color_1);
+ if color_2.is_some() {
+ machine.set_color_2(&color_2.unwrap());
+ } else {
+ machine.set_color_2(&color_1);
+ }
}
let elapsed = time::Instant::now() - time_beginning_loop;
use serde::{Deserialize, Serialize};
-#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
+#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq)]
pub struct RGB {
pub red: u8,
pub green: u8,
#[derive(Debug, Deserialize, Serialize)]
pub struct Settings {
pub machine_name: MachineName,
- pub cold_color: RGB,
- pub hot_color: RGB,
+ pub cold_color_1: RGB,
+ pub hot_color_1: RGB,
+ pub cold_color_2: Option<RGB>,
+ pub hot_color_2: Option<RGB>,
// Average temperature between CPU and GPU.
pub cold_temperature: f32,
pub hot_temperature: f32,
fn default() -> Self {
Settings {
machine_name: MachineName::Jiji,
- cold_color: RGB {
+ cold_color_1: RGB {
red: 0,
green: 255,
blue: 40,
},
- hot_color: RGB {
+ hot_color_1: RGB {
red: 255,
green: 0,
blue: 0,
},
+ cold_color_2: None,
+ hot_color_2: None,
cold_temperature: 55.,
hot_temperature: 75.,
}