mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 09:23:19 +01:00
fixed interger division bug and related tests, as well as a comment bug
This commit is contained in:
@@ -216,7 +216,7 @@ pub enum AuraZone {
|
|||||||
|
|
||||||
/// Default factory modes structure. This easily converts to an USB HID packet with:
|
/// Default factory modes structure. This easily converts to an USB HID packet with:
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// let bytes: [u8; LED_MSG_LEN] = mode.into();
|
/// // let bytes: [u8; LED_MSG_LEN] = mode.into();
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg_attr(feature = "dbus", derive(Type))]
|
#[cfg_attr(feature = "dbus", derive(Type))]
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
|
|||||||
@@ -71,10 +71,10 @@ impl std::str::FromStr for CurveData {
|
|||||||
} else {
|
} else {
|
||||||
let mut p = r;
|
let mut p = r;
|
||||||
if percentages {
|
if percentages {
|
||||||
p *= 255 / 100;
|
|
||||||
if r > 100 {
|
if r > 100 {
|
||||||
return Err(ProfileError::ParseFanCurvePercentOver100(r));
|
return Err(ProfileError::ParseFanCurvePercentOver100(r));
|
||||||
}
|
}
|
||||||
|
p = (p as f32 * 2.55).round() as u8;
|
||||||
}
|
}
|
||||||
if pwm_prev > p {
|
if pwm_prev > p {
|
||||||
return Err(ProfileError::ParseFanCurvePrevHigher(
|
return Err(ProfileError::ParseFanCurvePrevHigher(
|
||||||
@@ -222,7 +222,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(curve.fan, FanCurvePU::CPU);
|
assert_eq!(curve.fan, FanCurvePU::CPU);
|
||||||
assert_eq!(curve.temp, [30, 49, 59, 69, 79, 89, 99, 109]);
|
assert_eq!(curve.temp, [30, 49, 59, 69, 79, 89, 99, 109]);
|
||||||
assert_eq!(curve.pwm, [1, 2, 3, 4, 31, 49, 56, 58]);
|
assert_eq!(curve.pwm, [3, 5, 8, 10, 79, 125, 143, 148]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user