Xperia M LED control from shell (using files in /sys/class/) - Sony Xperia M

Hello XDA community,
I would like to get some advice at controlling notification LED on my Xperia M dual (C2005) running PecanM's Adnroid 6.0.
"Internet" says it is controlled from /sys/class/led or .../leds.
the /led directory looks like this:
Code:
[email protected]:/sys/class/led # ls
ls
fih_led
the fih_led directory:
Code:
[email protected]:/sys/class/led/fih_led # ls
ls
control
info
power
subsystem
uevent
the info file (green is on because it's charging and battery state > 90%):
Code:
[email protected]:/sys/class/led/fih_led # cat info
cat info
red LED(0), PMIC GPIO-0, LPG-6
On/Off PWM(0), Blinking PWM[0:0], Fade in/out PWM(511)
Blinking Time[0ms:0ms], Interval(500ms)
Frequency[CLK:DIV:EXP]=[2:3:3]
Ramp Generator[Toggle:Loop:Up]=[No:No:Yes]
LUT table[48-63]
Disable invert
Current sink(12mA)
Normal mode
Off state
green LED(1), PMIC GPIO-0, LPG-5
On/Off PWM(510), Blinking PWM[0:0], Fade in/out PWM(511)
Blinking Time[0ms:0ms], Interval(500ms)
Frequency[CLK:DIV:EXP]=[2:3:3]
Ramp Generator[Toggle:Loop:Up]=[No:No:Yes]
LUT table[32-47]
Disable invert
Current sink(12mA)
Normal mode
On state
blue LED(2), PMIC GPIO-0, LPG-4
On/Off PWM(0), Blinking PWM[0:0], Fade in/out PWM(511)
Blinking Time[0ms:0ms], Interval(500ms)
Frequency[CLK:DIV:EXP]=[2:3:3]
Ramp Generator[Toggle:Loop:Up]=[No:No:Yes]
LUT table[16-31]
Disable invert
Current sink(12mA)
Normal mode
Off state
then there is a control file:
Code:
[email protected]:/sys/class/led/fih_led # cat control
cat control
CMD
01 : LED on/off, 1 parameter
02 : LED blinking, 1 parameter
03 : LED fade in/out, 1 parameter
04 : Brightness of LED on, 1 parameter
05 : Brightness of LED blinking, 2 parameter
06 : Interval for LED fade in/out, 1 parameter
07 : Blinking time, 2 parameter
08 : Set mode, 1 parameter
09 : LED on/off in special mode, 1 parameter
10 : LED blinking in special mode, 1 parameter
11 : LED fade in/out in special mode, 1 parameter
12 : Set PMIC GPIO/MPP clock, DIV & EXP, 3 parameter
13 : Set PMIC GPIO/MPP clock, 1 parameter
14 : Set PMIC GPIO/MPP DIV, 1 parameter
15 : Set PMIC GPIO/MPP EXP, 1 parameter
16 : Set PMIC GPIO/MPP toggle, loop & ramp, 3 parameter
17 : Set PMIC GPIO/MPP toggle, 1 parameter
18 : Set PMIC GPIO/MPP loop, 1 parameter
19 : Set PMIC GPIO/MPP ramp, 1 parameter
20 : Set PMIC GPIO invert, 1 parameter
21 : Set PMIC MPP/LPG current sink, 1 parameter
22 : Set LED pin, 1 parameter
23 : Set MSM GPIO on/off level, 2 parameter
24 : Set PMIC GPIO/MPP/LPG, 1 parameter
25 : Brightness of LED fade in/out, 1 parameter
26 : LED SW blinking, 1 parameter
27 : LED SW fade in/out, 1 parameter
28 : LED SW blinking in special mode, 1 parameter
29 : LED SW fade in/out in special mode, 1 parameter
30 : Set range of LUT table, 2 parameter
31 : Set on/off state of LED, 1 parameter
32 : LED fade in/out at different timing (on/off, in time, out time), 3 parameter
33 : LED fade in/out once (on, in/out time, toggle up/down), 3 parameter
34 : LED fade in/out at different timing in special mode, 3 parameter
35 : LED fade in/out once in special mode, 3 parameter
From all this information I am assuming that these numbers are commands for controlling the led and
Code:
echo 21 0 > control
echo 01 1 > control
should set the currently controlled led to pin 0 (the red one) and turn it on (or off depending on type of logic), but that does nothing.
Is there any documentation on how to use this? Or does anybody know how to control the notification led?
Thanks for any useful information.

Related

[Q] Ambient Light Sensor Limitations??

I haven't been able to find an answer so far to this, so here goes.
I've played around extensively with the Auto-Brightness settings, tweaking to my desires. However, I'm still having problems in lower light conditions. Not a dark environment, mind you, but simply indoors without a light shining directly on the light sensor.
From what I can tell by watching the Sensor readings (under Edit Light sensor levels...), the sensor jumps from a low limit reading of 10 all the way up to 160 without any steps in between. Above that and the level jumps are less of an issue (and in fact, there are more steps). But because of the 10/160 jump, I end up with an "all or nothing" type situation. I can either have a comfortable, dimmer brightness level when it's dark, but have a screen that's too dim under normal conditions; or I can have it comfortably bright under normal use, but overly so in darker situations.
My question, after all of that, is whether this is a hardware limitation or something that could be modified in the code for the sensor?
I am willing to put in some work on this issue if someone can provide some direction on what I need to look at.
Thanks
Do you have the filter option enabled?
nukedukem said:
Do you have the filter option enabled?
Click to expand...
Click to collapse
I do. That shouldn't affect the raw values, though, only the filtered ones to the left of the raw values.
kevinbear said:
I haven't been able to find an answer so far to this, so here goes.
I've played around extensively with the Auto-Brightness settings, tweaking to my desires. However, I'm still having problems in lower light conditions. Not a dark environment, mind you, but simply indoors without a light shining directly on the light sensor.
From what I can tell by watching the Sensor readings (under Edit Light sensor levels...), the sensor jumps from a low limit reading of 10 all the way up to 160 without any steps in between. Above that and the level jumps are less of an issue (and in fact, there are more steps). But because of the 10/160 jump, I end up with an "all or nothing" type situation. I can either have a comfortable, dimmer brightness level when it's dark, but have a screen that's too dim under normal conditions; or I can have it comfortably bright under normal use, but overly so in darker situations.
My question, after all of that, is whether this is a hardware limitation or something that could be modified in the code for the sensor?
I am willing to put in some work on this issue if someone can provide some direction on what I need to look at.
Thanks
Click to expand...
Click to collapse
Yeah, I had this same problem. In general, I just found things were too bright. I've had good luck with these settings:
Sensor Filter: Enabled
Window Length: 20s
Reset Threshold: 1000 lux (any lower and it seems to get triggered too much).
Sample Interval: 2s (Since it's on a 20 second window length, I didn't see the need for super frequent sensor reading)
Use Custom Light Levels: Enabled
Screen Dim Level: 20 (default)
Allow Light Decrease: Enabled
Decrease Hysteresis: 40%
My light levels:
Lo-Up Screen Buttons
0-10 40 255
11-40 50 255
41-90 60 255
91-160 75 255
151-225 85 0
226-320 95 0
321-640 110 0
641-1280 120 0
1281-2600 140 0
2601-3099 160 0
3100-4099 180 0
4100-5099 200 0
5100-6099 220 0
6100-7099 230 0
7100-inf 255 0
Thanks for the response! I will try your settings and see how it works for me.
So were you getting similar raw sensor readings, too?

Automatic brightness?

I miss the option for this...
The widget only makes the brightest or darkest setting... :-(
Sent from my LT15i using XDA App
when you use the standard "Power Control" widget you can toggle min/user/max
with user being the setting that you set in the display settings.
and if you have a user setting somewhere in the middle, then it will adjust to the ambient light.
If you install widgetsoid (a massively enhanced version of the powercontrol widget mentioned above) the brightness control has an auto option, which works fine.
For ARC, you can enable and disable by executing the following command in a terminal. You can write it in a script file and make it one-button action with the help of "gscript lite".
echo 1 > /sys/devices/i2c-0/0-0040/leds/lcd-backlight/als/enable
1 to enable, 0 to disable
In addition, by adjusting cutoff frequency of low pass filter of ALS output, you can adjust the changing speed of brightness relative to ambient lighting. The command is listed below:
echo 2,4,2,0 > /sys/devices/i2c-0/0-0040/leds/lcd-backlight/als/params
2nd figure "4" is to define cuf-off frequency to 4Hz for
increasing brightness. Range 0~7, larger value for faster change
3rd figure is for decreasing brightness. This example, 2, is to define 2Hz for cut-off frequency.
cruxlin said:
For ARC, you can enable and disable by executing the following command in a terminal. You can write it in a script file and make it one-button action with the help of "gscript lite".
echo 1 > /sys/devices/i2c-0/0-0040/leds/lcd-backlight/als/enable
1 to enable, 0 to disable
In addition, by adjusting cutoff frequency of low pass filter of ALS output, you can adjust the changing speed of brightness relative to ambient lighting. The command is listed below:
echo 2,4,2,0 > /sys/devices/i2c-0/0-0040/leds/lcd-backlight/als/params
2nd figure "4" is to define cuf-off frequency to 4Hz for
increasing brightness. Range 0~7, larger value for faster change
3rd figure is for decreasing brightness. This example, 2, is to define 2Hz for cut-off frequency.
Click to expand...
Click to collapse
I think I just fell in love. Thanks a lot!
daveybaby said:
If you install widgetsoid (a massively enhanced version of the powercontrol widget mentioned above) the brightness control has an auto option, which works fine.
Click to expand...
Click to collapse
I have widgetsoid installed and the auto brightness control just sets my brightness to the minimum..
DemonicHawk said:
I have widgetsoid installed and the auto brightness control just sets my brightness to the minimum..
Click to expand...
Click to collapse
Are you sure? Works here just fine.
Try holding your thumb over the light sensor, see what happens.
Yeah, i've tried covering it and putting a flashlight to it, neither do anything when on auto. I even went into the service menu to make sure it was working properly.
I guess i'll just have to stick with a fixed brightness and let it "auto adjust" as needed. Maybe its the generic .181 build im using?
Hmm, i don´t know who is wrong but i was thinking that the arc only has an automatic brightness that can not be disabled. I have a german arc (unbranded, .181 FW) and it doesn´t matter to which level the brightness is set the automatic is always active and permanently regulates the brightness. Woul be very gald if SE would integrate an automatic brightness on/off setting with the next firmware
cruxlin said:
For ARC, you can enable and disable by executing the following command in a terminal. You can write it in a script file and make it one-button action with the help of "gscript lite".
echo 1 > /sys/devices/i2c-0/0-0040/leds/lcd-backlight/als/enable
1 to enable, 0 to disable
In addition, by adjusting cutoff frequency of low pass filter of ALS output, you can adjust the changing speed of brightness relative to ambient lighting. The command is listed below:
echo 2,4,2,0 > /sys/devices/i2c-0/0-0040/leds/lcd-backlight/als/params
2nd figure "4" is to define cuf-off frequency to 4Hz for
increasing brightness. Range 0~7, larger value for faster change
3rd figure is for decreasing brightness. This example, 2, is to define 2Hz for cut-off frequency.
Click to expand...
Click to collapse
Genius!! Many thanks
Strange! with the update to 2.3.3 it stopped auto-dimming (not sure if it was due to the update or due to me installing juice defender)
And i can not get turn it on with the Power Widget.
cruxlin said:
echo 1 > /sys/devices/i2c-0/0-0040/leds/lcd-backlight/als/enable
1 to enable, 0 to disable
Click to expand...
Click to collapse
I get "permission denied" trying to do that
but "cat" ing the vqalue gives me a 0
do I have to root?
cruxlin said:
echo 2,4,2,0 > /sys/devices/i2c-0/0-0040/leds/lcd-backlight/als/params
2nd figure "4" is to define cuf-off frequency to 4Hz for
increasing brightness. Range 0~7, larger value for faster change
3rd figure is for decreasing brightness. This example, 2, is to define 2Hz for cut-off frequency.
Click to expand...
Click to collapse
cat /sys/devices/i2c-0/0-0040/leds/lcd-backlight/als/params
gain,filter_up,filter_down,offset
2,0,0,0
any clues what gain and offset are used for?
this works brilliantly
Thank you so much
And yes you need ROOT
cruxlin said:
For ARC, you can enable and disable by executing the following command in a terminal. You can write it in a script file and make it one-button action with the help of "gscript lite".
echo 1 > /sys/devices/i2c-0/0-0040/leds/lcd-backlight/als/enable
1 to enable, 0 to disable
In addition, by adjusting cutoff frequency of low pass filter of ALS output, you can adjust the changing speed of brightness relative to ambient lighting. The command is listed below:
echo 2,4,2,0 > /sys/devices/i2c-0/0-0040/leds/lcd-backlight/als/params
2nd figure "4" is to define cuf-off frequency to 4Hz for
increasing brightness. Range 0~7, larger value for faster change
3rd figure is for decreasing brightness. This example, 2, is to define 2Hz for cut-off frequency.
Click to expand...
Click to collapse
Hi cruxlin
Thanks allot for your information on how to change this. I have found on my ARC with 2.3.3 that als/enable is allways configured to "1". Doing echo "0" > als/enable will not change this value. It is working fine for als/params where I managed to change how fast the brightness are changing.
I also discovered an odd way of manually disabling/enabling the light sensor by using the default sony ericsson brightness toggle widget. Setting this to "dim" will disable the auto brightness and you can set the brightness manual to whatever level you wish. When you toggle the widget to enable brightness it will both enable auto brightness and change brightness to the value you previosly used as minimum.
I had for testing added echo 2,6,6,0 > als/params for fast brightness change and using a flashlight. This made the brightness update the same second I moved the flashlight over the light sensor.
I actually very much like the sony ericsson way of controlling this as it enables me to define minimum brightness with auto brightness enabled and very quickly use the dim toggle to quickly change to some other preffered value.
So with that second script you can also get rid of the backlight stuttering higher and lower in some situations?
Ambroos said:
So with that second script you can also get rid of the backlight stuttering higher and lower in some situations?
Click to expand...
Click to collapse
I do not think I have experienced this backlight stuttering, how do you notice this?
I have just yesterday managed to get my auto brightness working, my SE brightness widget had been set to dim shortly after I got the phone and I had not touched it until yesterday unknowing that this also controls the auto brightness
hygge said:
I do not think I have experienced this backlight stuttering, how do you notice this?
I have just yesterday managed to get my auto brightness working, my SE brightness widget had been set to dim shortly after I got the phone and I had not touched it until yesterday unknowing that this also controls the auto brightness
Click to expand...
Click to collapse
It's just that in some low-light situations the automatic brightness flips out, and switches between two settings at an extremely fast speed, creating a flickering effect. Doesn't happen a lot, but it is pretty annoying when it happens.
Ambroos said:
It's just that in some low-light situations the automatic brightness flips out, and switches between two settings at an extremely fast speed, creating a flickering effect. Doesn't happen a lot, but it is pretty annoying when it happens.
Click to expand...
Click to collapse
I do experience that on my Neo too, try to move your phone a bit, or hold your thumb over the light sensor and release it. Works sometimes.
I ran the script in glite and it makes no difference for me any pointers thx
hygge said:
I also discovered an odd way of manually disabling/enabling the light sensor by using the default sony ericsson brightness toggle widget. Setting this to "dim" will disable the auto brightness and you can set the brightness manual to whatever level you wish. When you toggle the widget to enable brightness it will both enable auto brightness and change brightness to the value you previosly used as minimum.
I had for testing added echo 2,6,6,0 > als/params for fast brightness change and using a flashlight. This made the brightness update the same second I moved the flashlight over the light sensor.
I actually very much like the sony ericsson way of controlling this as it enables me to define minimum brightness with auto brightness enabled and very quickly use the dim toggle to quickly change to some other preffered value.
Click to expand...
Click to collapse
It works perfectly for me, thank you.
After upgrading to 2.3.4 where power control widget is missing (I dont know why), I was not able to set auto-mode.
With this solution I recovered it and, more ahead, I have now something I was looking for, the way to set the low brightness intensity, that was very high when dark night.
I cannot set the other paramethers, since I lost root while updating (I'll need to fix this), but for the moment, it works fine.
Again, thanks a lot.
daveybaby said:
If you install widgetsoid (a massively enhanced version of the powercontrol widget mentioned above) the brightness control has an auto option, which works fine.
Click to expand...
Click to collapse
Even if you uncheck auto, it will use the light sensor to set the brightness, the input you give is just the minimal brightness. Try putting the brightness on ~8% in a place with light, then hold you hand above the light sensor. Screen will still become darker.

No button lights

I just noticed my buttons aren't lighting up anymore :/
Mine stay on whenever charging and at all brightness levels... the only way they'll go off is if I put the phone to sleep (click power button).
Anyone know the setting location? I have Cyanogen & ADW launcher. I've seen it before but it's been so long I forgot where they were and can't find them.
Jodsfk421 said:
Anyone know the setting location? I have Cyanogen...
Click to expand...
Click to collapse
Menu > Settings > CM Settings > Display > Automatic Backlight > Edit other levels
Lower / Upper = readings from the light sensor
Screen = the screen brightness you want based on the lower/upper light sensor values
Buttons = whether or not you want the softkeys on. Unfortunately, they cannot be dimmed (hardware limitations, from what I've read), so 255=on and 0=off
In the default configuration, for example, if the sensor value is 0-199, the screen will be set to brightness 25 and the softkeys will be turned on. If the sensor value is >399, notice that the softkeys turn off (button value changes to 0). If you want the buttons on all the time, set all button values as 255. If you're like me, and you hate the softkey lights, set all button values to 0.
THANK YOU! Exactly what I was looking for and clearly explained!

[Q] CM7 display setting help.

Hey everyone. I've been trying to get better battery life out of my INC2 with CM7.2 and Aeroevan's kernel. The display of course, its the main reason why the battery life suffers. I like the automatic display brightness option because it is convenient, but sometimes it just doesn't behave the way I like it. Right now, with the current settings, it behaves ideally but I wish it was literally a couple of notches dimmer in every situation. Here they are:
Light Sensor Filter
-----------------
Enabled
Window Length: 10 seconds
Reset Threshold: 800 lux
Sample Interval: 1 second
Light Levels
-----------
Use Custom
Screen Dim Level: 20 (default)
Edit Other Levels: All of these values are their respective defaults
Allow Light Decrease
Decrease hysteresis: 40%
So guys, using automatic brightness....how can I do what I'm trying to do? (Literally make it dimmer at every "level")? I didn't edit the values/options that looked in-depth, while some of them I just took some tips online.

Question Incorrect operation of the light sensor

Hello! The light sensor works strangely for me. The display brightness is permanently low. I went to the engineering menu (*#899#) Manual test -> DEVICE DEBUGGING -> LightSensor in the `Parameter` field, the value is 1100. For all, this value is lower. I cannot change this value. I can't get into `FactoryMode` either.
Can someone help and tell me how to calibrate the light sensor?
Hard reset done. Android 12, OxygenOS 12.

Categories

Resources