feat(temp): Configurable lower bound for ramp (#1706)

Similar to warn-temperature, temps below `base-temperature` will use the first ramp icon.

Closes #1703
This commit is contained in:
Kazufumi NOTO 2019-04-08 01:36:09 +09:00 committed by Patrick Ziegler
parent fca4151f36
commit 7414e98008
2 changed files with 5 additions and 1 deletions

View File

@ -29,8 +29,11 @@ namespace modules {
string m_path; string m_path;
int m_zone = 0; int m_zone = 0;
// Base temperature used for where to start the ramp
int m_tempbase = 0;
int m_tempwarn = 0; int m_tempwarn = 0;
int m_temp = 0; int m_temp = 0;
// Percentage used in the ramp
int m_perc = 0; int m_perc = 0;
// Whether or not to show units with the %temperature-X% tokens // Whether or not to show units with the %temperature-X% tokens

View File

@ -17,6 +17,7 @@ namespace modules {
: timer_module<temperature_module>(bar, move(name_)) { : timer_module<temperature_module>(bar, move(name_)) {
m_zone = m_conf.get(name(), "thermal-zone", 0); m_zone = m_conf.get(name(), "thermal-zone", 0);
m_path = m_conf.get(name(), "hwmon-path", ""s); m_path = m_conf.get(name(), "hwmon-path", ""s);
m_tempbase = m_conf.get(name(), "base-temperature", 0);
m_tempwarn = m_conf.get(name(), "warn-temperature", 80); m_tempwarn = m_conf.get(name(), "warn-temperature", 80);
m_interval = m_conf.get<decltype(m_interval)>(name(), "interval", 1s); m_interval = m_conf.get<decltype(m_interval)>(name(), "interval", 1s);
m_units = m_conf.get(name(), "units", m_units); m_units = m_conf.get(name(), "units", m_units);
@ -52,7 +53,7 @@ namespace modules {
bool temperature_module::update() { bool temperature_module::update() {
m_temp = std::strtol(file_util::contents(m_path).c_str(), nullptr, 10) / 1000.0f + 0.5f; m_temp = std::strtol(file_util::contents(m_path).c_str(), nullptr, 10) / 1000.0f + 0.5f;
int temp_f = floor(((1.8 * m_temp) + 32) + 0.5); int temp_f = floor(((1.8 * m_temp) + 32) + 0.5);
m_perc = math_util::cap(math_util::percentage(m_temp, 0, m_tempwarn), 0, 100); m_perc = math_util::cap(math_util::percentage(m_temp, m_tempbase, m_tempwarn), 0, 100);
string temp_c_string = to_string(m_temp); string temp_c_string = to_string(m_temp);
string temp_f_string = to_string(temp_f); string temp_f_string = to_string(temp_f);