Compare commits
3 commits
dc014ca1c7
...
2b3fb4ac9a
Author | SHA1 | Date | |
---|---|---|---|
2b3fb4ac9a | |||
83983a111d | |||
d7489d5d04 |
11 changed files with 130 additions and 16 deletions
|
@ -32,6 +32,30 @@ pub enum ApiMessage {
|
||||||
UploadCurrentVariant(String, String), // SteamID, Steam username
|
UploadCurrentVariant(String, String), // SteamID, Steam username
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl core::fmt::Display for ApiMessage {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
Self::Battery(x) => write!(f, "Battery;{}", x),
|
||||||
|
Self::Cpu(x) => write!(f, "Cpu;{}", x),
|
||||||
|
Self::Gpu(x) => write!(f, "Gpu;{}", x),
|
||||||
|
Self::General(x) => write!(f, "General;{}", x),
|
||||||
|
Self::OnResume => write!(f, "OnResume"),
|
||||||
|
Self::OnPluggedIn => write!(f, "OnPluggedIn"),
|
||||||
|
Self::OnUnplugged => write!(f, "OnUnplugged"),
|
||||||
|
Self::OnChargeChange(x) => write!(f, "OnChargeChange({:?})", x),
|
||||||
|
Self::PowerVibeCheck => write!(f, "PowerVibeCheck"),
|
||||||
|
Self::WaitForEmptyQueue(_) => write!(f, "WaitForEmptyQueue"),
|
||||||
|
Self::LoadSettings(path, name, variant, variant_name) => write!(f, "LoadSettings({}, {}, {}, {})", path, name, variant, variant_name),
|
||||||
|
Self::LoadVariant(variant, variant_name) => write!(f, "LoadVariant({}, {})", variant, variant_name),
|
||||||
|
Self::LoadMainSettings => write!(f, "LoadMainSettings"),
|
||||||
|
Self::LoadSystemSettings => write!(f, "LoadSystemSettings"),
|
||||||
|
Self::GetLimits(_) => write!(f, "GetLimits"),
|
||||||
|
Self::GetProvider(s, _) => write!(f, "GetProvider({})", s),
|
||||||
|
Self::UploadCurrentVariant(id, user) => write!(f, "UploadCurrentVariant(id: {}, user: {})", id, user),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub enum BatteryMessage {
|
pub enum BatteryMessage {
|
||||||
SetChargeRate(Option<u64>),
|
SetChargeRate(Option<u64>),
|
||||||
GetChargeRate(Callback<Option<u64>>),
|
GetChargeRate(Callback<Option<u64>>),
|
||||||
|
@ -46,6 +70,24 @@ pub enum BatteryMessage {
|
||||||
GetChargeLimit(Callback<Option<f64>>),
|
GetChargeLimit(Callback<Option<f64>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl core::fmt::Display for BatteryMessage {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
Self::SetChargeRate(x) => write!(f, "SetChargeRate({:?})", x),
|
||||||
|
Self::GetChargeRate(_) => write!(f, "GetChargeRate"),
|
||||||
|
Self::SetChargeMode(x) => write!(f, "SetChargeMode({:?})", x),
|
||||||
|
Self::GetChargeMode(_) => write!(f, "GetChargeMode"),
|
||||||
|
Self::ReadChargeFull(_) => write!(f, "ReadChargeFull"),
|
||||||
|
Self::ReadChargeNow(_) => write!(f, "ReadChargeNow"),
|
||||||
|
Self::ReadChargeDesign(_) => write!(f, "ReadChargeDesign"),
|
||||||
|
Self::ReadCurrentNow(_) => write!(f, "ReadCurrentNow"),
|
||||||
|
Self::ReadChargePower(_) => write!(f, "ReadChargePower"),
|
||||||
|
Self::SetChargeLimit(x) => write!(f, "SetChargeLimit({:?})", x),
|
||||||
|
Self::GetChargeLimit(_) => write!(f, "GetChargeLimit"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl BatteryMessage {
|
impl BatteryMessage {
|
||||||
fn process(self, settings: &mut dyn TBattery) -> bool {
|
fn process(self, settings: &mut dyn TBattery) -> bool {
|
||||||
let dirty = self.is_modify();
|
let dirty = self.is_modify();
|
||||||
|
@ -87,6 +129,23 @@ pub enum CpuMessage {
|
||||||
GetCpusGovernor(Callback<Vec<String>>),
|
GetCpusGovernor(Callback<Vec<String>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl core::fmt::Display for CpuMessage {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
Self::SetCpuOnline(i, x) => write!(f, "SetCpuOnline({}, {})", i, x),
|
||||||
|
Self::SetCpusOnline(x) => write!(f, "SetCpusOnline({:?})", x),
|
||||||
|
Self::SetSmt(x, _) => write!(f, "SetChargeMode({})", x),
|
||||||
|
Self::GetSmt(_) => write!(f, "GetSmt"),
|
||||||
|
Self::GetCpusOnline(_) => write!(f, "GetCpusOnline"),
|
||||||
|
Self::SetClockLimits(x, y) => write!(f, "SetClockLimits({}, {:?})", x, y),
|
||||||
|
Self::GetClockLimits(x, _) => write!(f, "GetClockLimits({})", x),
|
||||||
|
Self::SetCpuGovernor(i, x) => write!(f, "SetCpuGovernor({}, {})", i, x),
|
||||||
|
Self::SetCpusGovernor(x) => write!(f, "SetCpusGovernor({:?})", x),
|
||||||
|
Self::GetCpusGovernor(_) => write!(f, "GetCpusGovernor"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl CpuMessage {
|
impl CpuMessage {
|
||||||
fn process(self, settings: &mut dyn TCpus) -> bool {
|
fn process(self, settings: &mut dyn TCpus) -> bool {
|
||||||
let dirty = self.is_modify();
|
let dirty = self.is_modify();
|
||||||
|
@ -206,6 +265,19 @@ pub enum GpuMessage {
|
||||||
GetMemoryClock(Callback<Option<u64>>),
|
GetMemoryClock(Callback<Option<u64>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl core::fmt::Display for GpuMessage {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
Self::SetPpt(x, y) => write!(f, "SetPpt(fast {:?}, slow {:?})", x, y),
|
||||||
|
Self::GetPpt(_) => write!(f, "GetPpt"),
|
||||||
|
Self::SetClockLimits(x) => write!(f, "SetClockLimits({:?})", x),
|
||||||
|
Self::GetClockLimits(_) => write!(f, "GetClockLimits"),
|
||||||
|
Self::SetMemoryClock(x) => write!(f, "SetMemoryClock({:?})", x),
|
||||||
|
Self::GetMemoryClock(_) => write!(f, "GetMemoryClock"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl GpuMessage {
|
impl GpuMessage {
|
||||||
fn process(self, settings: &mut dyn TGpu) -> bool {
|
fn process(self, settings: &mut dyn TGpu) -> bool {
|
||||||
let dirty = self.is_modify();
|
let dirty = self.is_modify();
|
||||||
|
@ -242,6 +314,21 @@ pub enum GeneralMessage {
|
||||||
ApplyNow,
|
ApplyNow,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl core::fmt::Display for GeneralMessage {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
Self::SetPersistent(x) => write!(f, "SetPersistent({})", x),
|
||||||
|
Self::GetPersistent(_) => write!(f, "GetPersistent"),
|
||||||
|
Self::GetCurrentProfileName(_) => write!(f, "GetCurrentProfileName"),
|
||||||
|
Self::GetPath(_) => write!(f, "GetPath"),
|
||||||
|
Self::GetCurrentVariant(_) => write!(f, "GetCurrentVariant"),
|
||||||
|
Self::GetAllVariants(_) => write!(f, "GetAllVariants"),
|
||||||
|
Self::AddVariant(variant, _) => write!(f, "AddVariant(name: `{}` [...])", variant.name),
|
||||||
|
Self::ApplyNow => write!(f, "ApplyNow"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl GeneralMessage {
|
impl GeneralMessage {
|
||||||
fn process(self, settings: &mut dyn TGeneral) -> bool {
|
fn process(self, settings: &mut dyn TGeneral) -> bool {
|
||||||
let dirty = self.is_modify();
|
let dirty = self.is_modify();
|
||||||
|
@ -285,20 +372,31 @@ fn print_errors(call_name: &str, errors: Vec<crate::settings::SettingError>) {
|
||||||
log::error!("Settings {}() err:\n{}", call_name, err_list);
|
log::error!("Settings {}() err:\n{}", call_name, err_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn print_messages(msgs: &Vec<String>) {
|
||||||
|
let mut log_msg = String::new();
|
||||||
|
for msg in msgs.iter() {
|
||||||
|
//use core::fmt::Write;
|
||||||
|
write!(log_msg, "{}, ", msg).unwrap();
|
||||||
|
}
|
||||||
|
log::info!("Processed messages: [{}]", log_msg);
|
||||||
|
}
|
||||||
|
|
||||||
impl ApiMessageHandler {
|
impl ApiMessageHandler {
|
||||||
pub fn process_forever(&mut self, settings: &mut Settings) {
|
pub fn process_forever(&mut self, settings: &mut Settings) {
|
||||||
crate::utility::ioperm_power_ec();
|
crate::utility::ioperm_power_ec();
|
||||||
//let mut dirty_echo = true; // set everything twice, to make sure PowerTools wins on race conditions
|
//let mut dirty_echo = true; // set everything twice, to make sure PowerTools wins on race conditions
|
||||||
while let Ok(msg) = self.intake.recv() {
|
while let Ok(msg) = self.intake.recv() {
|
||||||
|
let mut messages = vec![msg.to_string()]; // keep messages for logging
|
||||||
let mut dirty = self.process(settings, msg);
|
let mut dirty = self.process(settings, msg);
|
||||||
while let Ok(msg) = self.intake.try_recv() {
|
while let Ok(msg) = self.intake.try_recv() {
|
||||||
|
messages.push(msg.to_string());
|
||||||
dirty |= self.process(settings, msg);
|
dirty |= self.process(settings, msg);
|
||||||
}
|
}
|
||||||
if dirty
|
if dirty
|
||||||
/*|| dirty_echo */
|
/*|| dirty_echo */
|
||||||
{
|
{
|
||||||
//dirty_echo = dirty; // echo only once
|
//dirty_echo = dirty; // echo only once
|
||||||
|
print_messages(&messages);
|
||||||
// run on_set
|
// run on_set
|
||||||
if let Err(e) = settings.on_set() {
|
if let Err(e) = settings.on_set() {
|
||||||
print_errors("on_set", e);
|
print_errors("on_set", e);
|
||||||
|
|
BIN
translations/en-US.mo
Normal file
BIN
translations/en-US.mo
Normal file
Binary file not shown.
16
translations/en-US.po
Normal file
16
translations/en-US.po
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# TEMPLATE TITLE.
|
||||||
|
# Copyright (C) 2024 NGnius
|
||||||
|
# This file is distributed under the same license as the PowerTools package.
|
||||||
|
# NGnius (Graham) <ngniusness@gmail.com>, 2024.
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: v1.1\n"
|
||||||
|
"Report-Msgid-Bugs-To: https://git.ngni.us/NG-SD-Plugins/PowerTools/PowerTools/issues\n"
|
||||||
|
"POT-Creation-Date: 2023-01-09 19:52-0500\n"
|
||||||
|
"PO-Revision-Date: 2024-05-07 18:42-0500\n"
|
||||||
|
"Last-Translator: \n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"Language: en-US\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
|
@ -73,8 +73,8 @@ msgstr "Control de carga de la batería mientras está encendido"
|
||||||
|
|
||||||
#: components/battery.tsx:74
|
#: components/battery.tsx:74
|
||||||
# (Battery maximum input current with unit)
|
# (Battery maximum input current with unit)
|
||||||
msgid "Maximum (%)"
|
msgid "Maximum (mA)"
|
||||||
msgstr "Máximo (%)"
|
msgstr "Máximo (mA)"
|
||||||
|
|
||||||
#: components/battery.tsx:97,115
|
#: components/battery.tsx:97,115
|
||||||
# (Battery charge mode override toggle)
|
# (Battery charge mode override toggle)
|
||||||
|
|
|
@ -92,8 +92,8 @@ msgstr "Contrôler le taux de charge quand actif"
|
||||||
|
|
||||||
# (Battery maximum input current with unit)
|
# (Battery maximum input current with unit)
|
||||||
#: components/battery.tsx:74
|
#: components/battery.tsx:74
|
||||||
msgid "Maximum (%)"
|
msgid "Maximum (mA)"
|
||||||
msgstr "Maximum (%)"
|
msgstr "Maximum (mA)"
|
||||||
|
|
||||||
# (Battery charge mode override toggle)
|
# (Battery charge mode override toggle)
|
||||||
#: components/battery.tsx:97,115
|
#: components/battery.tsx:97,115
|
||||||
|
|
|
@ -76,8 +76,8 @@ msgstr "Controlla la velocità di ricarica quando il Deck è attivo"
|
||||||
|
|
||||||
# (Battery maximum input current with unit)
|
# (Battery maximum input current with unit)
|
||||||
#: components/battery.tsx:74
|
#: components/battery.tsx:74
|
||||||
msgid "Maximum (%)"
|
msgid "Maximum (mA)"
|
||||||
msgstr "Massimo (%)"
|
msgstr "Massimo (mA)"
|
||||||
|
|
||||||
# (Battery charge mode override toggle)
|
# (Battery charge mode override toggle)
|
||||||
#: components/battery.tsx:97,115
|
#: components/battery.tsx:97,115
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: v1.1\n"
|
"Project-Id-Version: v1.1\n"
|
||||||
"Report-Msgid-Bugs-To: https://github.com/NGnius/PowerTools/issues\n"
|
"Report-Msgid-Bugs-To: https://git.ngni.us/NG-SD-Plugins/PowerTools/issues\n"
|
||||||
"POT-Creation-Date: 2023-01-09 19:52-0500\n"
|
"POT-Creation-Date: 2023-01-09 19:52-0500\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
|
|
|
@ -81,8 +81,8 @@ msgstr "Контролируйте уровень тока заряда бата
|
||||||
|
|
||||||
#: components/battery.tsx:74
|
#: components/battery.tsx:74
|
||||||
# (Battery maximum input current with unit)
|
# (Battery maximum input current with unit)
|
||||||
msgid "Maximum (%)"
|
msgid "Maximum (mA)"
|
||||||
msgstr "Максимум (%)"
|
msgstr "Максимум (mA)"
|
||||||
|
|
||||||
#: components/battery.tsx:97,115
|
#: components/battery.tsx:97,115
|
||||||
# (Battery charge mode override toggle)
|
# (Battery charge mode override toggle)
|
||||||
|
|
|
@ -81,8 +81,8 @@ msgstr "Контролюйте рівень струму заряджання б
|
||||||
|
|
||||||
#: components/battery.tsx:74
|
#: components/battery.tsx:74
|
||||||
# (Battery maximum input current with unit)
|
# (Battery maximum input current with unit)
|
||||||
msgid "Maximum (%)"
|
msgid "Maximum (mA)"
|
||||||
msgstr "Максимум (%)"
|
msgstr "Максимум (mA)"
|
||||||
|
|
||||||
#: components/battery.tsx:97,115
|
#: components/battery.tsx:97,115
|
||||||
# (Battery charge mode override toggle)
|
# (Battery charge mode override toggle)
|
||||||
|
|
|
@ -67,8 +67,8 @@ msgstr "控制电池充电效率"
|
||||||
|
|
||||||
#: components/battery.tsx:74
|
#: components/battery.tsx:74
|
||||||
# (Battery maximum input current with unit)
|
# (Battery maximum input current with unit)
|
||||||
msgid "Maximum (%)"
|
msgid "Maximum (mA)"
|
||||||
msgstr "最大 (%)"
|
msgstr "最大 (mA)"
|
||||||
|
|
||||||
#: components/battery.tsx:97,115
|
#: components/battery.tsx:97,115
|
||||||
# (Battery charge mode override toggle)
|
# (Battery charge mode override toggle)
|
||||||
|
|
|
@ -68,8 +68,8 @@ msgstr "控制電池充電效率"
|
||||||
|
|
||||||
#: components/battery.tsx:74
|
#: components/battery.tsx:74
|
||||||
# (Battery maximum input current with unit)
|
# (Battery maximum input current with unit)
|
||||||
msgid "Maximum (%)"
|
msgid "Maximum (mA)"
|
||||||
msgstr "最大 (%)"
|
msgstr "最大 (mA)"
|
||||||
|
|
||||||
#: components/battery.tsx:97,115
|
#: components/battery.tsx:97,115
|
||||||
# (Battery charge mode override toggle)
|
# (Battery charge mode override toggle)
|
||||||
|
|
Loading…
Reference in a new issue