maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   [Request] Battery charge status on status LED (https://talk.maemo.org/showthread.php?t=63431)

TiagoTiago 2010-10-06 03:31

[Request] Battery charge status on status LED
 
I would like somthing to make it so i don't have to light up the screen to know how much battery charge is left.


The way i picture it is, instead of the pre-generated pattern for the status LED for the idle state (when the screen is locked and the N900 isn't plugged on the charger), the LED would blink first in a reference pattern (so you know what full would look like) and then in a pattern representing the current battery charge (or if that would use too much charge, check the battery charge every N minutes and update the pattern when it has changed since the previous measurement), at aproximatly the same rate as the default pattern (i mean, about as many repetitions per minute)

kaos_king 2010-10-06 13:12

Re: [Request] Battery charge status on status LED
 
I too would like this. There are many possible alternatives to what LED patterns to use, so being able to choose would be fantastic.

I have no idea how to go about this though...

bakuur 2010-10-06 13:17

Re: [Request] Battery charge status on status LED
 
what about a blinking LED that blinks lets say every 15 sec
and the intensity of the LED or how strong it emits light is the indicator

or

a green LED when from 100% to 70% and yellow from 70% to 20% then red when less
that would be much more accurate

TiagoTiago 2010-10-06 18:28

Re: [Request] Battery charge status on status LED
 
The LED is capable of 256 levels for each color component, you could for example have it change it's hue going across the rainbow, purple for full charge, then gradually turning blue, then gradually cyan, then gradually green, then gradually yellow, then gradually orange and then finally red; or really any color gradient (could for example go from white to yellow to orange to red to dark red to black, like a piece of metal made extremely hot and then cooling down in the dark)

smartypants 2010-10-06 19:08

Re: [Request] Battery charge status on status LED
 
http://en.wikipedia.org/wiki/Roy_G._Biv

smartypants 2010-10-06 19:09

Re: [Request] Battery charge status on status LED
 
it's a nice feature to know how much battery is left even from a long distance and in the dark :D

smartypants 2010-10-06 19:10

Re: [Request] Battery charge status on status LED
 
just do it

TiagoTiago 2010-10-06 19:11

Re: [Request] Battery charge status on status LED
 
Quote:

Originally Posted by smartypants (Post 834978)

lol, sorry i didn't research the colors of the rainbow before posting, apparently it was necessary :rolleyes:

lemmyslender 2010-10-06 19:23

Re: [Request] Battery charge status on status LED
 
If it were me, I'd tie it into the 8 "bars" information that is already there. Allow the user to change how frequently it update N minutes as suggested.

I would set it up like so:
3 green blinks = 8 bars
2 green blinks = 7 bars
1 green blink = 6 bars
3 yellow blinks = 5 bars
2 yellow blinks = 4 bars
1 yellow blink = 3 bars
3 red blinks = 2 bars
2 red blinks = 1 bar
1 red blink = 0 bar

It would be easy to quickly tell the approximate charge level at a glance. Refresh the pattern every 10 minutes or so (pick a number to suit yourself), update to a predefined pattern, repeat.

Only problem is any notifications would overide this, unless the priority is set high enough.

ossipena 2010-10-06 19:30

Re: [Request] Battery charge status on status LED
 
this probably is next to impossible to implement. that probably requires killing MCE led blinking completely because of conflict between MCE and requested app trying to drive the same controller

TiagoTiago 2010-10-06 19:30

Re: [Request] Battery charge status on status LED
 
just plain color blinks could get confused with regular LED patterns, somthing more complex than that would be needed, perhaps a prefix pattern that would always play before the actual charge status pattern would help.

TiagoTiago 2010-10-06 19:33

Re: [Request] Battery charge status on status LED
 
Is that why the LED pattern editor has such a big difficulty to test a pattern? How does HealthCheck's LED test does it?

woody14619 2010-10-06 19:34

Re: [Request] Battery charge status on status LED
 
The problem with this is that the LED use does actually eat battery. It may not seem like much, but when you're blinking it every 30 seconds all day, it adds up.

A better idea may be to trigger on another indicator (like say camera button) when the screen is off, and have it blink things to you then. Or, just have it use espeak to say the time and % battery left maybe? A lot easier than learning morris code to tell the time and battery level. ;)

TiagoTiago 2010-10-06 19:37

Re: [Request] Battery charge status on status LED
 
Just keep the average usage of the LED to somthing similar to the default white flashing

woody14619 2010-10-06 19:44

Re: [Request] Battery charge status on status LED
 
Default white flashing? Does yours flash white at times? Mine never flashes unless something is going on, like a incoming SMS. The only time I see white is when the device is powering up or down...

TiagoTiago 2010-10-06 19:50

Re: [Request] Battery charge status on status LED
 
With the screen locked and no notifications etc waiting, it flashes faint white every once in a while

lemmyslender 2010-10-06 23:21

Re: [Request] Battery charge status on status LED
 
OK, messing around a little bit; this is probably one of the worst ways to do this, but:

I wrote a little script that will:
1) grep the current bar level, and compare it to a previously stored level
2) if the levels are the same (ie 6 bars) it will exit
3) if the levels are different it will
4a) overwrite the current mce.ini file with a new mce.ini file based on the bar level
4b) restart mce
4c) set the stored bar value to the current value
5) exit
*settings,notification light, device on needs to be checked.

