Moto G LEDs Custom Controls

Search This thread

matmutant

Senior Member
Mar 17, 2011
3,395
4,743
~/
andrux-and-me.blogspot.com
Moto G
Moto E
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

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.
*/

B3hsRyTCEAIBaT8.jpg
B3hsSTFCMAEpH1E.jpg


in /sys/class/leds/charging/trigger we have these triggers available :
Code:
[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 :
Code:
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

______________________________​


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!

______________________________​

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
 
Last edited:

josip-k

Senior Member
Feb 20, 2011
3,891
2,717
26
Jastrebarsko
Samsung Galaxy S20
ASUS ZenFone 8
It would be cool if we could change the colors,and i think it would be possible..


Edit: sorry,i haven't read the blog -.-
BUT! I know you from the mini xperia's forums,i was an X8 user. I still have the old x8,and i was thinking,maybie we could make a hardware modification and swap the leds from X8 to Moto G? I have an old broken x8 at home,and the screen is broken but i think the led works. I haven't dissasembled my Moto G yet and i don't know if the led is hard sealed to the Motherboard or Speaker or camera..
 
Last edited:
  • Like
Reactions: mdsaif92

matmutant

Senior Member
Mar 17, 2011
3,395
4,743
~/
andrux-and-me.blogspot.com
Moto G
Moto E
Why not setting this at boot?

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!
 

S0bes

Senior Member
Jan 1, 2012
870
969
@matmutant thanks for interesting discovery :)
Can we somehow do the next thing
when notification comes leds both are active but the brighter one starts blinking?
like when you do the following commands:
Code:
echo battery-charging-blink-full-solid >/sys/class/leds/charging/trigger | echo 255 >/sys/class/leds/white/brightness
 

matmutant

Senior Member
Mar 17, 2011
3,395
4,743
~/
andrux-and-me.blogspot.com
Moto G
Moto E
@matmutant thanks for interesting discovery :)
Can we somehow do the next thing
when notification comes leds both are active but the brighter one starts blinking?
like when you do the following commands:
Code:
echo battery-charging-blink-full-solid >/sys/class/leds/charging/trigger | echo 255 >/sys/class/leds/white/brightness
Not without modifying the HAL :cyclops: (same as for brightness)
or, maybe with a tasker routine that would echo when notification comes and then revert ... but it would have a huge footprint on performances :mad:
 
  • Like
Reactions: S0bes

gnhuy91

Senior Member
Mar 20, 2014
53
5
Thanks for sharing this! This thread not getting much love but i found it very interesting.
And btw, can we set any LED to on when the screen is turned on by wake gesture from custom kernel? I know it should be a kernel thing, though :/
 

Top Liked Posts

  • There are no posts matching your filters.
  • 35
    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

    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.
    */

    B3hsRyTCEAIBaT8.jpg
    B3hsSTFCMAEpH1E.jpg


    in /sys/class/leds/charging/trigger we have these triggers available :
    Code:
    [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 :
    Code:
    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

    ______________________________​


    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!

    ______________________________​

    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
    6
    Why not setting this at boot?

    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!
    3
    Latest discovery :
    Using "bkl-trigger" as */charging/trigger allows you to get the LED on as long as the screen ("bkl" stands for backlight)

    Code:
    echo bkl-trigger >/sys/class/leds/charging/trigger

    i understood this after reading that https://github.com/gokulnatha/GT-I9...tation/devicetree/bindings/leds/leds-qpnp.txt
    >_<
    3
    @matmutant where were you so far we were missing you soo much
    thanks for the mod

    I am always around here, though i don't post if un-needed, and i was out of idea regarding customizations :silly:
    3
    Totally useless, but still classy : you can make the screen blink using :

    Code:
    echo battery-charging-blink-full-solid >/sys/class/leds/lcd-backlight/trigger

    :silly::silly::silly: