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
Sorry moto g 2nd gen

I've no idea then, play around with white and rgb folders, i can't test it by myself, don't play to much with the torch related folders and the torch related triggers, it can crash the device.

Playing with other folders/trigger shouldn't harm your device though, if anything goes wrong, then simply reboot to erase the modifications :)

Better do anything from adb shell, (playing with lcd-backlight will turn off screen, and only adb or force reboot can revert easily :silly: )
 

vikasb32

Inactive Recognized Themer
May 9, 2011
2,057
1,999
Hardwar
OnePlus 6
I little confuse hope u help me I read all post but don't now how to activate a trigger I want to my led show when I connect any USB.

Edit I just enable led when I connected to charger.
 
Last edited:

matmutant

Senior Member
Mar 17, 2011
3,395
4,743
~/
andrux-and-me.blogspot.com
Moto G
Moto E
I little confuse hope u help me I read all post but don't now how to activate a trigger I want to my led show when I connect any USB.

Edit I just enable led when I connected to charger.

for moto G (Flacon) we have the following triggers :
  • [none] (default, LED does nothing)
  • blk-trigger (used by ./wled:backlight/trigger)
  • usb-online (lights up when USB connected)
  • flash0_trigger (used by ./led:flash_0/trigger)
  • torch_trigger (used by ./led:flash_torch/trigger)
  • mmc0 (I/O triggered, lights when mmc0 is in use)
  • battery-charging-or-full (full time ON LED when charging or charged)
  • battery-charging (full time ON LED when charging)
  • battery-full (full time ON LED when charged)
  • battery-charging-blink-full-solid (blinks until charged)

To know which triggers are available on Moto G 2014 (Titan) simply do :
Code:
adb shell
su
Code:
cat /sys/class/leds/[name_of_the_LED]/trigger
Share them here, there might be interesting things there :cowboy:
Then choose the trigger you want to try by the following :
Code:
echo [name_of_the_trigger] >/sys/class/leds/[name_of_the_LED/trigger
Don't forget to set brightness to 255 (or any other value depending on the brightness wanted if it is a dimmable LED)
Code:
echo 255 >/sys/class/leds/[name_of_the_LED/]/brightness

Hope it helps :)
 
  • Like
Reactions: Snowers96

ReOmbra

Senior Member
Jan 9, 2014
321
215
I thank you so much for this useful feature..
In the light of the new discoveries i will post a past thread where the topic was the color of the led.. Maybe the consideration are the same of the past.. But hope is the last to die :D

http://xdaforums.com/showthread.php?t=2579588
Sent from my XT1032 using XDA Free mobile app
 

matmutant

Senior Member
Mar 17, 2011
3,395
4,743
~/
andrux-and-me.blogspot.com
Moto G
Moto E
I thank you so much for this useful feature..
In the light of the new discoveries i will post a past thread where the topic was the color of the led.. Maybe the consideration are the same of the past.. But hope is the last to die :D

http://xdaforums.com/showthread.php?t=2579588
Sent from my XT1032 using XDA Free mobile app
http://xdaforums.com/showpost.php?p=57125278&postcount=38
:p

Maybe pre-production devices had an RGB led (or maybe more a 2 color LED one) but the ones i had in hands feature white only :cowboy:
 
  • Like
Reactions: ReOmbra

S0bes

Senior Member
Jan 1, 2012
870
969
I just wanted to know how we can control pulse frequency when device is charging. It's approximately on=500ms and off =500 ms.
I thought that I found a method which is called every time led becomes active - public void setFlashing(int color, int mode, int onMS, int offMS)
but unfortunately this method is called only on notifications...
Seems like we can't control the second led :(

Anyway, if someone wants to control led's frequency on notifications you can use this xposed module which was kinda debug module for my researches. Don't know if there are already apps for it. if so then do not use mine. I don't care actually :)

p.s
is it bad for my battery if I set led blinking very fast? on=off=30 ms
 

