Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions framework_lib/src/chromium_ec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,26 @@ impl CrosEc {
Ok((status.microphone == 1, status.camera == 1))
}

/// Let charge fully once, if currently a charge limit is set
pub fn charge_limit_override(&self) -> EcResult<()> {
let params = &[ChargeLimitControlModes::Override as u8, 0, 0];
let data = self.send_command(EcCommands::ChargeLimitControl as u16, 0, params)?;

util::assert_win_len(data.len(), 0);

Ok(())
}

/// Disable all charge limits
pub fn charge_limit_disable(&self) -> EcResult<()> {
let params = &[ChargeLimitControlModes::Disable as u8, 0, 0];
let data = self.send_command(EcCommands::ChargeLimitControl as u16, 0, params)?;

util::assert_win_len(data.len(), 0);

Ok(())
}

pub fn set_charge_limit(&self, min: u8, max: u8) -> EcResult<()> {
// Sending bytes manually because the Set command, as opposed to the Get command,
// does not return any data
Expand Down Expand Up @@ -496,8 +516,8 @@ impl CrosEc {
pub fn set_fp_led_level(&self, level: FpLedBrightnessLevel) -> EcResult<()> {
// Sending bytes manually because the Set command, as opposed to the Get command,
// does not return any data
let limits = &[level as u8, 0x00];
let data = self.send_command(EcCommands::FpLedLevelControl as u16, 0, limits)?;
let params = &[level as u8, 0x00];
let data = self.send_command(EcCommands::FpLedLevelControl as u16, 0, params)?;

util::assert_win_len(data.len(), 0);

Expand Down
12 changes: 11 additions & 1 deletion framework_lib/src/commandline/clap_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,15 @@ struct ClapCli {
#[arg(long)]
expansion_bay: bool,

/// Get or set max charge limit
/// Temporarily remove the charge limit and charge full
#[arg(long)]
charge_full: bool,

/// Remove min/max charge limit (Overwritten by BIOS on reboot)
#[arg(long)]
charge_limit_disable: bool,

/// Get or set max charge limit (Overwritten by BIOS on reboot)
#[arg(long)]
charge_limit: Option<Option<u8>>,

Expand Down Expand Up @@ -452,6 +460,8 @@ pub fn parse(args: &[String]) -> Cli {
inputdeck: args.inputdeck,
inputdeck_mode: args.inputdeck_mode,
expansion_bay: args.expansion_bay,
charge_full: args.charge_full,
charge_limit_disable: args.charge_limit_disable,
charge_limit: args.charge_limit,
charge_current_limit,
charge_rate_limit,
Expand Down
8 changes: 8 additions & 0 deletions framework_lib/src/commandline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ pub struct Cli {
pub inputdeck: bool,
pub inputdeck_mode: Option<InputDeckModeArg>,
pub expansion_bay: bool,
pub charge_full: bool,
pub charge_limit_disable: bool,
pub charge_limit: Option<Option<u8>>,
pub charge_current_limit: Option<(u32, Option<u32>)>,
pub charge_rate_limit: Option<(f32, Option<f32>)>,
Expand Down Expand Up @@ -1368,6 +1370,10 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
print_nvidia_info();
#[cfg(not(feature = "nvidia"))]
error!("Not built with nvidia feature");
} else if args.charge_full {
print_err(ec.charge_limit_override());
} else if args.charge_limit_disable {
print_err(ec.charge_limit_disable());
} else if let Some(maybe_limit) = args.charge_limit {
print_err(handle_charge_limit(&ec, maybe_limit));
} else if let Some((limit, soc)) = args.charge_current_limit {
Expand Down Expand Up @@ -1803,6 +1809,8 @@ Options:
--inputdeck-mode Set input deck power mode [possible values: auto, off, on] (Framework 16 only)
--expansion-bay Show status of the expansion bay (Framework 16 only)
--nvidia Show NVIDIA GPU information (Framework 16 only)
--charge-full Temporarily remove the charge limit and charge full
--charge-limit-disable Remove min/max charge limit (Overwritten by BIOS on reboot)
--charge-limit [<VAL>] Get or set battery charge limit (Percentage number as arg, e.g. '100')
--charge-current-limit [<VAL>] Get or set battery current charge limit (Percentage number as arg, e.g. '100')
--get-gpio <GET_GPIO> Get GPIO value by name or all, if no name provided
Expand Down
7 changes: 7 additions & 0 deletions framework_lib/src/commandline/uefi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ pub fn parse(args: &[String]) -> Cli {
inputdeck: false,
inputdeck_mode: None,
expansion_bay: false,
charge_full: false,
charge_limit_disable: false,
charge_limit: None,
charge_current_limit: None,
charge_rate_limit: None,
Expand Down Expand Up @@ -254,6 +256,11 @@ pub fn parse(args: &[String]) -> Cli {
found_an_option = true;
} else if arg == "--nvidia" {
cli.nvidia = true;
} else if arg == "--charge-full" {
cli.charge_full = true;
found_an_option = true;
} else if arg == "--charge-limit-disable" {
cli.charge_limit_disable = true;
found_an_option = true;
} else if arg == "--charge-limit" {
cli.charge_limit = if args.len() > i + 1 {
Expand Down