Large code cleanup

This commit is contained in:
Luke
2021-02-06 23:18:01 +13:00
parent 39bbe33831
commit 629bdc2213
25 changed files with 124 additions and 287 deletions

View File

@@ -8,10 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Write set+apply after each array in multizone
- Remove misc bad logic
- Use same code path as 0x1866 device to configure led support
- Use same code path as 0x1866 device to configure led support for 0x1854 device
- Remove duplicate code
- Set correct speeds for multizone
- Remove dbus crate in favour of zbus. This removes the external dbus lib requirement.
- Huge internal refactor
- BREAKING CHANGE: Anime code refactor. DBUS method names have changed
# [2.2.2] - 2021-01-31
### Changed

11
Cargo.lock generated
View File

@@ -23,7 +23,7 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "asus-notify"
version = "2.0.4"
version = "3.0.0"
dependencies = [
"daemon",
"notify-rust",
@@ -33,9 +33,8 @@ dependencies = [
[[package]]
name = "asusctl"
version = "2.0.4"
version = "3.0.0"
dependencies = [
"daemon",
"gumdrop",
"rog_dbus",
"rog_types",
@@ -187,7 +186,7 @@ dependencies = [
[[package]]
name = "daemon"
version = "2.2.2"
version = "3.0.0"
dependencies = [
"env_logger",
"intel-pstate",
@@ -786,7 +785,7 @@ checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581"
[[package]]
name = "rog_dbus"
version = "2.2.1"
version = "3.0.0"
dependencies = [
"rog_fan_curve",
"rog_types",
@@ -807,7 +806,7 @@ dependencies = [
[[package]]
name = "rog_types"
version = "2.2.1"
version = "3.0.0"
dependencies = [
"gumdrop",
"rog_fan_curve",

View File

@@ -1,6 +1,6 @@
[package]
name = "asus-notify"
version = "2.0.4"
version = "3.0.0"
authors = ["Luke D Jones <luke@ljones.dev>"]
edition = "2018"

View File

@@ -1,6 +1,6 @@
[package]
name = "asusctl"
version = "2.0.4"
version = "3.0.0"
authors = ["Luke D Jones <luke@ljones.dev>"]
edition = "2018"
@@ -11,7 +11,6 @@ edition = "2018"
serde_json = "^1.0"
rog_dbus = { path = "../rog-dbus" }
rog_types = { path = "../rog-types" }
daemon = { path = "../daemon" }
gumdrop = "^0.8"
yansi-term = "^0.1"

View File

@@ -1,10 +1,9 @@
use daemon::{ctrl_fan_cpu::FanLevel, ctrl_gfx::vendors::GfxVendors};
use gumdrop::{Opt, Options};
use rog_dbus::AuraDbusClient;
use std::{env::args, process::Command};
use yansi_term::Colour::Green;
use yansi_term::Colour::Red;
use rog_types::{anime_matrix::{AniMeDataBuffer, FULL_PANE_LEN}, cli_options::{AniMeActions, AniMeStatusValue, LedBrightness, SetAuraBuiltin}, profile::{ProfileCommand, ProfileEvent}};
use rog_types::{anime_matrix::{AniMeDataBuffer, FULL_PANE_LEN}, cli_options::{AniMeActions, AniMeStatusValue, LedBrightness, SetAuraBuiltin}, gfx_vendors::GfxVendors, profile::{FanLevel, ProfileCommand, ProfileEvent}};
#[derive(Default, Options)]
struct CLIStart {
@@ -129,7 +128,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
if parsed.version {
println!(" asusctl version {}", env!("CARGO_PKG_VERSION"));
println!(" daemon version {}", daemon::VERSION);
println!(" rog-dbus version {}", rog_dbus::VERSION);
println!("rog-types version {}", rog_types::VERSION);
}

View File

@@ -1,6 +1,6 @@
[package]
name = "daemon"
version = "2.2.2"
version = "3.0.0"
license = "MPL-2.0"
readme = "README.md"
authors = ["Luke <luke@ljones.dev>"]

View File

@@ -42,7 +42,7 @@ impl ConfigV212 {
}
}
#[derive(Default, Deserialize, Serialize)]
#[derive(Deserialize, Serialize)]
pub struct Config {
pub gfx_managed: bool,
pub gfx_nv_mode_is_dedicated: bool,
@@ -57,6 +57,28 @@ pub struct Config {
pub power_profiles: BTreeMap<String, Profile>,
}
impl Default for Config {
fn default() -> Self {
let mut pwr = BTreeMap::new();
pwr.insert("normal".into(), Profile::new(0, 100, true, 0, None));
pwr.insert("boost".into(), Profile::new(0, 100, true, 1, None));
pwr.insert("silent".into(), Profile::new(0, 100, true, 2, None));
Config {
gfx_managed: true,
gfx_nv_mode_is_dedicated: true,
active_profile: "normal".into(),
toggle_profiles: vec!["normal".into(), "boost".into(), "silent".into()],
power_profile: 0,
bat_charge_limit:100,
kbd_led_brightness: 1,
kbd_backlight_mode: 0,
kbd_backlight_modes: Vec::new(),
power_profiles: pwr,
}
}
}
impl Config {
/// `load` will attempt to read the config, and panic if the dir is missing
pub fn load(supported_led_modes: &[u8]) -> Self {
@@ -92,36 +114,11 @@ impl Config {
fn create_default(file: &mut File, supported_led_modes: &[u8]) -> Self {
// create a default config here
let mut config = Config::default();
config.gfx_managed = true;
config.gfx_nv_mode_is_dedicated = true;
config.bat_charge_limit = 100;
config.kbd_backlight_mode = 0;
config.kbd_led_brightness = 1;
for n in supported_led_modes {
config.kbd_backlight_modes.push(AuraModes::from(*n))
}
let mut profile = Profile::default();
profile.fan_preset = 0;
profile.turbo = true;
config.power_profiles.insert("normal".into(), profile);
let mut profile = Profile::default();
profile.fan_preset = 1;
profile.turbo = true;
config.power_profiles.insert("boost".into(), profile);
let mut profile = Profile::default();
profile.fan_preset = 2;
config.power_profiles.insert("silent".into(), profile);
config.toggle_profiles.push("normal".into());
config.toggle_profiles.push("boost".into());
config.toggle_profiles.push("silent".into());
config.active_profile = "normal".into();
// Should be okay to unwrap this as is since it is a Default
let json = serde_json::to_string_pretty(&config).unwrap();
file.write_all(json.as_bytes())
@@ -208,3 +205,17 @@ impl Default for Profile {
}
}
}
impl Profile {
pub fn new(min_percentage: u8, max_percentage: u8, turbo: bool,
fan_preset: u8, fan_curve: Option<Curve>) -> Self {
Profile {
min_percentage,
max_percentage,
turbo,
fan_preset,
fan_curve,
}
}
}

View File

@@ -89,19 +89,13 @@ impl Dbus for CtrlAnimeDisplay {
buffer[1] = WRITE;
buffer[2] = ON_OFF;
let status_str;
if status {
buffer[3] = 0x03;
status_str = "on";
} else {
buffer[3] = 0x00;
status_str = "off";
}
self.write_bytes(&buffer).map_or_else(
|err| warn!("{}", err),
|()| info!("Turning {} the AniMe", status_str),
);
self.write_bytes(&buffer);
}
fn set_boot_on_off(&self, status: bool) {
@@ -159,7 +153,7 @@ impl CtrlAnimeDisplay {
/// Should only be used if the bytes you are writing are verified correct
#[inline]
fn write_bytes(&self, message: &[u8]) -> Result<(), AuraError> {
fn write_bytes(&self, message: &[u8]) {
match self.handle.write_control(
0x21, // request_type
0x09, // request
@@ -174,7 +168,6 @@ impl CtrlAnimeDisplay {
_ => error!("Failed to write to led interrupt: {}", err),
},
}
Ok(())
}
#[inline]
fn write_data_buffer(&self, buffer: AniMeDataBuffer) -> Result<(), AuraError> {
@@ -183,7 +176,7 @@ impl CtrlAnimeDisplay {
image[1][..7].copy_from_slice(&ANIME_PANE2_PREFIX);
for row in image.iter() {
self.write_bytes(row)?;
self.write_bytes(row);
}
self.do_flush()?;
Ok(())
@@ -211,7 +204,7 @@ impl CtrlAnimeDisplay {
image[1][..7].copy_from_slice(&ANIME_PANE2_PREFIX);
for row in image.iter() {
self.write_bytes(row)?;
self.write_bytes(row);
}
self.do_flush()?;
Ok(())
@@ -224,7 +217,7 @@ impl CtrlAnimeDisplay {
for (idx, byte) in INIT_STR.as_bytes().iter().enumerate() {
init[idx + 1] = *byte
}
self.write_bytes(&init)?;
self.write_bytes(&init);
// clear the init array and write other init message
for ch in init.iter_mut() {
@@ -233,7 +226,7 @@ impl CtrlAnimeDisplay {
init[0] = DEV_PAGE; // write it to be sure?
init[1] = INIT;
self.write_bytes(&init)?;
self.write_bytes(&init);
Ok(())
}
@@ -244,7 +237,7 @@ impl CtrlAnimeDisplay {
flush[1] = WRITE;
flush[2] = 0x03;
self.write_bytes(&flush)?;
self.write_bytes(&flush);
Ok(())
}
@@ -256,7 +249,7 @@ impl CtrlAnimeDisplay {
flush[2] = 0x01;
flush[3] = if status { 0x00 } else { 0x80 };
self.write_bytes(&flush)?;
self.write_bytes(&flush);
Ok(())
}
@@ -268,7 +261,7 @@ impl CtrlAnimeDisplay {
flush[2] = 0x01;
flush[3] = 0x80;
self.write_bytes(&flush)?;
self.write_bytes(&flush);
Ok(())
}
}

View File

@@ -101,7 +101,7 @@ impl CtrlCharge {
}
pub(super) fn set(&self, limit: u8, config: &mut Config) -> Result<(), RogError> {
if limit < 20 || limit > 100 {
if !(20..=100).contains(&limit) {
warn!(
"Unable to set battery charge limit, must be between 20-100: requested {}",
limit

View File

@@ -2,17 +2,17 @@ use crate::{
config::{Config, Profile},
GetSupported,
};
use rog_types::profile::ProfileEvent;
use rog_types::profile::{FanLevel, ProfileEvent};
use log::{info, warn};
use serde_derive::{Deserialize, Serialize};
use std::convert::TryInto;
use std::fs::OpenOptions;
use std::io::{Read, Write};
use std::path::Path;
use std::str::FromStr;
use std::sync::Arc;
use std::sync::Mutex;
use zbus::dbus_interface;
use crate::error::RogError;
static FAN_TYPE_1_PATH: &str = "/sys/devices/platform/asus-nb-wmi/throttle_thermal_policy";
static FAN_TYPE_2_PATH: &str = "/sys/devices/platform/asus-nb-wmi/fan_boost_mode";
@@ -63,7 +63,7 @@ impl DbusFanAndCpu {
ctrl.handle_profile_event(&event, &mut cfg)
.unwrap_or_else(|err| warn!("{}", err));
self.notify_profile(&cfg.active_profile)
.unwrap_or_else(|_| ());
.unwrap_or(());
}
}
}
@@ -393,46 +393,3 @@ impl CtrlFanAndCPU {
Ok(())
}
}
use crate::error::RogError;
#[derive(Debug)]
pub enum FanLevel {
Normal,
Boost,
Silent,
}
impl FromStr for FanLevel {
type Err = RogError;
fn from_str(s: &str) -> Result<Self, RogError> {
match s.to_lowercase().as_str() {
"normal" => Ok(FanLevel::Normal),
"boost" => Ok(FanLevel::Boost),
"silent" => Ok(FanLevel::Silent),
_ => Err(RogError::ParseFanLevel),
}
}
}
impl From<u8> for FanLevel {
fn from(n: u8) -> Self {
match n {
0 => FanLevel::Normal,
1 => FanLevel::Boost,
2 => FanLevel::Silent,
_ => FanLevel::Normal,
}
}
}
impl From<FanLevel> for u8 {
fn from(n: FanLevel) -> Self {
match n {
FanLevel::Normal => 0,
FanLevel::Boost => 1,
FanLevel::Silent => 2,
}
}
}

View File

@@ -10,7 +10,7 @@ use std::str::FromStr;
use std::{sync::Arc, sync::Mutex};
use sysfs_class::{PciDevice, SysClass};
use system::{GraphicsDevice, Module, PciBus};
use vendors::{GfxCtrlAction, GfxVendors};
use rog_types::gfx_vendors::{GfxCtrlAction, GfxVendors};
use zbus::dbus_interface;
use crate::*;
@@ -190,14 +190,9 @@ impl CtrlGraphics {
};
let modules = Module::all().map_err(|err| GfxError::Read("get_vendor".into(), err))?;
let driver_loaded = if modules
let driver_loaded = modules
.iter()
.any(|module| module.name == "nouveau" || module.name == "nvidia")
{
true
} else {
false
};
.any(|module| module.name == "nouveau" || module.name == "nvidia");
let vendor = if mode == "off" {
if driver_loaded {

View File

@@ -1,5 +1,3 @@
pub mod vendors;
pub mod error;
pub mod gfx;

View File

@@ -1,86 +0,0 @@
#[derive(Debug, PartialEq, Clone)]
pub enum GfxVendors {
Nvidia,
Integrated,
Compute,
Hybrid,
}
use std::str::FromStr;
use super::error::GfxError;
impl FromStr for GfxVendors {
type Err = GfxError;
fn from_str(s: &str) -> Result<Self, GfxError> {
match s.to_lowercase().as_str() {
"nvidia" => Ok(GfxVendors::Nvidia),
"hybrid" => Ok(GfxVendors::Hybrid),
"compute" => Ok(GfxVendors::Compute),
"integrated" => Ok(GfxVendors::Integrated),
"nvidia\n" => Ok(GfxVendors::Nvidia),
"hybrid\n" => Ok(GfxVendors::Hybrid),
"compute\n" => Ok(GfxVendors::Compute),
"integrated\n" => Ok(GfxVendors::Integrated),
_ => Err(GfxError::ParseVendor),
}
}
}
impl From<&GfxVendors> for &str {
fn from(mode: &GfxVendors) -> Self {
match mode {
GfxVendors::Nvidia => "nvidia",
GfxVendors::Hybrid => "hybrid",
GfxVendors::Compute => "compute",
GfxVendors::Integrated => "integrated",
}
}
}
#[derive(Debug)]
pub enum GfxCtrlAction {
Reboot,
RestartX,
None,
}
impl FromStr for GfxCtrlAction {
type Err = GfxError;
fn from_str(s: &str) -> Result<Self, GfxError> {
match s.to_lowercase().as_str() {
"reboot" => Ok(GfxCtrlAction::Reboot),
"restartx" => Ok(GfxCtrlAction::RestartX),
"none" => Ok(GfxCtrlAction::None),
_ => Err(GfxError::ParseVendor),
}
}
}
impl From<&GfxCtrlAction> for &str {
fn from(mode: &GfxCtrlAction) -> Self {
match mode {
GfxCtrlAction::Reboot => "reboot",
GfxCtrlAction::RestartX => "restartx",
GfxCtrlAction::None => "none",
}
}
}
impl From<&GfxCtrlAction> for String {
fn from(mode: &GfxCtrlAction) -> Self {
match mode {
GfxCtrlAction::Reboot => "reboot".into(),
GfxCtrlAction::RestartX => "restartx".into(),
GfxCtrlAction::None => "none".into(),
}
}
}
impl From<GfxCtrlAction> for String {
fn from(mode: GfxCtrlAction) -> Self {
(&mode).into()
}
}

View File

@@ -46,8 +46,7 @@ impl GetSupported for CtrlKbdBacklight {
per_key_led_mode = true;
let modes = modes
.iter()
.filter(|x| **x != PER_KEY)
.map(|x| *x)
.filter(|x| **x != PER_KEY).copied()
.collect();
stock_led_modes = Some(modes);
} else {
@@ -293,7 +292,7 @@ impl CtrlKbdBacklight {
warn!("led_node: {}", err);
None
},
|node| Some(node),
Some,
);
let kbd_node = Self::get_node_failover(id_product, condev_iface, Self::scan_kbd_node)
@@ -302,7 +301,7 @@ impl CtrlKbdBacklight {
warn!("kbd_node: {}", err);
None
},
|node| Some(node),
Some,
);
let bright_node = Self::get_kbd_bright_path();
@@ -375,7 +374,7 @@ impl CtrlKbdBacklight {
{
if parent
.attribute_value("idProduct")
.ok_or(RogError::NotFound("LED idProduct".into()))?
.ok_or_else(|| RogError::NotFound("LED idProduct".into()))?
== id_product
{
if let Some(dev_node) = device.devnode() {

View File

@@ -1,11 +1,12 @@
use crate::{
config::Config,
ctrl_gfx::{gfx::CtrlGraphics, vendors::GfxVendors},
ctrl_gfx::{gfx::CtrlGraphics},
error::RogError,
GetSupported,
};
//use crate::dbus::DbusEvents;
use log::{info, warn};
use rog_types::gfx_vendors::GfxVendors;
use serde_derive::{Deserialize, Serialize};
use std::convert::TryInto;
use std::fs::OpenOptions;

View File

@@ -3,17 +3,18 @@ use daemon::ctrl_fan_cpu::{CtrlFanAndCPU, DbusFanAndCpu};
use daemon::ctrl_leds::{CtrlKbdBacklight, DbusKbdBacklight};
use daemon::laptops::match_laptop;
use daemon::{
config::Config, laptops::print_board_info, supported::SupportedFunctions, GetSupported,
config::Config, laptops::print_board_info, ctrl_supported::SupportedFunctions, GetSupported,
};
use daemon::{
ctrl_anime::CtrlAnimeDisplay,
ctrl_gfx::{gfx::CtrlGraphics, vendors::GfxVendors},
ctrl_gfx::{gfx::CtrlGraphics},
};
use rog_dbus::DBUS_NAME;
use daemon::{CtrlTask, Reloadable, ZbusAdd};
use log::LevelFilter;
use log::{error, info, warn};
use rog_types::gfx_vendors::GfxVendors;
use std::error::Error;
use std::io::Write;
use std::sync::Arc;

View File

@@ -1,5 +1,6 @@
use intel_pstate::PStateError;
use rog_fan_curve::CurveError;
use rog_types::error::GraphicsError;
use std::convert::From;
use std::fmt;
@@ -64,3 +65,11 @@ impl From<CurveError> for RogError {
RogError::FanCurve(err)
}
}
impl From<GraphicsError> for RogError {
fn from(err: GraphicsError) -> Self {
match err {
GraphicsError::ParseVendor => RogError::GfxSwitching(GfxError::ParseVendor)
}
}
}

View File

@@ -1,15 +1,25 @@
#![deny(unused_must_use)]
/// Configuration loading, saving
pub mod config;
///
/// Control of AniMe matrix display
pub mod ctrl_anime;
///
/// Control of battery charge level
pub mod ctrl_charge;
/// Control CPU min/max freq and turbo, fan mode, fan curves
///
/// Intel machines can control:
/// - CPU min/max frequency
/// - CPU turbo enable/disable
/// - Fan mode (normal, boost, silent)
///
/// AMD machines can control:
/// - CPU turbo enable/disable
/// - Fan mode (normal, boost, silent)
/// - Fan min/max RPM curve
pub mod ctrl_fan_cpu;
///
/// GPU switching and power
pub mod ctrl_gfx;
///
/// Keyboard LED brightness control, RGB, and LED display modes
pub mod ctrl_leds;
/// Control ASUS bios function such as boot sound, Optimus/Dedicated gfx mode
pub mod ctrl_rog_bios;
@@ -17,7 +27,7 @@ pub mod ctrl_rog_bios;
pub mod laptops;
/// Fetch all supported functions for the laptop
pub mod supported;
pub mod ctrl_supported;
mod error;

View File

@@ -1,56 +0,0 @@
use std::convert::TryInto;
use log::warn;
use serde_derive::{Deserialize, Serialize};
use zbus::dbus_interface;
use crate::{
ctrl_anime::{AnimeSupportedFunctions, CtrlAnimeDisplay},
ctrl_charge::{ChargeSupportedFunctions, CtrlCharge},
ctrl_fan_cpu::{CtrlFanAndCPU, FanCpuSupportedFunctions},
ctrl_leds::{CtrlKbdBacklight, LedSupportedFunctions},
ctrl_rog_bios::{CtrlRogBios, RogBiosSupportedFunctions},
GetSupported,
};
#[derive(Serialize, Deserialize)]
pub struct SupportedFunctions {
anime_ctrl: AnimeSupportedFunctions,
charge_ctrl: ChargeSupportedFunctions,
fan_cpu_ctrl: FanCpuSupportedFunctions,
keyboard_led: LedSupportedFunctions,
rog_bios_ctrl: RogBiosSupportedFunctions,
}
#[dbus_interface(name = "org.asuslinux.Daemon")]
impl SupportedFunctions {
fn supported_functions(&self) -> String {
serde_json::to_string_pretty(self).unwrap()
}
}
impl crate::ZbusAdd for SupportedFunctions {
fn add_to_server(self, server: &mut zbus::ObjectServer) {
server
.at(&"/org/asuslinux/Supported".try_into().unwrap(), self)
.map_err(|err| {
warn!("SupportedFunctions: add_to_server {}", err);
err
})
.ok();
}
}
impl GetSupported for SupportedFunctions {
type A = SupportedFunctions;
fn get_supported() -> Self::A {
SupportedFunctions {
keyboard_led: CtrlKbdBacklight::get_supported(),
anime_ctrl: CtrlAnimeDisplay::get_supported(),
charge_ctrl: CtrlCharge::get_supported(),
fan_cpu_ctrl: CtrlFanAndCPU::get_supported(),
rog_bios_ctrl: CtrlRogBios::get_supported(),
}
}
}

View File

@@ -1,6 +1,6 @@
[package]
name = "rog_dbus"
version = "2.2.1"
version = "3.0.0"
license = "MPL-2.0"
readme = "README.md"
authors = ["Luke <luke@ljones.dev>"]

View File

@@ -1,6 +1,6 @@
[package]
name = "rog_types"
version = "2.2.1"
version = "3.0.0"
license = "MPL-2.0"
readme = "README.md"
authors = ["Luke <luke@ljones.dev>"]

View File

@@ -17,6 +17,12 @@ pub const ANIME_PANE2_PREFIX: [u8; 7] = [0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x0
#[derive(Debug, Deserialize, Serialize, Type)]
pub struct AniMeDataBuffer(Vec<u8>);
impl Default for AniMeDataBuffer {
fn default() -> Self {
Self::new()
}
}
impl AniMeDataBuffer {
pub fn new() -> Self {
AniMeDataBuffer(vec![0u8; FULL_PANE_LEN])

View File

@@ -205,20 +205,20 @@ pub enum AuraModes {
impl From<SetAuraBuiltin> for AuraModes {
fn from(mode: SetAuraBuiltin) -> Self {
match mode {
SetAuraBuiltin::Static(x) => AuraModes::Static(x.into()),
SetAuraBuiltin::Breathe(x) => AuraModes::Breathe(x.into()),
SetAuraBuiltin::Strobe(x) => AuraModes::Strobe(x.into()),
SetAuraBuiltin::Rainbow(x) => AuraModes::Rainbow(x.into()),
SetAuraBuiltin::Star(x) => AuraModes::Star(x.into()),
SetAuraBuiltin::Rain(x) => AuraModes::Rain(x.into()),
SetAuraBuiltin::Highlight(x) => AuraModes::Highlight(x.into()),
SetAuraBuiltin::Laser(x) => AuraModes::Laser(x.into()),
SetAuraBuiltin::Ripple(x) => AuraModes::Ripple(x.into()),
SetAuraBuiltin::Pulse(x) => AuraModes::Pulse(x.into()),
SetAuraBuiltin::Comet(x) => AuraModes::Comet(x.into()),
SetAuraBuiltin::Flash(x) => AuraModes::Flash(x.into()),
SetAuraBuiltin::MultiStatic(x) => AuraModes::MultiStatic(x.into()),
SetAuraBuiltin::MultiBreathe(x) => AuraModes::MultiBreathe(x.into()),
SetAuraBuiltin::Static(x) => AuraModes::Static(x),
SetAuraBuiltin::Breathe(x) => AuraModes::Breathe(x),
SetAuraBuiltin::Strobe(x) => AuraModes::Strobe(x),
SetAuraBuiltin::Rainbow(x) => AuraModes::Rainbow(x),
SetAuraBuiltin::Star(x) => AuraModes::Star(x),
SetAuraBuiltin::Rain(x) => AuraModes::Rain(x),
SetAuraBuiltin::Highlight(x) => AuraModes::Highlight(x),
SetAuraBuiltin::Laser(x) => AuraModes::Laser(x),
SetAuraBuiltin::Ripple(x) => AuraModes::Ripple(x),
SetAuraBuiltin::Pulse(x) => AuraModes::Pulse(x),
SetAuraBuiltin::Comet(x) => AuraModes::Comet(x),
SetAuraBuiltin::Flash(x) => AuraModes::Flash(x),
SetAuraBuiltin::MultiStatic(x) => AuraModes::MultiStatic(x),
SetAuraBuiltin::MultiBreathe(x) => AuraModes::MultiBreathe(x),
}
}
}

View File

@@ -34,8 +34,7 @@ impl FromStr for LedBrightness {
"high" => Ok(LedBrightness { level: Some(0x03) }),
_ => {
print!(
"{}\n{}\n",
"Invalid argument, must be one of:", "off, low, med, high"
"Invalid argument, must be one of: off, low, med, high"
);
Err(AuraError::ParseBrightness)
}
@@ -109,7 +108,7 @@ impl FromStr for AniMeStatusValue {
"on" => Ok(AniMeStatusValue::On),
"off" => Ok(AniMeStatusValue::Off),
_ => {
print!("{}\n{}\n", "Invalid argument, must be one of:", "on, off");
print!("Invalid argument, must be one of: on, off");
Err(AuraError::ParseAnime)
}
}

View File

@@ -17,6 +17,8 @@ pub mod fancy;
/// Helper functions for the AniMe display
pub mod anime_matrix;
pub mod gfx_vendors;
pub mod error;
pub static VERSION: &str = env!("CARGO_PKG_VERSION");