Advanced Aura feature

Groundwork for 'advanced' aura modes
Add single zone + Doom light flash
Fix mocking for ROGCC
Better prepare & change to mapping of keyboard layouts to models and functions
Refactor and begin using new key layout stuff
Enable first arg to rogcc to set layout in mocking feature mode
Complete refactor of key layouts, and to RON serde
This commit is contained in:
Luke D. Jones
2022-12-11 11:50:47 +13:00
parent e3ecaa92bd
commit 1cbffedaeb
134 changed files with 8249 additions and 4390 deletions

View File

@@ -1,10 +1,10 @@
use serde_derive::{Deserialize, Serialize};
use udev::Device;
#[cfg(feature = "dbus")]
use zbus::zvariant::Type;
use crate::{error::ProfileError, FanCurvePU};
use crate::error::ProfileError;
use crate::FanCurvePU;
pub(crate) fn pwm_str(fan: char, index: usize) -> String {
let mut buf = "pwm1_auto_point1_pwm".to_string();
@@ -62,12 +62,15 @@ impl From<&CurveData> for String {
impl std::str::FromStr for CurveData {
type Err = ProfileError;
/// Parse a string to the correct values that the fan curve kernel driver expects
/// Parse a string to the correct values that the fan curve kernel driver
/// expects
///
/// If the fan curve is given with percentage char '%' then the fan power values are converted
/// otherwise the expected fan power range is 0-255.
/// If the fan curve is given with percentage char '%' then the fan power
/// values are converted otherwise the expected fan power range is
/// 0-255.
///
/// Temperature range is 0-255 in degrees C. You don't want to be setting over 100.
/// Temperature range is 0-255 in degrees C. You don't want to be setting
/// over 100.
fn from_str(input: &str) -> Result<Self, Self::Err> {
let mut temp = [0u8; 8];
let mut pwm = [0u8; 8];
@@ -313,6 +316,10 @@ mod tests {
fn set_to_string() {
let set = FanCurveSet::default();
let string = String::from(&set);
assert_eq!(string.as_str(), "Enabled: false, CPU: 0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%, GPU: 0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%");
assert_eq!(
string.as_str(),
"Enabled: false, CPU: 0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%, GPU: \
0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%,0c:0%"
);
}
}

View File

@@ -1,17 +1,14 @@
pub mod error;
pub mod fan_curve_set;
use std::{
fmt::Display,
fs::OpenOptions,
io::{Read, Write},
path::Path,
};
use std::fmt::Display;
use std::fs::OpenOptions;
use std::io::{Read, Write};
use std::path::Path;
use error::ProfileError;
use fan_curve_set::{CurveData, FanCurveSet};
use serde_derive::{Deserialize, Serialize};
use udev::Device;
#[cfg(feature = "dbus")]
use zbus::zvariant::Type;
@@ -207,10 +204,11 @@ impl FanCurveProfiles {
}
}
/// Reset the stored (self) and device curve to the defaults of the platform.
/// Reset the stored (self) and device curve to the defaults of the
/// platform.
///
/// Each `platform_profile` has a different default and the defualt can be read
/// only for the currently active profile.
/// Each `platform_profile` has a different default and the defualt can be
/// read only for the currently active profile.
pub fn set_active_curve_to_defaults(
&mut self,
profile: Profile,
@@ -232,8 +230,8 @@ impl FanCurveProfiles {
}
/// Write the curves for the selected profile to the device. If the curve is
/// in the enabled list it will become active. If the curve is zeroed it will be initialised
/// to a default read from the system.
/// in the enabled list it will become active. If the curve is zeroed it
/// will be initialised to a default read from the system.
// TODO: Make this return an error if curve is zeroed
pub fn write_profile_curve_to_platform(
&mut self,