-
Notifications
You must be signed in to change notification settings - Fork 38
reading battery status via i2c always reports 0 #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Compiling and flashing the current version of the master branch fixed the reported battery level for me |
Yep. Was fixed with 65bf0c6 |
I found that I also needed #22 to read the charging status, too |
#22 did not fix all but helped me to realized that current_bat_pcnt is not a good idea when I try to fix in 65bf0c6 I totally forgot the reg of REG_ID_BAT current battery percent can be stored in reg of REG_ID_BAT So I will remove current_bat_pcnt from code later and add bitSet(percent,7) to indicate charging status just like @wez said |
removed current_bat_pcnt now I've updated picocalc_helloworld ,added new battery info code with charging status I also find out that, when I press the battery into socket for the first time, there is a slight time that axp2101 chip will report battery percent to be zero ,that causes low_bat() to do PMU.shutdown(); So I add a low_bat_count to debounce to avoid |
I'm not sure if I'm doing something wrong here, but I can read keyboard data and change the backlight just fine, so my i2c stuff generally works.
I have this rust function to read the battery register; it sends
REG_ID_BAT
and then reads back 2 bytes:The data I get back is always
[REG_ID_BAT, 0]
, which corresponds to:PicoCalc/Code/picocalc_keyboard/picocalc_keyboard.ino
Lines 140 to 143 in 4c65694
but with
current_bat_pcnt
set to 0.That value always appears to be
0
for me; whether the batteries are installed, removed, charging or when the usb-c cable to the picocalc (not the pico) is attached to the computer or not.Am I reading the schematic correctly? I think the STM MCU
Serial1
is connected toUART1
(pins 8/9) on the pico, so I should be able to read the PMU debugging information by reading from that uart in my pico firmware? I capture and log that data, but I haven't seen anything get printed there so far.Should I be doing something differently to read the battery level?
The text was updated successfully, but these errors were encountered: