Reading battery level from mmbasic

Can the battery charge level be read or estimated from MMBASIC?

supposedly you can get the percentage via i2c of the keyboard in register REG_ID_BAT = 0x0b

Direct get bat info from PicoMIte(MMBasic), no

but I add the sample code in

basicly just like @pkr said

send i2c command 0x0b to the keyboard and get return data

Then I found out there is a bug in current keyboard firmware

if we send i2c command 0x0b to the kbd ,there is a high odds that will crash keyboard

And I fixed this bug

so If you are really interesting in this ,here is the docs for How to flash the new firmware into keyboard of picocalc

important note is if we want the correct battery percent

we need to insert batteries first without any cable
then Power ON PIcoCalc
then we can plug typec cable , get battery info from serial port or else.

There is also a shortcut on keyboard to get battery level

on keyboard press Alt+B
the top-left led will blink

  • 3 times means full,or above 80%
  • 2 times means 50%
  • 1 means low

However, due to the low power consumption of the picocalc ,even 1 blink will last enough time

6 Likes

what a legend!

oh please. I am sorry but no need to be sarcastic

I’m managing all these codes alone, so occasional bugs are inevitable

1 Like

I literally mean you are a legend for what you are doing, only love and appreciation.

1 Like

Oh I see,thanks

This may be a misunderstanding caused by language barriers. no big deal

And I’m definitely not deserve “legend” word, overly praised

just a careless man, hopeful got your understanding when we met bugs

1 Like

Dare we ask for a new build for Pico2 with latest MMBasic and the keyboard fix all in one ?. Your last build is downloaded and Pico2 sat here waiting for my PicoCalc to arrive in a few weeks max :smiling_face_with_sunglasses:(hopefully)…

keyboard is separate independent thing/device (not related nor to pico 1/2, nor to basic), you can update it any time

1 Like

Is it not possible using the i2c commands in PicoMite? Details are in Appendix B of the manual. I’m not sure how those commands might be used to configure it. But it looks like it might be possible, if the correct pin(s) were specified, the speed was set, etc.

The keyboard shortcut that blinks the LED is useful. :slight_smile:

1 Like