[Tutorial][SP] How-to for controlling the LED Illumination bar!

Search This thread

DooMLoRD

Inactive Recognized Developer
Jul 27, 2010
13,187
39,710
Pune
[ intro ]

so as you all are aware the Xperia SP has a nice LED Illumination bar... Sony was kind enough to provide APIs to control this illumination bar but that is only good if you use it in apps...

many devs here were trying to figure out how to control this LED bar by the traditional ways of using sysfs interface...

I was able to figure out how to get this work! following is a short how-to for controlling the LED Illumination bar!

hope this helps!



[ proof ]

attachment.php




[ NOTE ]

all this requires ROOT! to change the values!



[ interface ]

the stock kernel provides a SYSFS interface at:
Code:
/sys/devices/i2c-10/10-0047/leds


there are 3 LED locations mapped as:
LED3 - LED1 - LED2
(check the image above for mapping)


each LED control has 3 colors:
  • RED
    Code:
    [B][COLOR="Red"]
    /sys/devices/i2c-10/10-0047/leds/LED1_R/
    /sys/devices/i2c-10/10-0047/leds/LED2_R/
    /sys/devices/i2c-10/10-0047/leds/LED3_R/
    [/COLOR][/B]

  • BLUE
    Code:
    [B][COLOR="blue"]
    /sys/devices/i2c-10/10-0047/leds/LED1_B/
    /sys/devices/i2c-10/10-0047/leds/LED2_B/
    /sys/devices/i2c-10/10-0047/leds/LED3_B/
    [/COLOR][/B]

  • GREEN
    Code:
    [B][COLOR="green"]
    /sys/devices/i2c-10/10-0047/leds/LED1_G/
    /sys/devices/i2c-10/10-0047/leds/LED2_G/
    /sys/devices/i2c-10/10-0047/leds/LED3_G/
    [/COLOR][/B]



each LED control interface has two parameters which are of interest to control LED
  • led_current
  • brightness

traditionally LEDs could be controlled using only the brightness interface BUT on the Xperia SP we first need to control the led_current


each one has limits 0 (minimum) to 255 (maximum)



[ example ]

  1. to make left LED GREEN give the command:
    Code:
    [b]
    echo 255 > /sys/devices/i2c-10/10-0047/leds/LED3_G/led_current; 
    echo 255 > /sys/devices/i2c-10/10-0047/leds/LED3_G/brightness; 
    [/b]

  2. to make center LED BLUE give the command:
    Code:
    [b]
    echo 255 > /sys/devices/i2c-10/10-0047/leds/LED1_B/led_current; 
    echo 255 > /sys/devices/i2c-10/10-0047/leds/LED1_B/brightness; 
    [/b]

  3. to make right LED RED give the command:
    Code:
    [b]
    echo 255 > /sys/devices/i2c-10/10-0047/leds/LED2_R/led_current; 
    echo 255 > /sys/devices/i2c-10/10-0047/leds/LED2_R/brightness; 
    [/b]

  4. to power off all the LEDs use:
    Code:
    [B]
    echo 0 > /sys/devices/i2c-10/10-0047/leds/LED1_B/led_current;
    echo 0 > /sys/devices/i2c-10/10-0047/leds/LED2_B/led_current;
    echo 0 > /sys/devices/i2c-10/10-0047/leds/LED3_B/led_current;
    echo 0 > /sys/devices/i2c-10/10-0047/leds/LED1_G/led_current; 
    echo 0 > /sys/devices/i2c-10/10-0047/leds/LED2_G/led_current; 
    echo 0 > /sys/devices/i2c-10/10-0047/leds/LED3_G/led_current; 
    echo 0 > /sys/devices/i2c-10/10-0047/leds/LED1_R/led_current; 
    echo 0 > /sys/devices/i2c-10/10-0047/leds/LED2_R/led_current; 
    echo 0 > /sys/devices/i2c-10/10-0047/leds/LED3_R/led_current;
    [/B]

  5. for disco lights:
    Code:
    [B]echo 255 > /sys/devices/i2c-10/10-0047/leds/LED3_G/led_current; echo 255 > /sys/devices/i2c-10/10-0047/leds/LED3_G/brightness; sleep 1; echo 255 > /sys/devices/i2c-10/10-0047/leds/LED1_B/led_current; echo 255 > /sys/devices/i2c-10/10-0047/leds/LED1_B/brightness; sleep 1; echo 255 > /sys/devices/i2c-10/10-0047/leds/LED2_R/led_current; echo 255 > /sys/devices/i2c-10/10-0047/leds/LED2_R/brightness; sleep 1;[/b]


