FORUMS
Remove All Ads from XDA
Thread Deleted Email Thread
Prev Previous Post   Next Post Next
[ 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
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