maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   [Announce] bnf - nifty little tool, allowing to have battery info at glance (https://talk.maemo.org/showthread.php?t=84452)

Estel 2012-05-24 00:54

[Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Current version: 1.2
---

bnf 1.2 was uploaded to extras-devel. It is minor release, incorporating changes from tar-only 1.1 into repos version (tar link removed from attachment) + small fix for sudo. Changelog:
  • Fixed typo in sudoers file (bnf.sh was present, instead of bnf)
  • Back in the repos, ad they're working again
---

bnf 1.1 was just released. Repositories and autobuilder are not working reliably ATM, so extras-* release will arrive if when it's ever fixed. For now, update from 1.0 is available as attachment to this post. To install, just untar it to /usr/sbin (overwriting old file).Changelog:
  • Uses either bq27x00_battery module, or i2cget method, transparently deciding which one is applicable.
  • New value - "Average Time Remaining", which shows remaining time, calculated from averaged power usage since last complete charging.
  • Minor code cleanup + more things commented for easy code understanding, even for sh beginners.
---

bnf 1.0 was just uploaded to extras-devel. Changelog:
  • Initial release.

bnf is minimalistic, simple tool that display most important informations about battery and charging chip status (gathered via bq27x00_battery module, or i2cget), as notification pop-up message. It process values that need calculating and display them in human-readable format, detect state (charging via USB, wall charger, or discharging) and formatting visible info accordingly.

It's main advantage is, that it displays info from last 5 seconds without influencing output by itself - it's even possible to measure such small things as 3 mA total power usage in echo > sys/power/mem state (via calling it as first thing upon wakeup).

bnf can be called via desktop icon (provided by package), terminal:
Code:

sudo bnf
...or things like shortcutd. Last one is extremely useful, as with bnf, it allows to check power usage, while inside full-screen programs (bnf can be called via camera button half-press), without connecting via ssh or running anything in background.

bnf works out-of-the box, and doesn't require any configuration.

http://imageshack.us/scaled/landing/407/bnf11.png

bnf is licensed under terms of GPL (latest revision). It is provided as-is, without any warranty whatsoever.
---

Credits:

Thanks to shadowjk for method of gathering data via i2cget. I wouldn't be even close to starting it without Your state-of-art bq27200.sh script.
Thanks to merlin1991 and X-Fade, for teaching me about debhelper requirements.
---

FAQ:
---

Q: Nice tool, but I would like it to also display <xyz>...
A: Open /usr/sbin/bnf with any text editor of Your choice and modify it - it's quite easy, in fact, everything is documented to (almost) single command, so adjusting it to own needs should be trivial. This makes bnf great tool for learning few basic things about shell scripting for N900.

Q: How to calibrate battery measurements?
A: See:
http://talk.maemo.org/showpost.php?p...&postcount=846
Instructions are long, but process itself is very straightforward, at least, when You get used to it. I've written it as verbosely as I can, to allow everyone understand what is happening - otherwise, it would be 3-4 liner.
---

First post will be updated when appropriate (with notes left as post, inside this thread).

/Estel

Estel 2012-05-24 01:14

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
I've updated description and added a picture.

/Estel

nkirk 2012-05-24 07:39

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Being a fan of your bat capacity guide + script, i always thought why didnt you build something like this earlier to make it more mass-market friendly so most others could benifit from it. good work estel

/nkirk.

vi_ 2012-05-24 08:30

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Another release so soon Estel? Get in my son!

reinob 2012-05-24 11:21

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
@Estel,

Thanks for the script. I've tried it, and I get:
SoC: 70%
Charge: 1384 mAh
Full Charge: 1969 mAh

My battery is however the stock one, so the full charge is about 1300mAh (1269 according to battery-eye) and current charge should be around 584mAh (again, according to battery-eye).

BatteryGraph "confirms" that the charge is 584mAh (46%).

Note that bnf says, in my case, that "Calibration needed: 1" (and VDQ: 0, no idea what that is).

I know that the whole battery-thing is a mess, and I guess I do need to calibrate the battery measurements, but I just wanted to indicate my results in case you might want to add a warning on the first post..

Add.: I just read through http://talk.maemo.org/showpost.php?p...&postcount=846 again (it's an amazing read :), so I'll give that a shot and see if I can calibrate the measurement :)

Estel 2012-05-24 11:37

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
@nkirk

Thanks - it wasn't released earlier, because I've lacked skills to put it into repos properly ;)

@vi_
Fortunately, releasing this one was a no-brainer, after ereswap that took ~20 hours of constant effort (*after* having main reswapping part ready) to write missing parts and upload this bugger to repos ;)