Attachments

  • testblink.apk
    351.5 KB · Views: 31
Last edited:
  • Like
Reactions: remo0073

diordnAMRZAR

Member
Sep 12, 2014
42
17
This LED hack works on my rooted XT1040 -- Although I did not build an init script --rather I did the commands through the shell. Cool!
 

robin0800

Senior Member
Jan 22, 2012
606
397
70
Brighton
Google Pixel 7a
I just wanted to know how we can control pulse frequency when device is charging. It's approximately on=500ms and off =500 ms.
I thought that I found a method which is called every time led becomes active - public void setFlashing(int color, int mode, int onMS, int offMS)
but unfortunately this method is called only on notifications...
Seems like we can't control the second led :(

Anyway, if someone wants to control led's frequency on notifications you can use this xposed module which was kinda debug module for my researches. Don't know if there are already apps for it. if so then do not use mine. I don't care actually :)

p.s
is it bad for my battery if I set led blinking very fast? on=off=30 ms
There is an app called "light manager" in the play store that does work and has a good GUI for configuration, not sure if it only works on a rooted phone.
 
  • Like
Reactions: S0bes

matmutant

Senior Member
Mar 17, 2011
3,395
4,743
~/
andrux-and-me.blogspot.com
Moto G
Moto E
batch answering questions xD

What is that rgb folder for? Is one of the LED RGB?

MOTO why you do this? I crie everytiem ;_;
I think i have a theory about this (see end of post)
_____________​
I just wanted to know how we can control pulse frequency when device is charging. It's approximately on=500ms and off =500 ms.

I thought that I found a method which is called every time led becomes active - public void setFlashing(int color, int mode, int onMS, int offMS)
but unfortunately this method is called only on notifications...
Seems like we can't control the second led :(

Anyway, if someone wants to control led's frequency on notifications you can use this xposed module which was kinda debug module for my researches. Don't know if there are already apps for it. if so then do not use mine. I don't care actually :)


p.s
is it bad for my battery if I set led blinking very fast? on=off=30 ms

We can control blinking using /sys/class/leds/rgb/control (see below) but with both issues and drawback using that way...
I would more fear about LED wearing with fast blinking

_____________​
This LED hack works on my rooted XT1040 -- Although I did not build an init script --rather I did the commands through the shell. Cool!
Thx for the report :)
_____________​
deej_roamer said:
I went through all of your work about the LEDs on moto G and I also have found the two LEDs functioning differently however then i decided to look around some more and whatI found was

