On PC file /sys/class/backlight/.../max_brightness can contain 0
when backlight control is not supported. Added check helps to avoid
dividing by zero and printing NaN.
---
src/devices/backlight.cpp | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/devices/backlight.cpp b/src/devices/backlight.cpp
index b8c9147..82cb1e0 100644
--- a/src/devices/backlight.cpp
+++ b/src/devices/backlight.cpp
@@ -145,6 +145,9 @@ double backlight::utilization(void)
{
double p;
+ if (max_level == 0)
+ return 0.0;
+
p = 100.0 * (end_level + start_level) / 2 / max_level;
return p;
}
--
1.7.5.4