diff --git a/lib/xpp b/lib/xpp index 8c019e6d..ab6247ba 160000 --- a/lib/xpp +++ b/lib/xpp @@ -1 +1 @@ -Subproject commit 8c019e6d7fefd2468791bc1cbf90d68ff7c1ba33 +Subproject commit ab6247ba7baee2c06d35534e81ae27f622ebd5b4 diff --git a/src/modules/battery.cpp b/src/modules/battery.cpp index be9e4ea4..f2563820 100644 --- a/src/modules/battery.cpp +++ b/src/modules/battery.cpp @@ -342,24 +342,18 @@ namespace modules { * same time. */ void battery_module::subthread() { - chrono::duration dur{0.0}; - - if (battery_module::state::CHARGING == m_state && m_animation_charging) { - dur += chrono::milliseconds{m_animation_charging->framerate()}; - } else if (battery_module::state::DISCHARGING == m_state && m_animation_discharging) { - dur += chrono::milliseconds{m_animation_discharging->framerate()}; - } else { - dur += 1s; - } + m_log.trace("%s: Start of subthread", name()); while (running()) { - for (int i = 0; running() && i < dur.count(); ++i) { - if (m_state == battery_module::state::CHARGING || - m_state == battery_module::state::DISCHARGING) { - broadcast(); - } - sleep(dur); + int framerate = 1000; // milliseconds + if (m_state == battery_module::state::CHARGING) { + broadcast(); + framerate = m_animation_charging->framerate(); + } else if (m_state == battery_module::state::DISCHARGING) { + broadcast(); + framerate = m_animation_discharging->framerate(); } + this_thread::sleep_for(std::chrono::milliseconds(framerate)); } m_log.trace("%s: End of subthread", name());