fix: static_cast clamp
This commit is contained in:
parent
52db1e8e68
commit
bae83ee4e3
|
@ -717,8 +717,9 @@ void waybar::modules::Network::parseSignal(struct nlattr **bss) {
|
||||||
// WiFi-hardware usually operates in the range -90 to -20dBm.
|
// WiFi-hardware usually operates in the range -90 to -20dBm.
|
||||||
const int hardwareMax = -20;
|
const int hardwareMax = -20;
|
||||||
const int hardwareMin = -90;
|
const int hardwareMin = -90;
|
||||||
signal_strength_ =
|
const int strength =
|
||||||
std::clamp(((signal_strength_dbm_ - hardwareMin) / double{hardwareMax - hardwareMin}) * 100, 0, 100);
|
((signal_strength_dbm_ - hardwareMin) / double{hardwareMax - hardwareMin}) * 100;
|
||||||
|
signal_strength_ = std::clamp(strength, 0, 100);
|
||||||
}
|
}
|
||||||
if (bss[NL80211_BSS_SIGNAL_UNSPEC] != nullptr) {
|
if (bss[NL80211_BSS_SIGNAL_UNSPEC] != nullptr) {
|
||||||
signal_strength_ = nla_get_u8(bss[NL80211_BSS_SIGNAL_UNSPEC]);
|
signal_strength_ = nla_get_u8(bss[NL80211_BSS_SIGNAL_UNSPEC]);
|
||||||
|
|
Loading…
Reference in New Issue