[LED][DEV] Moto E LED Custom Controls

matmutant

Senior Member
Mar 17, 2011
3,379
4,741
0
~/
andrux-and-me.blogspot.com
Playing With Notification LED
Original source (for MotoG) <<< make sure you read the blog article before commenting ....
dedicated Blog article for MotoE

It's always cool to know at a glance that your device is charging without the need of lighting the screen, here is how:

Requirements :
  • Moto E (tested on XT1022)
  • Rooted
  • SU rights granted
  • adb if you want to monitor all this from a computer

Code:
#include <std_disclaimer.h>
/*
* Your warranty is now void.
*
* I am not responsible for bricked devices, dead SD cards, BURNT LEDs,
* thermonuclear war, or you getting fired because the alarm app failed.
* YOU are choosing to make these modifications, and if
* you point the finger at me for messing up your device, I will laugh at you.
*/
in /sys/class/leds/charging/trigger we have these triggers available :
Code:
[none] bkl-trigger usb-online mmc0 mmc1 battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid bms-online
easy to change them using :
Code:
echo battery-charging >/sys/class/leds/charging/trigger
needs to set any value !=0 for brightness (LED is either ON or OFF on MotoE):
Code:
echo 1 >/sys/class/leds/charging/trigger
Moto E (is quite different than Moto G MotoG has two LEDs too, they are simply impossible to see):
If you pay attention, you can se that Moto E has Two little white LEDs soldered under the LED hole, the first one (left) is ruled by /sys/class/leds/charging and the second one (less bright, ont the right) is ruled by the /sys/class/leds/white.

/sys/class/leds/white/trigger, and /sys/class/leds/white/brightness configure the right LED and these settings are overridden has soon as a notification comes.

/sys/class/leds/charging/trigger and /sys/class/charging/brightness configure the left LED (the brighter one) and these settings are not overridden by notifications AND both can work toghether:
You can see the left one kept ON while charging (using battery-charging trigger) and the right one Blinking with an incoming notification.


It is time for the community to help, and we will find out a way to correctly dim the LEDs if possible.

For now, the best way is to set left LED (/sys/class/leds/charging/) for charging using dedicated trigger and keeping the right one to none and get both working together this way.

______________________________​

Set at boot:
WARNING : if you fail this, you may screw up your device ... (keep a backup somewhere)
  1. Create a blank file and name it like 99charging_LED-blink
  2. paste the following in that file :
    Code:
    #!/system/bin/sh
    # enabling charging LED blinking while charging
    echo "battery-charging-blink-full-solid" >/sys/class/leds/charging/trigger
    echo "1" >/sys/class/leds/charging/brightness
  3. mount /etc/init.d as RW
  4. Paste 99charging_LED-blink there
  5. set permissions as -RWXR-XR-X
  6. Open terminal emulator, and type :
    Code:
    su
    sh /etc/init.d/99charging_LED-blink
    Plug it to charger, it should start blinking ... if not, make sure everything is correctly set
  7. Reboot
  8. Enjoy!

______________________________​


For whose who asked, here is the proof of the 2 LEDs and their White-color :
http://forum.xda-developers.com/showpost.php?p=57039807&postcount=7


Feel free to test further and report your discoveries!
The above has been tested on stock rooted ROM, and reported to work on CM11-m12, both on XT1022.

Here is the LED related Thread for MotoG

XDA:DevDB Information
[LED][DEV] Moto E LED Custom Controls, Tool/Utility for the Moto E

Contributors
matmutant

Version Information
Status: Testing

Created 2014-11-24
Last Updated 2014-12-15
 
Last edited:

AshuGite

Senior Member
Oct 6, 2012
334
172
73
Off the Edge!!!
tried this in trickster mod led control... but since the left one is so bright it overrides the indication of the right..i.e the change in the blinking intensity is not visible until observed closely...
 

matmutant

