Wireless Battery Indicator (PS3)
-
The next kernel firmware will have support for rumble & battery information in the sony-hid driver (which will be used if you don't install the ps3controller driver).
You will be able to query via:
/sys/class/power_supply/sony_controller_battery_xx:xx:xx:xx:xx:xx/capacityUnfortunately, the native driver has one big downside in that it ignores the bluetooth IdleTimeout setting. If you leave your Pi on 24/7 and forget to manually turn off the controller, it will stay paired indefinitely and drain battery quite quickly.
-
Here's a very rough way to read the current battery status when ps3controller is used. Feel free to clean it up and incorporate it in your stuff:
#!/bin/bash function read_sixaxis_battery () { while read -r line; do if [[ "$line" == *"L2CAP"* ]]; then read -r line read -r line echo "$line" | awk '{ print $12 }' return fi done } hcidump -x | read_sixaxis_battery & sleep 5 pkill hcidump
You need to install bluez-hcidump and run the script with root privileges.
If you want to incorporate it into python, here's what you're looking for from the output:
hcidump -x > ACL data: handle 11 flags 0x02 dlen 54 L2CAP(d): cid 0x0041 len 50 [psm 0] A1 01 00 00 00 00 00 87 82 7E 7D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 05 16 00 00 00 00 33 FD 77 01 C0 02 09 01 F1 01 93 00 02
The battery value is the 31st in the array, shown as 05 in the above log.
-
Awesome, thanks!
I'll give this a try and let you know how it goes!
-
Anyone have this functional at all right now?
-
can we incorporate it into other controllers
-
Very cool feature!
Would be fantastic if the indicator could function similarly as the overheating or power shortage icons on the top right of the screen.
-
@zerojay said in Wireless Battery Indicator (PS3):
Anyone have this functional at all right now?
I haven't had a chance to use the newer hcidump method since I gifted my pi to a friend a while back. Now I have another one, so I might give it a shot this weekend!
@retroprogrammer said in Wireless Battery Indicator (PS3):
can we incorporate it into other controllers
Maybe, depending on how the other controllers work/connect to the pi. I get the feeling it's not a standardised system, so it probably needs to be tailored to each controller type (though once each implementation is figured out, a single script could check for all known types).
@ezra84 said in Wireless Battery Indicator (PS3):
Very cool feature!
Would be fantastic if the indicator could function similarly as the overheating or power shortage icons on the top right of the screen.
Do you mean a similar look/graphics of the icons, or similar in the sense of having a (low battery) warning?
-
@Heyoeyo Let me know if you need anyone to help with testing.
-
@heyoeyo I mean in the sense of having a low battery warning. That should be more important than the looks, but of course it would be nice if it can be implemented in the same style as the other warning icons.
-
Hello,
i tried to install this https://github.com/heyoeyo/batteryCheck
on my Raspberry Pi3 running Retropie v4.3 but once i try to run batteryCheck.py i obtain the following errorTraceback (most recent call last):
File "batCheck.py", line 98, in <module>
time_stamp = os.stat(logPath).st_mtime;
OSError: [Errno 2] No such file or directory: '/var/log/sixad'infact /var/log/sixad does not exists
-
dont work with latest retropie Version :(
-
If someone wants to get real fancy they could use pngview to make something like this : https://github.com/d-rez/gbz_overlay
-
@Heyoeyo do you know if the BatteryCheck script can be updated to work on the newer release of RetroPie?
-
@silverbullet
You would have to check the log files for whatever PS3 driver is running by default and then possible edit the lines of code it is searching for.
/var/log/sixad is the old one for the sixad driver, not sure where the other drivers logs are at. -
@madmodder123 I tried looking for that, but I don't see that sixad is logging on my system anymore. It looks like the logrotate is setup to rotate the logs in that /var/log/sixad file, but that file doesn't exist. I looked through the documentation and I don't see any mention of logging. I am not sure if the logging was removed and the remnants of the log rotation weren't removed? If you have any suggestions of where the logs are now stored, I would appreciate it.
Thanks!
-
@silverbullet
So I did a little detective work.
It looks like in RetroPie 4.4/Stretch the /var/log/sixad file was removed and the logs for sixad are sent to journald ("/run/log/journal/44377289e4ad47738189eab7cbdb463a/system.journal" on my Pi) and i'm not sure if the script can read from that file as it contains a bunch of different logs.to test this you can try changing batCheck.py from
"logPath='/var/log/sixad'" to "logPath='/run/log/journal/44377289e4ad47738189eab7cbdb463a/system.journal'" (note the big string of characters in the file path is probably different on your Pi!) and then running the script
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.