Check Battery Level for Keyboard
#1
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
  Reply
#2
Per that FAQ you need to install the keyboard utilities package (link is in the "Troubleshooting" section).
  Reply
#3
(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?
  Reply
#4
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.)
  Reply
#5
(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.
  Reply
#6
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.
  Reply
#7
(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.
  Reply
#8
(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.
  Reply
#9
(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".
  Reply
#10
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
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  keyboard case charging but not typing new2pinephone 18 5,611 02-19-2024, 07:30 AM
Last Post: theResonant
  Keyboard doesn't charge my phone no matter what, so can I charge my phone directly ragreenburg 3 7,689 01-14-2024, 03:34 PM
Last Post: acid andy
  I've added an I2C connector to the PP keyboard eugenr 0 411 11-26-2023, 07:24 AM
Last Post: eugenr
  Update the PinePhone keyboard driver to support missing characters? Peter Gamma 8 8,091 10-22-2023, 08:43 PM
Last Post: Peter Gamma
  key repeat with pinephone keyboard rotwang 0 438 10-22-2023, 03:39 PM
Last Post: rotwang
Exclamation USB mouse isn't working when a PP keyboard is attached? mikeb 3 1,202 10-21-2023, 08:21 PM
Last Post: Peter Gamma
  Pinephone with mini keyboard, trackpad and large power bank? Peter Gamma 0 502 10-21-2023, 07:50 AM
Last Post: Peter Gamma
  Which mini keyboard and mouse to choose for the PP? Peter Gamma 0 603 10-21-2023, 02:55 AM
Last Post: Peter Gamma
  Use the Linux Console with the PinePhone Keyboard mburns 2 991 10-20-2023, 04:11 PM
Last Post: mburns
  How to disassemble Keyboard top and replace cables? elof 2 805 10-11-2023, 09:03 AM
Last Post: elof

Forum Jump:


Users browsing this thread: 1 Guest(s)