mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2025-12-06 07:12:01 +01:00
PowerControl: Add Charge Limit
This commit is contained in:
parent
b47c5fa860
commit
874cf6f974
|
|
@ -15,6 +15,7 @@
|
|||
static IntPtr PDFV = new IntPtr(0xFE700C00 + 0x4C);
|
||||
static IntPtr XBID = new IntPtr(0xFE700300 + 0xBD);
|
||||
static IntPtr PDCT = new IntPtr(0xFE700C00 + 0x01);
|
||||
static IntPtr MCBL = new IntPtr(0xFE700B00 + 0x9F);
|
||||
static ushort IO6C = 0x6C;
|
||||
|
||||
public const ushort MAX_FAN_RPM = 0x1C84;
|
||||
|
|
@ -26,6 +27,7 @@
|
|||
public byte PDCS { get; set; }
|
||||
|
||||
public bool BatteryTempLE { get; set; }
|
||||
public bool MaxBatteryCharge { get; set; }
|
||||
|
||||
public bool IsSupported(ushort deviceFirmware, byte deviceBoardID, byte devicePDCS)
|
||||
{
|
||||
|
|
@ -42,11 +44,11 @@
|
|||
private static readonly DeviceVersion[] deviceVersions = {
|
||||
// Steam Deck - LCD version
|
||||
new DeviceVersion() { Firmware = 0xB030, BoardID = 0x6, PDCS = 0 /* 0x2B */, BatteryTempLE = false },
|
||||
new DeviceVersion() { Firmware = 0xB030, BoardID = 0xA, PDCS = 0 /* 0x2B */, BatteryTempLE = false },
|
||||
new DeviceVersion() { Firmware = 0xB030, BoardID = 0xA, PDCS = 0 /* 0x2B */, BatteryTempLE = false, MaxBatteryCharge = true },
|
||||
|
||||
// Steam Deck - OLED version
|
||||
// new DeviceVersion() { Firmware = 0x1030, BoardID = 0x5, PDCS = 0 /* 0x2F */, BatteryTempLE = true },
|
||||
new DeviceVersion() { Firmware = 0x1050, BoardID = 0x5, PDCS = 0 /* 0x2F */, BatteryTempLE = true }
|
||||
new DeviceVersion() { Firmware = 0x1050, BoardID = 0x5, PDCS = 0 /* 0x2F */, BatteryTempLE = true, MaxBatteryCharge = true }
|
||||
};
|
||||
|
||||
public static Vlv0100 Instance = new Vlv0100();
|
||||
|
|
@ -178,6 +180,27 @@
|
|||
return (float)(value - 0x0AAC) / 10.0f;
|
||||
}
|
||||
|
||||
public int? GetMaxBatteryCharge()
|
||||
{
|
||||
if (SupportedDevice?.MaxBatteryCharge != true)
|
||||
return null;
|
||||
var data = inpOut?.ReadMemory(MCBL, 1);
|
||||
if (data is null)
|
||||
return null;
|
||||
if (data[0] > 100)
|
||||
return null;
|
||||
return data[0];
|
||||
}
|
||||
public void SetMaxBatteryCharge(int chargeLimit)
|
||||
{
|
||||
if (SupportedDevice?.MaxBatteryCharge != true)
|
||||
return;
|
||||
if (chargeLimit < 0 || chargeLimit > 100)
|
||||
return;
|
||||
byte[] data = BitConverter.GetBytes(chargeLimit);
|
||||
inpOut?.WriteMemory(MCBL, data);
|
||||
}
|
||||
|
||||
private void SetGain(ushort gain)
|
||||
{
|
||||
byte[] data = BitConverter.GetBytes(gain);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ namespace PowerControl
|
|||
Options.PerformanceOverlay.ModeInstance,
|
||||
Options.PerformanceOverlay.KernelDriversInstance,
|
||||
Options.FanControl.Instance,
|
||||
Options.SteamController.Instance
|
||||
Options.SteamController.Instance,
|
||||
Options.BatteryChargeLimit.Instance
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
32
PowerControl/Options/BatteryChargeLimit.cs
Normal file
32
PowerControl/Options/BatteryChargeLimit.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using CommonHelpers;
|
||||
|
||||
namespace PowerControl.Options
|
||||
{
|
||||
public static class BatteryChargeLimit
|
||||
{
|
||||
public static Menu.MenuItemWithOptions Instance = new Menu.MenuItemWithOptions()
|
||||
{
|
||||
Name = "Charge Limit",
|
||||
ApplyDelay = 1000,
|
||||
Options = { "70%", "80%", "90%", "100%" },
|
||||
ActiveOption = "?",
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
var value = int.Parse(selected.ToString().TrimEnd('%'));
|
||||
|
||||
using (var vlv0100 = new Vlv0100())
|
||||
{
|
||||
if (!vlv0100.Open())
|
||||
return null;
|
||||
|
||||
vlv0100.SetMaxBatteryCharge(value);
|
||||
|
||||
var newValue = vlv0100.GetMaxBatteryCharge();
|
||||
if (newValue is null)
|
||||
return null;
|
||||
return newValue.ToString() + "%";
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
## #{GIT_TAG_NAME}
|
||||
|
||||
- PowerControl: Add Charge Limit (70%, 80%, 90%, 100%)
|
||||
|
||||
## 0.7.1
|
||||
|
||||
- SteamDeck OLED: Support BIOS 107 with temperature readings
|
||||
|
|
|
|||
Loading…
Reference in a new issue