Strongly type the Led brightness

This commit is contained in:
Luke D Jones
2021-03-22 14:09:27 +13:00
parent 7a51cd1c70
commit 03b338bdfa
6 changed files with 70 additions and 28 deletions

View File

@@ -7,14 +7,14 @@ use std::str::FromStr;
#[derive(Options)]
pub struct LedBrightness {
level: Option<u8>,
level: Option<u32>,
}
impl LedBrightness {
pub fn new(level: Option<u8>) -> Self {
pub fn new(level: Option<u32>) -> Self {
LedBrightness { level }
}
pub fn level(&self) -> Option<u8> {
pub fn level(&self) -> Option<u32> {
self.level
}
}

View File

@@ -7,13 +7,7 @@ use daemon::{
};
use gumdrop::{Opt, Options};
use rog_dbus::AuraDbusClient;
use rog_types::{
anime_matrix::{AniMeDataBuffer, FULL_PANE_LEN},
aura_modes::{AuraEffect, AuraModeNum},
cli_options::{AniMeActions, AniMeStatusValue},
gfx_vendors::GfxVendors,
profile::{FanLevel, ProfileCommand, ProfileEvent},
};
use rog_types::{anime_matrix::{AniMeDataBuffer, FULL_PANE_LEN}, aura_modes::{self, AuraEffect, AuraModeNum}, cli_options::{AniMeActions, AniMeStatusValue}, gfx_vendors::GfxVendors, profile::{FanLevel, ProfileCommand, ProfileEvent}};
use std::env::args;
use yansi_term::Colour::Green;
use yansi_term::Colour::Red;
@@ -202,7 +196,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let level = dbus.proxies().led().get_led_brightness()?;
println!("Current keyboard led brightness: {}", level.to_string());
}
Some(level) => dbus.proxies().led().set_led_brightness(level)?,
Some(level) => dbus.proxies().led().set_led_brightness(<aura_modes::LedBrightness>::from(level))?,
}
}