[Moto G Android Development] matmutant:
Moto G LEDs Custom Controls

Playing With Notification LED

​

Original source <<< make sure you read the blog article before commenting ....

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 G (tested on XT1032)

Rooted

SU rights granted

adb if you want to monitor all this from a computer

#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 :

[none] bkl-trigger usb-online flash0_trigger torch_trigger mmc0 battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid bms-online

easy to change them using :

echo battery-charging >/sys/class/leds/charging/trigger

The same is available in /sys/class/leds/white/trigger, and /sys/class/leds/white/brightness allows to dim the LED, though :

During test i was able to show that using /sys/class/leds/charging/trigger overrides any other trigger (if a notification comes, then it won't change the pattern) After extended test, it turned out that MotoG also have two LEDs

[*]Though using /sys/class/leds/white/brightness allows to use 0~255 values to dimm the LED, and /sys/class/leds/white/trigger works; it is overridden by any incoming notification that set brightness back to 0.

edit : Current knowledg is :

/sys/class/leds/charging/trigger → first LED, can be set to on/blinking while charging, although at full brightness.

/sys/class/leds/white/trigger → second LED, can be dimmed, but the LED turns back off when a notification comes in.

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

What we need is to find a way to dim the "first" LED

______________________________​

[YOUTUBE]hYmxhQfwPT8[/YOUTUBE]​

Set at boot

:

WARNING : if you fail this, you may screw up your device ... (keep a backup somewhere)

Create a blank file and name it like 99charging_LED-blink

paste the following in that file :

#!/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

mount /etc/init.d as RW

Paste 99charging_LED-blink there

set permissions as -RWXR-XR-X

Open terminal emulator, and type :

su
sh /etc/init.d/99charging_LED-blink

Plug it to charger, it should start blinking ... if not, make sure everything is correctly set

Reboot

Enjoy!

______________________________​

The above has only been tested on CM11

Here is the LED related Thread for MotoE

XDA:DevDB Information

Moto G notification LEDs Custom Controls, Tool/Utility for the Moto G

Contributors

matmutant

Version Information

Status: Testing

Created 2014-11-24

Last Updated 2014-12-15