Senior Member
Mar 17, 2011
3,379
4,741
0
~/
andrux-and-me.blogspot.com
tried this in trickster mod led control... but since the left one is so bright it overrides the indication of the right..i.e the change in the blinking intensity is not visible until observed closely...
In fact, you should use the following :
Code:
echo battery-charging-blink-full-solid >/sys/class/leds/charging/trigger
This way the brighter will blink during charge, so the notification LED will be visible too (that's not the same blink pattern so it gives an irregular blink feeling)

Of course, i have no idea why there are 2 LEDs, and if lighting the brighter one will burn it or not : i'm going to add a disclaimer to OP since this mod has potential consequences on Hardware.

Thank you for your report, may i ask you your device and ROM?
 

AshuGite

Senior Member
Oct 6, 2012
334
172
73
Off the Edge!!!
In fact, you should use the following :
Code:
echo battery-charging-blink-full-solid >/sys/class/leds/charging/trigger
This way the brighter will blink during charge, so the notification LED will be visible too (that's not the same blink pattern so it gives an irregular blink feeling)

Of course, i have no idea why there are 2 LEDs, and if lighting the brighter one will burn it or not : i'm going to add a disclaimer to OP since this mod has potential consequences on Hardware.

Thank you for your report, may i ask you your device and ROM?

same results on cm11 m12 and stock 4.4.4 in XT1022
 
  • Like
Reactions: matmutant

matmutant

Senior Member
Mar 17, 2011
3,379
4,741
0
~/
andrux-and-me.blogspot.com
Is this working?
Because i have planned to make app for this.
Sure it works :)

Two steps are needed to set up each LEDs :

The Brighter One:
Code:
echo battery-charging-blink-full-solid >/sys/class/leds/charging/trigger
Code:
echo 1 >/sys/class/leds/charging/brightness
The 'notification' One (better keep it to trigger=none, so it will keep its role of notification LED), but if you wanna play with it:
Code:
echo battery-charging-blink-full-solid >/sys/class/leds/white/trigger
Code:
echo 1 >/sys/class/leds/white/brightness
Contrary to MotoG, i couldn't dim this LED by setting 0~255 for brightness :mad:

There might be a way to trigger flash LED when getting notification, but this is not for Moto E either :eek:


if you make an app for this we could share this thread as co-contributors and in-depth study these new possibilities :cool:
 
  • Like
Reactions: saintmonte

matmutant

Senior Member
Mar 17, 2011
3,379
4,741
0
~/
andrux-and-me.blogspot.com
  • Like
Reactions: nisu4717

matmutant

Senior Member
Mar 17, 2011
3,379
4,741
0
~/
andrux-and-me.blogspot.com
Just because having this feature working at boot is soooo cool xD

Set at boot:
WARNING : if you fail this, you may screw up your device ... (keep a backup somewhere)
  1. Create a blank file and name it like 99charging_LED-blink
  2. paste the following in that file :
    Code:
    #!/system/bin/sh
    # enabling charging LED blinking while charging
    echo battery-charging-blink-full-solid >/sys/class/leds/charging/trigger
    echo 1 >/sys/class/leds/charging/brightness
  3. mount /etc/init.d as RW
  4. Paste 99charging_LED-blink there
  5. set permissions as -RWXR-XR-X
  6. Open terminal emulator, and type :
    Code:
    su
    sh /etc/init.d/99charging_LED-blink
    Plug it to charger, it should start blinking ... if not, make sure everything is correctly set
  7. Reboot
  8. Enjoy!
 

AshuGite

Senior Member
Oct 6, 2012
334
172
73
Off the Edge!!!
Set at boot:
WARNING : if you fail this, you may screw up your device ... (keep a backup somewhere)
  1. Create a blank file and name it like 99charging_LED-blink
  2. paste the following in that file :
    Code:
    #!/system/bin/sh
    # enabling charging LED blinking while charging
    echo battery-charging-blink-full-solid >/sys/class/leds/charging/trigger
    echo 1 >/sys/class/leds/charging/brightness
  3. mount /etc/init.d as RW
  4. Paste 99charging_LED-blink there
  5. set permissions as -RWXR-XR-X
  6. Open terminal emulator, and type :
    Code:
    su
    sh /etc/init.d/99charging_LED-blink
    Plug it to charger, it should start blinking ... if not, make sure everything is correctly set
  7. Reboot
  8. Enjoy!
i already created a script for myself but unable to figure out how to control blinking pulse...
 

matmutant

Senior Member
Mar 17, 2011
3,379
4,741
0
~/
andrux-and-me.blogspot.com
i already created a script for myself but unable to figure out how to control blinking pulse...
The blinking pulse is Hardcoded, that means end-user cannot modify it, though some work in the light Hal should both give hability to dim the LED and control its pulse frequency (no idea if it will really be userspace configurable or not then)
@dhacker29 had done something related for MotoX a while ago :
http://review.cyanogenmod.org/#/c/57550/

However, that's not part of my skill range :cyclops:
 

AshuGite

Senior Member
Oct 6, 2012
334
172
73
Off the Edge!!!
The blinking pulse is Hardcoded, that means end-user cannot modify it, though some work in the light Hal should both give hability to dim the LED and control its pulse frequency (no idea if it will really be userspace configurable or not then)

@dhacker29 had done something related for MotoX a while ago :
http://review.cyanogenmod.org/#/c/57550/

However, that's not part of my skill range :cyclops:
in cm11 we have the option to control the pulse frequency..