Code:
root@falcon_umtsds:/sys/class/leds # ls -l ./*/device
ls -l ./*/device
lrwxrwxrwx root     root              2014-11-30 02:15 device -> ../../../leds-qpnp-e4a33a00
lrwxrwxrwx root     root              2014-11-30 02:16 device -> ../../../qcom,mdss_fb_primary.156
lrwxrwxrwx root     root              2014-11-30 02:16 device -> ../../../leds-qpnp-e4a34c00
lrwxrwxrwx root     root              2014-11-30 02:16 device -> ../../../leds-qpnp-e4a34c00
lrwxrwxrwx root     root              2014-11-30 02:16 device -> ../../../leds-qpnp-rgb-e4a32800
lrwxrwxrwx root     root              2014-11-30 02:09 device -> ../../../qcom,camera-led-flash.0
lrwxrwxrwx root     root              2014-11-30 02:16 device -> ../../../leds-qpnp-rgb-e4a32800
lrwxrwxrwx root     root              2014-11-30 02:16 device -> ../../../leds-qpnp-e4a33c00
These files are in order of
Code:
charging
lcd-backlight
led:flash_0
led:flash_torch
rgb
torch-light
white
wled:backlight

So I linked the LEDs with their function
Code:
charging=======>leds-qpnp-e4a33a00
lcd-backlight====>qcom,mdss_fb_primary.156
led:flash_0=====>leds-qpnp-e4a34c00
led:flash_torch==>leds-qpnp-e4a34c00
rgb==========>leds-qpnp-rgb-e4a32800
torch-light=====>qcom,camera-led-flash.0
white========>leds-qpnp-rgb-e4a32800
wled:backlight==>leds-qpnp-e4a33c00

Which means we have six LEDs in total
Code:
1. The extra charging LED (leds-qpnp-e4a33a00)(charging)
2. The LCD Backlight LED (qcom,mdss_fb_primary.156)(lcd-backlight)
3. The Main Camera Flash (leds-qpnp-e4a34c00)(led:flash_0 and led:flash_torch)
4, The normal notification LED (leds-qpnp-rgb-e4a32800)(rgb and white)
5. The Main Camera Flash (qcom,camera-led-flash.0)(torch-light)
6. The LCD Backlight LED (leds-qpnp-e4a33c00)(wled:backlight)

I have tried to check if I can get the LEDs to turn on using the charging trigger. My conclusions are listed down
1. LED2 and LED6 are just the same
2. LED3 and LED5 are just the same
3. I have been successful in all attempts except in rgb/triggers Although I can trigger the same LED using white/triggers


Could you comment on my conclusions? Please Specially the 3rd one! Also if you have any idea why would they call a white led an rgb?



Looks like you made a pretty good job :) (i was too lazy to search for the "real" path)
All you said is in agreement with what i have found previously by experiments
==> that might mean that we are both wrong? :silly:

_____________​

I would say that the fact there are two ways to light the flash LED is linked to the way the Hardware Abstraction Layer works : two uses == two ways (meaning that Flash-LED is both used as flash [led:flash_*] and torch [torch-light])
==> It was why i previously thought there was only one LED being lighten up in different ways (until i saw the 2 LEDs on MotoE board)

Code:
root@falcon_umts:/sys/devices/leds-qpnp-e4a34c00/leds # ls
led:flash_0
led:flash_torch
==> In case device has more than 1 flash LED, there would be led:flash_1 too and i think that led:flash_torch would light both...

  • led:flash_torch is configured to react to torch_trigger == when we turn torch lamp ON (set */charging/trigger to torch_trigger and see)
  • led:flash_0 is configured to react to flash0_trigger == when camera decides to flash.

_____________​

Now for rgb or white :
There are few documentation on the web (as for triggers) [btw this is interesting to read : https://github.com/buglabs/android-froyo-kernel/blob/master/Documentation/leds-class.txt ]

Code:
root@falcon_umts:/sys/devices/leds-qpnp-rgb-e4a32800/leds # ls
rgb
white

The only way to play with RGB is messing with ./control :
Code:
root@falcon_umts:/sys/devices/leds-qpnp-rgb-e4a32800/leds/rgb # cat ./control
./RGB=0xffffffff, on/off=1000/1000 ms, ramp=1/1
==> Obviously, needs to echo 255 to brightness, but triggers seem not to have any impact

example of what i tried :
Code:
root@falcon_umts:/sys/class/leds/rgb # echo 0xffffff00 1000 100 >./control


  • whatever hexa value used, the color displayed will stay white (pretty obvious)
  • whenever a notification comes it will override the LED blinking == similar behavior as for white
    ==> But it doesn't overwrite the files (?)

RGB looks to be the main controler and would control the channels of an RGB led if it existed on the device

white is like a specific part of RGB (like led:torch_0 is for led:torch ?) and it would explain why motoX 2013 has a green LED and thus has rgb,red, green, and blue folders and that only rgb and green lights its green-only LED.

+ messing with white will mess with rgb and vice versa, i don't have enough time to play much with this but that may help for further understanding...
 
  • Like
Reactions: S0bes

S0bes

Senior Member
Jan 1, 2012
870
969
@robin0800 does it work with gravitybox? Because gb overrides offMS value and at this point I had to look deeper to get it working.
 

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: