PINE64
Check Battery Level for Keyboard - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PinePhone (https://forum.pine64.org/forumdisplay.php?fid=120)
+--- Forum: PinePhone Accessories (https://forum.pine64.org/forumdisplay.php?fid=123)
+--- Thread: Check Battery Level for Keyboard (/showthread.php?tid=16012)

Pages: 1 2


Check Battery Level for Keyboard - ragreenburg - 02-07-2022

Anyone know how to check the battery level for the keyboard? In Megi's FAQ it shows you can run the command below but every time I try to run that I get command unknown. I am using Arch and the keyboard/charger are working just fine but I can't get any info on the battery level.
Code:
ppkb-i2c-charger-ctl info



RE: Check Battery Level for Keyboard - Zebulon Walton - 02-07-2022

Per that FAQ you need to install the keyboard utilities package (link is in the "Troubleshooting" section).


RE: Check Battery Level for Keyboard - ragreenburg - 02-07-2022

(02-07-2022, 02:02 PM)Zebulon Walton Wrote: Per that FAQ you need to install the keyboard utilities package (link is in the "Troubleshooting" section).

Maybe I'm confused here but what he is linking to is the keyboard firmware which should be installed if I am able to use the keyboard, right?


RE: Check Battery Level for Keyboard - Zebulon Walton - 02-07-2022

It's supposed to be "firmware and tools". It looks like you have to clone the source tree with git and then build from source. (On Mobian to get the C compiler, make, etc., you need to "sudo apt-get install build-essential". Not sure on other distros.)

Code:
git clone https://megous.com/git/pinephone-keyboard

Then you cd into the resulting pinephone-keyboard directory where there's a Makefile which has a target to build the tools/utilities. So if you have the prerequisites installed the following would build everything, or just build the tools, respectively:

Code:
make            # Build everything

make tools      # Build tools/utilities only

However, it appears that one of the prerequisites is php, when running either make command the following diagnostic is issued because that's not installed:

Code:
php keymaps/map-to-c.php keymaps/physical-map.txt keymaps/factory-keymap.txt build/kmap.h
make: php: No such file or directory
make: *** [Makefile:21: build/kmap.h] Error 127

The problem is that "apt-get install php" wants to drag in a bunch of other stuff including the apache web server and I really don't want that. (Though I could install all that stuff, build the tools, then remove it all afterwards.)


RE: Check Battery Level for Keyboard - ragreenburg - 02-07-2022

(02-07-2022, 02:44 PM)Zebulon Walton Wrote: It's supposed to be "firmware and tools".  It looks like you have to clone the source tree with git and then build from source. (On Mobian to get the C compiler, make, etc., you need to "sudo apt-get install build-essential". Not sure on other distros.)

Code:
git clone https://megous.com/git/pinephone-keyboard

Then you cd into the resulting pinephone-keyboard directory where there's a Makefile which has a target to build the tools/utilities. So if you have the prerequisites installed the following would build everything, or just build the tools, respectively:

Code:
make            # Build everything

make tools      # Build tools/utilities only

However, it appears that one of the prerequisites is php, when running either make command the following diagnostic is issued because that's not installed:

Code:
php keymaps/map-to-c.php keymaps/physical-map.txt keymaps/factory-keymap.txt build/kmap.h
make: php: No such file or directory
make: *** [Makefile:21: build/kmap.h] Error 127

The problem is that "apt-get install php" wants to drag in a bunch of other stuff including the apache web server and I really don't want that. (Though I could install all that stuff, build the tools, then remove it all afterwards.)

Thank you for the help! On Arch Php was only 3 packages and was like 20 mb so I may have had the other stuff installed or maybe Arch just packages it differently. Either way, I built it but now running the same command as I listed in my original post, still gives the same error. I rebooted and tried again with the keyboard attached and same thing.

Edit:
It seems like they are inside of the build directory. I assumed I would be able to run them from anywhere but I was mistaken. Unfortunately I found this out after disconnecting my keyboard so I will have to reattach it all and see if that is actually working.


RE: Check Battery Level for Keyboard - Zebulon Walton - 02-07-2022

You should be able to copy the executable file to /usr/local/bin and as long as that's in your search path (I think it usually is on Linux) it will be picked up when you invoke it on the command line. Or you could define a bash alias, which might not be a bad idea anyway to make shorter and easier to type command out of it without actually changing the name of the executable file.

I don't want to get into installing Apache on my eMMC installation, so maybe what I'll do is boot up on a Mobian sd card and build the tools which can then be copied to the eMMc.


RE: Check Battery Level for Keyboard - ragreenburg - 02-07-2022

(02-07-2022, 03:35 PM)Zebulon Walton Wrote: You should be able to copy the executable file to /usr/local/bin and as long as that's in your search path (I think it usually is on Linux) it will be picked up when you invoke it on the command line.  Or you could define a bash alias, which might not be a bad idea anyway to make shorter and easier to type command out of it without actually changing the name of the executable file.

I don't want to get into installing Apache on my eMMC installation, so maybe what I'll do is boot up on a Mobian sd card and build the tools which can then be copied to the eMMc.

So I got it running but it seems like I may need to shim my keyboard because the charger status is always at "idle" and it doesn't seem to be charging my PPPro. Plus the voltage hasn't changed in the last 20 minutes or so.


RE: Check Battery Level for Keyboard - Zebulon Walton - 02-07-2022

(02-07-2022, 04:55 PM)ragreenburg Wrote: So I got it running but it seems like I may need to shim my keyboard because the charger status is always at "idle" and it doesn't seem to be charging my PPPro. Plus the voltage hasn't changed in the last 20 minutes or so.

I found with mine that with the keyboard attached, the Phosh charging indicator displays but the percentage of charge doesn't budge. I left it all hooked up to a charger with the phone turned off until the charger display showed no more current draw (presumably fully charged) and now the phone shows 100% charged. So it looks like the battery level is maintained when the phoneis turned on but for charging to take place it needs to be turned off.


RE: Check Battery Level for Keyboard - ragreenburg - 02-07-2022

(02-07-2022, 05:09 PM)Zebulon Walton Wrote:
(02-07-2022, 04:55 PM)ragreenburg Wrote: So I got it running but it seems like I may need to shim my keyboard because the charger status is always at "idle" and it doesn't seem to be charging my PPPro. Plus the voltage hasn't changed in the last 20 minutes or so.

I found with mine that with the keyboard attached, the Phosh charging indicator displays but the percentage of charge doesn't budge. I left it all hooked up to a charger with the phone turned off until the charger display showed no more current draw (presumably fully charged) and now the phone shows 100% charged. So it looks like the battery level is maintained when the phoneis turned on but for charging to take place it needs to be turned off.
I noticed that when I got the keyboard fully charged the output said "charged" rather than "idle".


RE: Check Battery Level for Keyboard - Zebulon Walton - 02-07-2022

Building the keyboard utilities on an SD card loaded up with the prerequisites and copying them over to the eMMC's /usr/local/sbin worked fine. (Since root privileges are needed to run them I put them in sbin.) To make it easy to check battery status from the command line I added /usr/local/sbin/ppkb-i2c-charger-ctl to the sudoers file as a command not requiring a password for sudo and added the following in .bashrc to make the command "kbatt" to check keyboard battery status:

Code:
alias kbatt='sudo /usr/local/sbin/ppkb-i2c-charger-ctl info'

Also the i2c-dev module is required to be loaded but apparently is not by default, so I added it to the /etc/modules file to hopefully be loaded at boot time.

I have not played around with any of the other options or utilities. Controlling power and charging between the phone's battery and the keyboard battery is still very much a work in progress as documented in Megi's development log:

https://xnux.eu/log/#057