Compare commits

...

3 commits

Author SHA1 Message Date
2b3fb4ac9a Make Stanto happy #152 2024-05-07 18:46:21 -04:00
83983a111d Revert "Update battery charge rate to % #156"
This reverts commit dc014ca1c7.
2024-05-07 18:44:30 -04:00
d7489d5d04 Add more logging for #153 2024-05-07 18:40:06 -04:00
11 changed files with 130 additions and 16 deletions

View file

@ -32,6 +32,30 @@ pub enum ApiMessage {
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 {
SetChargeRate(Option<u64>),
GetChargeRate(Callback<Option<u64>>),
@ -46,6 +70,24 @@ pub enum BatteryMessage {
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 {
fn process(self, settings: &mut dyn TBattery) -> bool {
let dirty = self.is_modify();
@ -87,6 +129,23 @@ pub enum CpuMessage {
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 {
fn process(self, settings: &mut dyn TCpus) -> bool {
let dirty = self.is_modify();
@ -206,6 +265,19 @@ pub enum GpuMessage {
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 {
fn process(self, settings: &mut dyn TGpu) -> bool {
let dirty = self.is_modify();
@ -242,6 +314,21 @@ pub enum GeneralMessage {
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 {
fn process(self, settings: &mut dyn TGeneral) -> bool {
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);
}
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 {
pub fn process_forever(&mut self, settings: &mut Settings) {
crate::utility::ioperm_power_ec();
//let mut dirty_echo = true; // set everything twice, to make sure PowerTools wins on race conditions
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);
while let Ok(msg) = self.intake.try_recv() {
messages.push(msg.to_string());
dirty |= self.process(settings, msg);
}
if dirty
/*|| dirty_echo */
{
//dirty_echo = dirty; // echo only once
print_messages(&messages);
// run on_set
if let Err(e) = settings.on_set() {
print_errors("on_set", e);

BIN
translations/en-US.mo Normal file

Binary file not shown.

16
translations/en-US.po Normal file
View 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"

View file

@ -73,8 +73,8 @@ msgstr "Control de carga de la batería mientras está encendido"
#: components/battery.tsx:74
# (Battery maximum input current with unit)
msgid "Maximum (%)"
msgstr "Máximo (%)"
msgid "Maximum (mA)"
msgstr "Máximo (mA)"
#: components/battery.tsx:97,115
# (Battery charge mode override toggle)

View file

@ -92,8 +92,8 @@ msgstr "Contrôler le taux de charge quand actif"
# (Battery maximum input current with unit)
#: components/battery.tsx:74
msgid "Maximum (%)"
msgstr "Maximum (%)"
msgid "Maximum (mA)"
msgstr "Maximum (mA)"
# (Battery charge mode override toggle)
#: components/battery.tsx:97,115

View file

@ -76,8 +76,8 @@ msgstr "Controlla la velocità di ricarica quando il Deck è attivo"
# (Battery maximum input current with unit)
#: components/battery.tsx:74
msgid "Maximum (%)"
msgstr "Massimo (%)"
msgid "Maximum (mA)"
msgstr "Massimo (mA)"
# (Battery charge mode override toggle)
#: components/battery.tsx:97,115

View file

@ -5,7 +5,7 @@
msgid ""
msgstr ""
"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"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"

View file

@ -81,8 +81,8 @@ msgstr "Контролируйте уровень тока заряда бата
#: components/battery.tsx:74
# (Battery maximum input current with unit)
msgid "Maximum (%)"
msgstr "Максимум (%)"
msgid "Maximum (mA)"
msgstr "Максимум (mA)"
#: components/battery.tsx:97,115
# (Battery charge mode override toggle)

View file

@ -81,8 +81,8 @@ msgstr "Контролюйте рівень струму заряджання б
#: components/battery.tsx:74
# (Battery maximum input current with unit)
msgid "Maximum (%)"
msgstr "Максимум (%)"
msgid "Maximum (mA)"
msgstr "Максимум (mA)"
#: components/battery.tsx:97,115
# (Battery charge mode override toggle)

View file

@ -67,8 +67,8 @@ msgstr "控制电池充电效率"
#: components/battery.tsx:74
# (Battery maximum input current with unit)
msgid "Maximum (%)"
msgstr "最大 (%)"
msgid "Maximum (mA)"
msgstr "最大 (mA)"
#: components/battery.tsx:97,115
# (Battery charge mode override toggle)

View file

@ -68,8 +68,8 @@ msgstr "控制電池充電效率"
#: components/battery.tsx:74
# (Battery maximum input current with unit)
msgid "Maximum (%)"
msgstr "最大 (%)"
msgid "Maximum (mA)"
msgstr "最大 (mA)"
#: components/battery.tsx:97,115
# (Battery charge mode override toggle)