From 7414e9800879cc3692af5ca217fdb18978ba8b4a Mon Sep 17 00:00:00 2001 From: Kazufumi NOTO Date: Mon, 8 Apr 2019 01:36:09 +0900 Subject: [PATCH] feat(temp): Configurable lower bound for ramp (#1706) Similar to warn-temperature, temps below `base-temperature` will use the first ramp icon. Closes #1703 --- include/modules/temperature.hpp | 3 +++ src/modules/temperature.cpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/modules/temperature.hpp b/include/modules/temperature.hpp index e69cb1a2..aa0c0a08 100644 --- a/include/modules/temperature.hpp +++ b/include/modules/temperature.hpp @@ -29,8 +29,11 @@ namespace modules { string m_path; int m_zone = 0; + // Base temperature used for where to start the ramp + int m_tempbase = 0; int m_tempwarn = 0; int m_temp = 0; + // Percentage used in the ramp int m_perc = 0; // Whether or not to show units with the %temperature-X% tokens diff --git a/src/modules/temperature.cpp b/src/modules/temperature.cpp index a6f6838e..85201aa9 100644 --- a/src/modules/temperature.cpp +++ b/src/modules/temperature.cpp @@ -17,6 +17,7 @@ namespace modules { : timer_module(bar, move(name_)) { m_zone = m_conf.get(name(), "thermal-zone", 0); 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_interval = m_conf.get(name(), "interval", 1s); m_units = m_conf.get(name(), "units", m_units); @@ -52,7 +53,7 @@ namespace modules { bool temperature_module::update() { 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); - 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_f_string = to_string(temp_f);