cheers!


regards,

DooMLoRD
 

Attachments

  • IMG_20130910_223214.JPG
    IMG_20130910_223214.JPG
    150.5 KB · Views: 17,149
Last edited:

ashis.kyal

Senior Member
May 31, 2013
436
77
Kolkata
indiastechblog.blogspot.in
Detailed Tutioral

For inserting this commands you will need rooted device and android terminal emulator which can be downloaded from Play store.
Then you will have to get root access in Terminal and for that command is " /system/xbin/su " (w/o quotes).
Now SuperSu will prompt for Root access and then you need to grant access.
Now type the command from the OP and see the magic!
:victory:
 
  • Like
Reactions: [ThibaulT]

DooMLoRD

Inactive Recognized Developer
Jul 27, 2010
13,187
39,710
Pune
For inserting this commands you will need rooted device and android terminal emulator which can be downloaded from Play store.
Then you will have to get root access in Terminal and for that command is " /system/xbin/su " (w/o quotes).
Now SuperSu will prompt for Root access and then you need to grant access.
Now type the command from the OP and see the magic!
:victory:

if u want to make any changes to sysfs those are pre-requisites... ;)

if u want simpler version wait for a simple LED control app :p
 

sagar29

Senior Member
Aug 19, 2013
85
221
Area 51
Redmi K20 Pro
Any way to change colours then those three?

Sent from my C5303 using xda app-developers app

mix those colors to get different colors :)

like to get purple
echo 255 > /sys/devices/i2c-10/10-0047/leds/LED1_B/led_current;
echo 255 > /sys/devices/i2c-10/10-0047/leds/LED1_B/brightness;
echo 255 > /sys/devices/i2c-10/10-0047/leds/LED1_R/led_current;
echo 255 > /sys/devices/i2c-10/10-0047/leds/LED1_R/brightness;
 
  • Like
Reactions: Li-polymers

