FORUMS
Remove All Ads from XDA

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

13,194 posts
Thanks Meter: 39,785
 
Post Reply Email Thread
[ 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 ]





[ 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:
    
    /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/
    
  • BLUE
    Code:
    
    /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/
    
  • GREEN
    Code:
    
    /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/
    



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:
    
    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; 
    
  2. to make center LED BLUE give the command:
    Code:
    
    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; 
    
  3. to make right LED RED give the command:
    Code:
    
    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; 
    
  4. to power off all the LEDs use:
    Code:
    
    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;
    
  5. for disco lights:
    Code:
    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;


cheers!


regards,

DooMLoRD
Attached Thumbnails
Click image for larger version

Name:	IMG_20130910_223214.JPG
Views:	17066
Size:	150.5 KB
ID:	2248071  
The Following 54 Users Say Thank You to DooMLoRD For This Useful Post: [ View ] Gift DooMLoRD Ad-Free
10th September 2013, 08:24 PM |#2  
Divaksh's Avatar
Retired Recognized Developer
Flag Jaipur
Thanks Meter: 7,047
 
Donate to Me
More
Reserved.

Sent from my C5302 using XDA Premium 4 mobile app
10th September 2013, 09:44 PM |#3  
karma123's Avatar
Senior Member
Thanks Meter: 46
 
More
definitely you are the man .. thanks for your hard work
The Following User Says Thank You to karma123 For This Useful Post: [ View ] Gift karma123 Ad-Free
11th September 2013, 05:12 AM |#4  
moomoopobo's Avatar
Member
Flag Sydney
Thanks Meter: 0
 
More
Yes!,thanks man!, I'm Kenny on the facebook page =D, well done man, once again, you are a beast =P
11th September 2013, 05:43 AM |#5  
Sunghabib's Avatar
Member
Flag Depok
Thanks Meter: 8
 
More
Oh man, i have no idea how to edit this thing

Sent from my C5303 using XDA Premium 4 mobile app
11th September 2013, 07:20 AM |#6  
Li-polymers's Avatar
Senior Member
Flag Melbourne
Thanks Meter: 49
 
More
Quote:
Originally Posted by Sunghabib

Oh man, i have no idea how to edit this thing

Sent from my C5303 using XDA Premium 4 mobile app

You can use a terminal emulator to run these scripts.

Sent from my C5303 using xda app-developers app
11th September 2013, 07:21 AM |#7  
ashis.kyal's Avatar
Senior Member
Flag Kolkata
Thanks Meter: 77
 
Donate to Me
More
Tutorial 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!
The Following User Says Thank You to ashis.kyal For This Useful Post: [ View ] Gift ashis.kyal Ad-Free
11th September 2013, 08:00 AM |#8  
DooMLoRD's Avatar
OP Inactive Recognized Developer
Flag Pune
Thanks Meter: 39,785
 
Donate to Me
More
Quote:
Originally Posted by ashis.kyal

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!

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
The Following 2 Users Say Thank You to DooMLoRD For This Useful Post: [ View ] Gift DooMLoRD Ad-Free
11th September 2013, 08:18 AM |#9  
ashis.kyal's Avatar
Senior Member
Flag Kolkata
Thanks Meter: 77
 
Donate to Me
More
Quote:
Originally Posted by DooMLoRD

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

Yes I know that these are the prerequisite but many Of the members didnt know the process.

Btw an app will be a a great
11th September 2013, 10:59 AM |#10  
Li-polymers's Avatar
Senior Member
Flag Melbourne
Thanks Meter: 49
 
More
Any way to change colours then those three?

Sent from my C5303 using xda app-developers app
11th September 2013, 11:02 AM |#11  
DooMLoRD's Avatar
OP Inactive Recognized Developer
Flag Pune
Thanks Meter: 39,785
 
Donate to Me
More
Quote:
Originally Posted by Li-polymers

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
The Following User Says Thank You to DooMLoRD For This Useful Post: [ View ] Gift DooMLoRD Ad-Free
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes