-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathelectron.py
More file actions
executable file
·44 lines (35 loc) · 870 Bytes
/
Copy pathelectron.py
File metadata and controls
executable file
·44 lines (35 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
import Battery
import BatteryReader
import time
import sys
bat_files = [
'/sys/class/power_supply/AC/uevent',
'/sys/class/power_supply/BAT0/uevent',
'/sys/class/power_supply/BAT1/uevent',
]
reader_list = []
for bf in bat_files:
try:
reader_list.append(BatteryReader.BatteryReader(bf))
except:
pass
while True:
bat_list = []
for reader in reader_list:
reader.read()
bat_list.append(reader.spawn_battery())
for bat in bat_list:
if bat.data.get('c_cur_now'):
i_cur_now = bat.data.get('c_cur_now')
i_p_now = bat.data.get('d_p_now')
for xbat in bat_list:
xbat.data['i_cur_now'] = i_cur_now
xbat.data['i_p_now'] = i_p_now
xbat.compute()
break
for bat in bat_list:
sys.stdout.write('\n')
sys.stdout.write(str(bat))
sys.stdout.flush()
time.sleep(3)