Top Liked Posts

  • There are no posts matching your filters.
  • 54
    [ intro ]

    so as you all are aware the Xperia SP has a nice LED Illumination bar... Sony was kind enough to provide APIs to control this illumination bar but that is only good if you use it in apps...

    many devs here were trying to figure out how to control this LED bar by the traditional ways of using sysfs interface...

    I was able to figure out how to get this work! following is a short how-to for controlling the LED Illumination bar!

    hope this helps!



    [ proof ]

    attachment.php




    [ NOTE ]

    all this requires ROOT! to change the values!



    [ interface ]

    the stock kernel provides a SYSFS interface at:
    Code:
    /sys/devices/i2c-10/10-0047/leds


    there are 3 LED locations mapped as:
    LED3 - LED1 - LED2
    (check the image above for mapping)


    each LED control has 3 colors:
    • RED
      Code:
      [B][COLOR="Red"]
      /sys/devices/i2c-10/10-0047/leds/LED1_R/
      /sys/devices/i2c-10/10-0047/leds/LED2_R/
      /sys/devices/i2c-10/10-0047/leds/LED3_R/
      [/COLOR][/B]

    • BLUE
      Code:
      [B][COLOR="blue"]
      /sys/devices/i2c-10/10-0047/leds/LED1_B/
      /sys/devices/i2c-10/10-0047/leds/LED2_B/
      /sys/devices/i2c-10/10-0047/leds/LED3_B/
      [/COLOR][/B]

    • GREEN
      Code:
      [B][COLOR="green"]
      /sys/devices/i2c-10/10-0047/leds/LED1_G/
      /sys/devices/i2c-10/10-0047/leds/LED2_G/
      /sys/devices/i2c-10/10-0047/leds/LED3_G/
      [/COLOR][/B]



    each LED control interface has two parameters which are of interest to control LED
    • led_current
    • brightness

    traditionally LEDs could be controlled using only the brightness interface BUT on the Xperia SP we first need to control the led_current


    each one has limits 0 (minimum) to 255 (maximum)



    [ example ]

    1. to make left LED GREEN give the command:
      Code:
      [b]
      echo 255 > /sys/devices/i2c-10/10-0047/leds/LED3_G/led_current; 
      echo 255 > /sys/devices/i2c-10/10-0047/leds/LED3_G/brightness; 
      [/b]

    2. to make center LED BLUE give the command:
      Code:
      [b]
      echo 255 > /sys/devices/i2c-10/10-0047/leds/LED1_B/led_current; 
      echo 255 > /sys/devices/i2c-10/10-0047/leds/LED1_B/brightness; 
      [/b]

    3. to make right LED RED give the command:
      Code:
      [b]
      echo 255 > /sys/devices/i2c-10/10-0047/leds/LED2_R/led_current; 
      echo 255 > /sys/devices/i2c-10/10-0047/leds/LED2_R/brightness; 
      [/b]

    4. to power off all the LEDs use:
      Code:
      [B]
      echo 0 > /sys/devices/i2c-10/10-0047/leds/LED1_B/led_current;
      echo 0 > /sys/devices/i2c-10/10-0047/leds/LED2_B/led_current;
      echo 0 > /sys/devices/i2c-10/10-0047/leds/LED3_B/led_current;
      echo 0 > /sys/devices/i2c-10/10-0047/leds/LED1_G/led_current; 
      echo 0 > /sys/devices/i2c-10/10-0047/leds/LED2_G/led_current; 
      echo 0 > /sys/devices/i2c-10/10-0047/leds/LED3_G/led_current; 
      echo 0 > /sys/devices/i2c-10/10-0047/leds/LED1_R/led_current; 
      echo 0 > /sys/devices/i2c-10/10-0047/leds/LED2_R/led_current; 
      echo 0 > /sys/devices/i2c-10/10-0047/leds/LED3_R/led_current;
      [/B]

    5. for disco lights:
      Code:
      [B]echo 255 > /sys/devices/i2c-10/10-0047/leds/LED3_G/led_current; echo 255 > /sys/devices/i2c-10/10-0047/leds/LED3_G/brightness; sleep 1; echo 255 > /sys/devices/i2c-10/10-0047/leds/LED1_B/led_current; echo 255 > /sys/devices/i2c-10/10-0047/leds/LED1_B/brightness; sleep 1; echo 255 > /sys/devices/i2c-10/10-0047/leds/LED2_R/led_current; echo 255 > /sys/devices/i2c-10/10-0047/leds/LED2_R/brightness; sleep 1;[/b]


    cheers!


    regards,

    DooMLoRD
    2
    For inserting this commands you will need rooted device and android terminal emulator which can be downloaded from Play store.
    Then you will have to get root access in Terminal and for that command is " /system/xbin/su " (w/o quotes).
    Now SuperSu will prompt for Root access and then you need to grant access.
    Now type the command from the OP and see the magic!
    :victory:

    if u want to make any changes to sysfs those are pre-requisites... ;)

    if u want simpler version wait for a simple LED control app :p
    1
    definitely you are the man .. thanks for your hard work
    1
    Detailed Tutioral

    For inserting this commands you will need rooted device and android terminal emulator which can be downloaded from Play store.
    Then you will have to get root access in Terminal and for that command is " /system/xbin/su " (w/o quotes).
    Now SuperSu will prompt for Root access and then you need to grant access.
    Now type the command from the OP and see the magic!
    :victory:
    1
    Any way to change colours then those three?

    Sent from my C5303 using xda app-developers app

    its standard RGB...

    u can mix them to get desired color :)

    following a list of colors u can get using RGB combination:
    http://kb.iu.edu/data/aetf.html