I also have something "in-middle" to release - thing less complicated than ereswap, but requiring some actual work (unlike bnf) before release - so expect 3th one soon, but it will be targeted at absolutely niche "market" (users of optical disc drives via hostmode).

/Estel

// Edit

@reinob
Thansk a lot for trying it :) I see You've already went through calibration guide, so you probably know already what VDQ is (Valid discharge quality). Just don't worry if You won't get accurate result after first calibration - drop from 1900 to 1200-something will, probably, require few calibration "steps".

also, keep in mind, that both batteryeye and batterygraph doesn't give "real" results - even if You would have 3000 mAh battery, it would say about "Stock" capacity - it's taking data from same source as BME, so capacity is "red" from resistor value between BMI (3th battery pin) and mass - whatever manufacturer put there, "code" the readings - and State of Charge is calculated via voltage.

After proper calibration, bnf will should you absolutely 100% accurate State of Charge - percentage shown is CSOC (Compensated State of Charge), so it even take into account current temperature of battery (which affects capacity).

/Estel

sixwheeledbeast 2012-05-24 20:53

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Thought I'd mention something I found after installing (or not) bnf.
Downloaded via HAM, accidently tapped the fuzzy area on ic2tool execption warning.
bnf "failed to install".
On checking HAM again it wasn't in the repo's.

Turn's out it's installed without ic2tools and when run the desktop goes blank and CPU hits 100%. Only way to stop it is pressing power key.

trlopes1974 2012-05-24 22:27

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
1 Attachment(s)
Attachment 26555

niceeeee.... I guess it needs calibration

Estel 2012-05-25 17:40

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Well, "Calibration needed: 1" means something ;)

BTW, even having "Calibration needed: 0" doesn't mean You don't need calibration, if You've changed battery recently or so. N900's hardware doesn't have any way to fingerprint battery, so if You switch from standard BL-5J to, lets say, dual-scud, You still need to calibrate before seeing Your 3000 mAh.

Generally, "Calibration needed" is derived form amount of cycles since last calibration. If chip was reset, calibration is "never" so induct "Calibration needed".

/Estel

Jigzy 2012-05-25 18:59

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Love the app! not sure if others would be interested, but is their a possibilty of having a widget displaying all the info?

Jordi 2012-05-25 19:13

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Nice tool. Plans to have this for the N9? (errm)

Estel 2012-05-25 19:23

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
@Jigzy
Probably perfectly doable for everyone, via QueenBeeconWidget. although, as it's reading data via i2cget, it couldn't update itself constantly - something like 1 auto update per minute (+ on touch) should be ok.

@Jordi
I have no idea, as I don't own N9(50), so NFC if something like ic2tool exists there, what type of charging chip it use, how to handle notifications (are there any?) etc, etc.

So, it's definitely a task for someone owning devices in question, already.

/Estel

saponga 2012-05-25 19:36

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Quote:

Originally Posted by Jigzy (Post 1212503)
Love the app! not sure if others would be interested, but is their a possibilty of having a widget displaying all the info?

I don't think its a good idea... Actually, i would like to know if i could uninstall advanced power monitor and save some juice by stopping one more daemon. Does will bnf works propperly if i do that ? BTW, i just did tried the callibration as per Estel's post but my phone shuttdown @3235 mV w/o EDV1 turn to 1. It's charging now but i'm wondering if the callibration was sucessful.
Thanks for the tool Estel.
Edit: Just check that out and "callibration needed" stills 1. But SoC is pretty closer to the power monitor value than before calibration. Should i try recallibrate it ?

Estel 2012-05-25 22:31

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
bnf doesn't rely on APM in any way - you can safely uninstall it. Although it's nice piece of code, I must admit, that I've also uninstalled APM few months ago - bnf suits my need for detailed info, and standard battery indicator is OK for a "glance" battery status. In my case, it was rather about saving memory, instead of CPU cycles.

As for shutting down - just stop bme, while attempting to calibrate. Then, after EDV=1 and VDQ=0, remember to charge device for a while (via charge.sh script, as per my instructions), before turning bme again - or, it will shutdown device due to voltage lower than it's threshold.

/Estel

sixwheeledbeast 2012-05-26 08:36

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Quote:

