[MOD] Script to toggle the keylights (Part II)

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
In Part I, I showed you how to use Tasker and some scripts to make your button backlight flash for an incoming notification. One problem with that technique is that it requires a script to be run every time the lights are flashed. This resulted in a dramatic increase in battery drain since the phone was kept from going completely idle. I tried creating a script that runs perpetually and only flashes the lights when a setting is changed, but when the phone does go idle, it slows down or completely stops the script.

I decided to try a new approach to the lights. Instead of to flashing the lights, when a notification comes in, I would leave the lights permanently on until the screen is turned on again. This however required a modified kernel. The default action by all of the kernels is to turn off the key lights when the phone goes idle. Picasticks was kind enough to provide me with a modified version of his kernel that stopped the lights being turned off. With that in hand, I tested what happens when I leave the key lights on. It turns out that the LEDs consume very very very little energy. Over the course of a 20 hour test, my phone only lost 22% of its battery power. Until I can figure out a way to make the lights flash in an efficient way, or Picasticks can find a low level way to incorporate it into the kernel, this is the most efficient solution. You may think that flashing the lights has to be more efficient than leaving them on. If you wake the phone to do it, you are burning through a lot more juice than if you just keep the light on. Think of it the same way florescent lights work. There is a cost associated with turning it on. If you repeat the process of turning them on too often, you consume more juice than just leaving them on. In this case, waking the phone uses 25-60mA for a few seconds where as the LEDs consume less than 1mA. If you waked the phone every 10 seconds to flash the lights and the phone stayed out of idle for only one second, that would equal 25mA * 6 = 150mAs for the most conservative estimate of the amount of battery consumed in 1 min. If I leave the light on and use the most liberal estimate for battery consumption (1mA), then it would consume 60mAs, almost three times less. If we flash the lights every 3 seconds like I did in Part I, that would consume at least 500 mAs, over 8 times as much as leaving the lights on. If you still don't believe me, try both out and let me know how it goes.

Here is how to set this up to work on your phone with Tasker:
(If you already have did Part I, you can start on step 5)
  1. Install tasker
  2. Install sl4a
  3. Download the KeylightsNoFlash_v2.rar and extract it.
  4. Place sush into /system/bin and change the permissions to "rwxr-xr-x"
    Code:
    adb remount
    adb push sush /system/bin/
    adb shell chmod 755 /system/bin/sush
    or through terminal emulator:
    Code:
    mount -o remount,rw -t yaffs2 /system /system 
    cp /sdcard/sush /system/bin/sush
    chmod 755 /system/bin/sush
  5. Place userbackup.xml in /sdcard/tasker
  6. Place the six script files into /sdcard/sl4a/scripts
  7. Open tasker, hit the menu, profile data, restore
  8. Press apply to exit Tasker, and Go to Settings>Accessibility> Enable Accessibility for Tasker
  9. Place Picasticks modified kernel (picasticks-07-led1.zip) onto your micro SD card.
  10. Reboot into recovery.
  11. Use the flash zip feature to install the modified kernel.

This will turn on the button backlight LEDs if you get a missed call, text, GV message, Gtalk message, Groove IP missed call, Sipdroid, missed call, cSipSimple missed call, new email, or new Gmail. If you want other notifications to trigger the lights, in Tasker hit New -> Event -> UI -> Notification -> Owner Application -> and select the app who's notifications you want to trigger the lights. When the Task Selection Menu pops up, select Togglekeylights. There is a 14 second delay built into the light to allow the phone to go back to sleep before turning on the light for missed calls.

If you don't want to use Picastick's kernel, then ask your kernel dev to be as kind as Picasticks and create you a kernel that disables the the sleep feature of the button backlights.

Also, I did this:
http://forum.androidcentral.com/opt...ng-external-notification-light-optimus-v.html
I think I voided my warranty :D

With the led script, disabling the led with key presses, and finally adding an external spot for the led, you'll have a fully functional and dedicated notification led.

All credit goes to Picasticks for this one. Thank you!
 
Last edited:
  • Like
Reactions: JerryScript

JerryScript

Daydream Believer
Mar 8, 2011
2,055
1,559
0
Visit site
Thanks, as always, well thought out and explained.

Just wanted to point out to any Mythbuster viewers that this is not the same as turning your lights on and off with a switch, which Mythbusters proved did not effect power consumption to the point where leaving lights on was better. In this case, the switch itself is the CPU which has to use alot of power to turn the lights on or off, so in your face Mythbusters! ;)

I'm still working on the design for my lighting mod, looking at incorporating a pen-laser's lens to project an image on the ceiling, or I may just use a braid of fiber optics, trying to plan every detail before I crack her open.
 

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
Thanks, as always, well thought out and explained.

Just wanted to point out to any Mythbuster viewers that this is not the same as turning your lights on and off with a switch, which Mythbusters proved did not effect power consumption to the point where leaving lights on was better. In this case, the switch itself is the CPU which has to use alot of power to turn the lights on or off, so in your face Mythbusters! ;)

:)

I was this |-| close to talking about the mythbusters test because I knew someone would bring it up. Here is what they concluded:
It's best to turn off the bulb if you are leaving the room for more than:

Incandescent: 0.36 seconds
CFL: 0.015 seconds
Halogen: .51 seconds
LED: 1.28 seconds
Fluorescent: 23.3 seconds
Source

This is because of the start up power consumption which is analogous to our non-idle power consumption. So even they concluded that if the fluorescent lights are being turned on and off very rapidly, it would consume more power than leaving them on.

Now everyone's integrity is still intact. Crisis averted.


BTW, I can't wait to see your phone. You've hyped it up so much, I'll only accept something as cool or cooler than this: http://www.youtube.com/watch?v=VpwWac6ktKE
The bar has been set.
 
Last edited:

arhtard

Slacker
Jun 16, 2011
129
17
0
Visit site
:)

I was this |-| close to talking about the mythbusters test because I knew someone would bring it up. Here is what they concluded:

Source

This is because of the start up power consumption which is analogous to our non-idle power consumption. So even they concluded that if the fluorescent lights are being turned on and off very rapidly, it would consume more power than leaving them on.

Now everyone's integrity is still intact. Crisis averted.


BTW, I can't wait to see your phone. You've hyped it up so much, I'll only accept something as cool or cooler than this: YouTube - ‪Cell Phone Transformer‬‏
The bar has been set.
haha that video would make a cool boot screen
 

Forum statistics

Threads
943,172
Messages
6,917,630
Members
3,158,860
Latest member
dumpsterrentals38