netstar pushed a commit to branch master.

http://git.enlightenment.org/apps/evisum.git/commit/?id=93afb7f45d772b199d50236e176a5b7c7c1b5215

commit 93afb7f45d772b199d50236e176a5b7c7c1b5215
Author: Alastair Poole <nets...@gmail.com>
Date:   Tue Apr 6 07:28:08 2021 +0100

    sensors: hidpp linux coarse battery...
---
 src/bin/system/machine/sensors.bogox | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/bin/system/machine/sensors.bogox 
b/src/bin/system/machine/sensors.bogox
index 082def1..a8a1f5d 100644
--- a/src/bin/system/machine/sensors.bogox
+++ b/src/bin/system/machine/sensors.bogox
@@ -470,6 +470,28 @@ _battery_state_get(power_t *power)
              power->batteries[i]->charge_current = atol(buf);
              free(buf);
           }
+        else
+          {
+             // Fallback to "coarse" representation.
+             snprintf(path, sizeof(path), "%s/capacity_level", link);
+             buf = file_contents(path);
+             if (buf)
+               {
+                  power->batteries[i]->charge_full = 100;
+                  if (buf[0] == 'F')
+                    power->batteries[i]->charge_current = 100;
+                  else if (buf[0] == 'H')
+                    power->batteries[i]->charge_current = 75;
+                  else if (buf[0] == 'N')
+                    power->batteries[i]->charge_current = 50;
+                  else if (buf[0] == 'L')
+                    power->batteries[i]->charge_current = 25;
+                  else if (buf[0] == 'C')
+                    power->batteries[i]->charge_current = 5;
+
+                  free(buf);
+               }
+          }
         free(naming);
      }
 done:

-- 


Reply via email to