Obviously this needs to be run as root. There are a variety of ways to have the script run automatically at a predetermined interval. If the level hasn't changed nothing is written or restarted.

Based on the wiki, mce shouldn't be restarted too often (several times in less than 2 minutes) or there may be problems restarting it. If the battery last for 4 hours at 100% cpu, and there are 8 bar levels, there should be about 30 minutes between changes (if I did my math right). So from that perspective it shouldn't cause any issues.

I suppose it could do very bad things if something prevented if from completely writing the file, or the file was corrupted.

I'll play with it a little more, if it seems to work and there is interest, I could post it.

hawaii 2010-10-07 01:15

Re: [Request] Battery charge status on status LED
 
Anytime you restart MCE, you'll lose "stacked" or in-progress notifications. This is not conducive at all.

There is no sane way to do this with MCE.

TiagoTiago 2010-10-07 01:19

Re: [Request] Battery charge status on status LED
 
There gotta be a better way to control the status LED...

bakuur 2010-10-07 20:56

Re: [Request] Battery charge status on status LED
 
please post it if you can
ill work on it too
maybe i can help you abit ;)

blue_led 2010-10-07 21:10

Re: [Request] Battery charge status on status LED
 
1 Attachment(s)
i wrote a plain script * who drive the led ALL colors with color of the pulse function of time digits when charger is plugged
the idea is to keep led white and modify leds currents

* the script ( Pulsar ) is unfinished and work well until battery is fully charged when full white pattern is changed to full green.
an early variant of the script you can find here :
http://talk.maemo.org/showpost.php?p...4&postcount=33
actual script is more finished and obfuscated and i thought also at battery status indicator.
if i find time i will finish this script with an option of time , battery status or both.

Matan 2010-10-07 21:33

Re: [Request] Battery charge status on status LED
 
I added a method for preventing MCE from interfering with the leds, and it is available in power-kernel. This adds a dominant attribute called dbrightness to the leds such that if this attribute is set to non-negative, writes to regular brightness attributes are ignored, so MCE works as usual, it just has no affect.

Someone could implement the same for the engines, thus allowing for temporarily preventing MCE from controlling the leds.

lemmyslender 2010-10-08 11:52

Re: [Request] Battery charge status on status LED
 
Since it was requested, I'll post the script I used.
If you are unsure what it is doing or how to use it, please don't, it can screw up your mce.ini file which will definitely screw up your system, causing you to have to flash it, or possibly bricking your N900. It takes more than just copying the script and running it, additional steps are needed. If you can't figure them out, don't use it. Not responsible for any harm to your phone.

