Monday, November 24, 2014

Moto G : Play with the LED

Moto G has a White-only notification LED (as actual Knowledge, might be proved wrong later on... ==> proof has been given since then)

I miss the RGB led of my X10 mini, and the charging LED notification
We can't override the LED color since it turned out that the LED is White and not RGB, but we can play with the triggers :

in /sys/class/leds/, we can find the following folders (that are symlinks):
  • charging/
  • lcd-backlight/
  • led:flash_0/
  • led:flash_torch/
  • rgb/
  • torch-light/
  • white/
  • wled:backlight/

For a start, let's play with /sys/class/leds/charging/:
  • brightness
  • device/
  • max_brightness
  • power/
  • subsystem/
  • trigger
  • uevent

Brightness

Is that LED dimmable?

adb shell
su
echo 255 /sys/class/leds/charging/brightness


  • Using /sys/class/leds/charging/brightness this LED only takes two states: 0 and 255 (in fact 0 and != 0)
  • Using /sys/class/leds/white/brightness the LED can be set to any value between 0 and 255 (but it is overridden if a notification comes and the value is set bat to 0...


Triggers
Testing and setting the triggers

What are the triggers available ?

catching values :
cat /sys/class/leds/charging/trigger

output:
[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 


The ones we know the use :

  • [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 get Blinking during charging :
echo battery-charging-blink-full-solid >/sys/class/leds/charging/trigger

making sure it worked:
cat /sys/class/leds/charging/trigger

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

Since */charging/brightness does not dimm LED, the LED stays at full power.


Comments

Some Strange behaviors :

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) in fact i recently found that MotoG has 2 LEDs and that they can be lighten up the same way it works for MotoE :

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



Though using /sys/class/leds/white/brightness allows to use 0~255 values to dimm the LED it is overridden by any incoming notification that set brightness back to 0. ==> Cannot be used as battery blinking notification.

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 used as notification LED as it is by default) and get both working together this way.
What we need is to find a way to dim the "first" LED


Got the idea to play with LED thanks to carock @XDA

No comments:

Post a Comment