Originally Posted by sixwheeledbeast (Post 1212127)
Thought I'd mention something I found after installing (or not) bnf.
Downloaded via HAM, accidently tapped the fuzzy area on ic2tool execption warning.
bnf "failed to install".
On checking HAM again it wasn't in the repo's.

Turn's out it's installed without ic2tools and when run the desktop goes blank and CPU hits 100%. Only way to stop it is pressing power key.

Ok, I think I got more problems now.
I couldn't uninstall the app from HAM.
Had to apt-get install bnf, apt-get remove bnf.
Then installed via HAM again.

Now with a fresh install bnf still doesn't display anything.

sudo bnf works ok after a reboot but desktop and app lancher icons do nothing.

Is this correct?

Estel 2012-05-26 15:45

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Of course not. Could You join IRc #maemo, and "ping Estel_"? We would check, what is going on.

/Estel

sixwheeledbeast 2012-05-26 18:38

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Quote:

Originally Posted by sixwheeledbeast (Post 1212747)
sudo bnf works ok after a reboot but desktop and app lancher icons do nothing.

Resolved thanks to Estel on IRC.
QCPUFREQ was set to load bq27x00 module.
After unchecking option and a reboot. bnf works perfectly.

peterleinchen 2012-05-26 21:17

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
2 Attachment(s)
Hey Estel,
just stumbled accidentally over your second package. :)
Nice. Will surely help some people.
(When will see your next deb with battery hot swap via click on widget?)

Seems like something (a script and a desktop file) needs to be deb packaged to get some more deserved attention! ?

Since I am using it since aeons, I just can not remember where/how I got it, via thread or directly from you?
Whatever, I had modified (rearranged, sorted) the output slightly, so it matches my "subjective aesthetic feeling/logic" more :)
Here are my screenies:

Attachment 26584
Attachment 26585

Estel 2012-05-26 23:59

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Quote:

Originally Posted by peterleinchen (Post 1213012)
Seems like something (a script and a desktop file) needs to be deb packaged to get some more deserved attention! ?

...and a sudoers file :D

Seriously though, I always thought that place for such - even simplest - things is in repos, instead in some random (or even extra valuable) thread on TMO, which many people can miss. I'm glad You're enjoying it too :)

Repos version of script benefit from some code cleanup (minor things) - probably, You can re-patch them to Your modified version without much problems :)

/Estel

tingu699 2012-05-28 11:45

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Quote:

Originally Posted by sixwheeledbeast (Post 1212977)
Resolved thanks to Estel on IRC.
QCPUFREQ was set to load bq27x00 module.
After unchecking option and a reboot. bnf works perfectly.

hi guys. i made the same mistake. now i have the same empty screen problem like sixwheelebeast.
i'm a total noob and dont uderstand whwat is meant by "QCPUFREQ was set to load bq27x00 module.
After unchecking option and a reboot. bnf works perfectly"

please can someone help me how to do this?
thank you

sixwheeledbeast 2012-05-28 17:33

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Quote:

Originally Posted by tingu699 (Post 1213760)
please can someone help me how to do this?
thank you

PM Sent.......

branja 2012-06-19 16:21

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
It's a great app!

but...How to calibrate it?

I can only make it work via ``sudo gainroot bnf´´...
it says that the full charge is at 795 mAh & it doesn't matter if I use BME or some other battery.

p.s. It olso displays that calibration is 0 & vdq is 0.

sixwheeledbeast 2012-06-19 17:41

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Here Was covered further up, I agree it should be in a wiki or OP.

peterleinchen 2012-06-19 18:46

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
This is THE wiki ;)
But maybe it should be at least in first post. Estel?

Estel 2012-06-23 20:55

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Good idea, adding :)

karlitos 2012-07-16 20:52

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Hello, I am still able starting the bnf only from the terminal after I switch to the root shell (sudo gainroot). If I start bnf from its application icon (menu, shortcut ...) only blank sscreen appears.
I tried to find a solution, I even blacklisted the bq27x00-battery modul, but still no luck. Can anyone help me with this issue please ?

peterleinchen 2012-07-16 21:13

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Looks like your desktop file is missing sudo rights.

Try
Code:

cat /usr/share/applications/hildon/bnf.desktop
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name=bnf
Type=Application
Exec=sudo /opt/scripts/bnf.sh
Icon=statusarea_battery_full100

and if you are missing the msudom. then edit via leafpad (or nano. vi. ...) and add that sudo. maybe will need sudser installed hor update sudoers file, if you know howj.

please have in mind. that i do have a personal installation of bnf, so maybe estel will know more ...