This is just a brute force method, very likely the worst way to do it. As noted earlier in the thread, it resets mce occasionally, which will clear any other notifications (missed call, im, email, sms, etc). Unless you are more concerned about the battery level than other notifications, I wouldn't use it.

I tested it for about 12 hours (1-2 bars, charging overnight, 8-7 bars in morning). It seems to work.

Again, probably the worst way to do this and it will cause you to miss other notifications.


Code:

#! /bin/bash

sudo gainroot
#set variables for current bar level and previous bar level
curbar=`lshal | grep battery.charge_level.current | awk '{print $3}'`
prevbar=`cat /home/user/.ledcharge/lastbar`
 
if [ $curbar -eq $prevbar ]; then
#exit without doing anything
echo `date | awk '{print $4}'`
exit
else
echo $curbar
#set pattern to current bar level
if [ $curbar -eq 8 ];then
cp /home/user/.ledcharge/mce.8.ini /etc/mce/mce.ini
fi
if [ $curbar -eq 7 ];then
cp /home/user/.ledcharge/mce.7.ini /etc/mce/mce.ini
fi
if [ $curbar -eq 6 ];then
cp /home/user/.ledcharge/mce.6.ini /etc/mce/mce.ini
fi
if [ $curbar -eq 5 ];then
cp /home/user/.ledcharge/mce.5.ini /etc/mce/mce.ini
fi
if [ $curbar -eq 4 ];then
cp /home/user/.ledcharge/mce.4.ini /etc/mce/mce.ini
fi
if [ $curbar -eq 3 ];then
cp /home/user/.ledcharge/mce.3.ini /etc/mce/mce.ini
fi
if [ $curbar -eq 2 ];then
cp /home/user/.ledcharge/mce.2.ini /etc/mce/mce.ini
fi
if [ $curbar -eq 1 ];then
cp /home/user/.ledcharge/mce.1.ini /etc/mce/mce.ini
fi
if [ $curbar -eq 0 ];then
cp /home/user/.ledcharge/mce.0.ini /etc/mce/mce.ini
fi

#remove and reset lastbar variable
rm /home/user/.ledcharge/lastbar
touch /home/user/.ledcharge/lastbar
echo $curbar >> /home/user/.ledcharge/lastbar

fi

#now restart mci
initctl stop mce
sleep 2
initctl start mce

exit


bakuur 2010-10-10 19:04

Re: [Request] Battery charge status on status LED
 
is it possible to add more profiles to the mce.ini

like over here
Code:

# Priority (0 - highest, 255 - lowest)
# Policy - 0 only play pattern when the display is off
#          1 play pattern even when the display is on
#          2 only play pattern when the display is off, including acting dead
#          3 play pattern even when the display is on, including acting dead
#          4 only play pattern if the display is off, or if in acting dead
#          5 always play pattern, even if vibrator disabled in profiles
# Timeout in seconds before pattern is disabled, 0 for infinite
# Repeat count, 0 for infinite
# AcceleratePeriod time in millisecond
# OnPeriod time in milliseconds
# BreakPeriod time in milliseconds
# OffPeriod time in milliseconds
# Speed from 1 to 255
PatternIncomingCall=1;3;0;0;30;970;0;1000;180
PatternIncomingMessage=4;3;2;1;30;360;0;100;180
PatternPowerKeyPress=5;5;1;1;0;16;0;16;128
PatternTouchscreen=11;3;0;1;23;0;15;50;255
PatternChatAndEmail=10;3;0;1;23;0;15;50;255

if you notice the first number is the priority so this can make the phone notification LED with higher priority over the battery level indicator

then if the profiles are added we can use the script in the post before to force these profiles to be loaded
thus our problems solved

im not sure about all this
its just pure assumptions so far
i just dont have a spare N900 to test with

but i promise to work with this for now hopefully we can make this come true!!


All times are GMT. The time now is 08:50.

vBulletin® Version 3.8.8