--edit
NOW I remember (as it happened again to me)!
Sometimes the hildon-home hangs. Then you can not start any self-placed widgets/programs from desktop. This also hinders notifications for missed calls or SMS/mails. AND also the display of self made notfications like bnf uses. A restart will help out (there is also other workaround posted by me somewhere else in this forum ;)).

sifo 2012-07-16 21:20

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Here is the bnf.desktop without any edit

Code:


[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name=bnf
Type=Application
Exec=sudo bnf
Icon=statusarea_battery_full100
X-App-Loading-Image=none


karlitos 2012-07-17 21:06

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Thank you very much. Had to change the exec command in the .desktop file from bnf to /usr/sbin/bnf and now it works just fine.

peterleinchen 2012-07-17 21:18

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Oops. Estel.
I think then you have to change a bit here (assuming karlitos installed from repo).
Sudoing an exe without full path works only if location is in path. /usr/sbin is per default not in path for user (but of course for root).

foobar 2012-07-17 22:00

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
I can confirm that the .desktop file as installed from the repos lacks the full path to bnf.

Estel 2012-07-20 12:13

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
It is not lacking anything - icons placed in standard directories where hildon expect them, doesn't need to be provided with full path.

Thanks for confirming, though :)

/Estel

karlitos 2012-07-20 13:31

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Hello, it is not about icons but about the path to the binary.

peterleinchen 2012-07-20 19:02

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Yes, it was not about icons (where full path is not only not needed, but must not be set, to my experience).

But I have to apologize, Estel.
Of course a sudo in front of command does not require full path!

But I had similar once and thought it was that (not having root rights); and it was late...

As I just greyed out my nonsense in former post, it was not fully nonsense ;j My script is in totally different location!

karlitos
can you run
sudo bnf
from terminal as user (not as root)?
Please open a new x-term and directly type
sudo bnf

If that starts the window or black screen, then give us output of
lsmod | grep bq27

sixwheeledbeast 2012-07-24 22:58

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
@Estel
Trying to calibrate my battery using your bqCapacity post.

Have you forgotten to mention ./i2cget needs chmod as well as bq27200.sh?

Estel 2012-07-28 02:47

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Good catch. I need to refine instructions anyway - i2cget is available from i2c-tool package for ages (in fact, was in time of writing initial tutorial...), so messing with placing i2cget manually isn't needed. bq27200.sh definitely needs chmod +x it.

Considering, that bq27200.sh is sitting in some random server for ages, I guess I will refine it a little, ask ShadowJK for permission and put it as part of bnf package - it will make things much easier.

/Estel

uros 2012-10-26 12:16

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Hi Estel

Any idea why sudo bnf after reflashing my devica and clean install CSSU fthumb sudo bnf granted me with

Error: Could not set address to 0x55: Device or resource busy
/usr/sbin/bnf: line 44: arithmetic syntax error

tnx

Estel 2012-10-26 18:51

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Looks like something is occupying i2cbus - I bet, that bq27x00_battery module is loaded at startup. check your blacklist and enforced modules list (refer to kernel-power thread, it was discussed there, "somewhere" - I don't remember locations now, sadly :( ).

// edit

For quick confirm/deny, try (as root) modprobe -r bq27x00_battery - if it accepts command without errors, and then, bnf starts to work, you can be sure it is it.

peterleinchen 2012-10-26 19:21

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Yep, exactly that is my assumption/explanation also :)

@Estel
Maybe you meant that from here on and ff?
Can not remember in kernel thread, but maybe also there...


--edit
and I remembered why bnf called from menu icon may sometimes not display any output, but shows black screen

Estel 2012-10-26 20:01

Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
 
Yea :)

BTW, don't get too 1337 with blacklisting bq27x00_battery - do it using a way, that you will be able to revert easily. Current progress on bme replacement (via re-written bq2415_battery and bq27x00_battery modules) mean, that after some time, you *will* want to use "reborn" bq27x00_battery, as module for exporting things for userland bme replacement bits.

After all, talking directly to i2c is always - more or less "dirty hack", and with dawn of proper BME replacement, it's going to get obsolete. While it will - for sure - mean availability of nicely integrated, GUI battery meters, it doesn't mean BNF will go away, though - for those hardy pack of people, that still like it, I will for sure release version that uses bq27x00_battery instead of i2cget, as soon as BME replacement using kernel module will be available.

/Estel


All times are GMT. The time now is 04:17.

vBulletin® Version 3.8.8