[Hack]Improved Hardware Auto Brightness - Xperia SP General

This is a hacky fix but it is a fix.
It gives you a backlight that will go from dim to full bright without the need for any other apps running. It's not uber configurable like dedicated apps as it's limited by hardware but it requires 0 ram, 0 runtime and 0 battery
Append the following to hw_config.sh. The sleep is a hack but a viable one - hw_config is fired up by one of the rc files as a oneshot service so it should be OK to extend it's operation
If you prefer you could just make a standalone script with everything after the sleep command (make sure you have the dev= assignment from hw_setup too!) and fire it off with a script executer of your choice
Code:
#this sleep ensures that the system is up and done [email protected] with light levels before setup
sleep 30
#select als group for backlight
echo 1 > $dev/leds/lcd-backlight1/als_group
echo 1 > $dev/leds/lcd-backlight2/als_group
#set both to max. brightness - als will lower
echo 255 > $dev/leds/lcd-backlight1/brightness
echo 255 > $dev/leds/lcd-backlight2/brightness
#set custom als curve
echo 7,1,48,72,24,255,0 > $dev/als_group1
#set custom filter frequency
echo 1000 > $dev/als_filter_down_speed_mHz
echo 1000 > $dev/als_filter_up_speed_mHz
#turn on hardware als
echo 1 > $dev/als_on
Notes
Make sure you have completely uninstalled any other light controllers - Velis in particular wreaks havoc even when disabled - it still receives the screen on intent and resets the brightness which results in a black display - guess how I know ....
Make sure you have disabled auto brightness control in the standard Sony settings and set the slider to full bright for good measure
I use nobootanimation so my phone boots a bit quicker than some. It might be that sleep 30 isn't long enough for an animated startup
Best thing is probably to create a setup script and run that to satisfy yourself the hack works. Then add it to hw_config and increase the delay if it doesn't work!
If you want to know more about the als setup check HERE or read the AS3677 datasheet.
Sadly I wasn't able to find out how the ALS curves are loaded into the current system, hence the direct hardware poking
There's some useful debug capability built into the sysfs
cat $dev/debug to see light sensor outputs and calculated backlight settings
cat als_group1 to read back the curve settings complete with a graph showing the response curve
A software guy could probably easily make an apk that hooked to the SCREEN_ON intent to program all this (and have a nice gui to show/edit the curve) but I'm a hardware engineer so that ain't me!

It's easier to just use Lux. Thanks anyway.

pakatsui said:
It's easier to just use Lux. Thanks anyway.
Click to expand...
Click to collapse
LUX, YAB or other brightness app will don`t work correct on all my Xperias. Only with "system brightness settings" active in the background this apps will change the brightness in realtime. When i close the systemsettings brightness will change no longer or with some luck once when unlocking.
so i will test this Hack, hope it helps to become a wide range in realtime.

heross said:
LUX, YAB or other brightness app will don`t work correct on all my Xperias. Only with "system brightness settings" active in the background this apps will change the brightness in realtime. When i close the systemsettings brightness will change no longer or with some luck once when unlocking.
so i will test this Hack, hope it helps to become a wide range in realtime.
Click to expand...
Click to collapse
Lux works fine. I'm using it now.
Sent from my Xperia SP using xda premium

Hello t_o_f,
today i have made test this fix in Car navigation from sunlight to the moon. awesome. this is the best fix i have always seen for xperia autobrightness. :good::laugh::good: ten points from germany.
the best, lowest brightness it is configurable with the Stock slider!

Call me daft. I disabled auto brightness, jacked the brightness to high, and have no other brightness apps installed. I appended the above to /etc/hw_config.sh and rebooted.
auto brightness didn't work. It was still jacked up to high so I enabled it and tested, still not working. Did I do something wrong? I'm on 254 rooted.

Related

[INFO] Auto-Backlight Settings for Cyanogenmod ROMs

Some of you would already know that the lightsensor filter in the Evo kernels is now working ( I would say atleast 80% working ) and responds best to Desire builds.
I have it working just fine for the last few hours on the AndroidMedaUltimate 1.3 version. Here are my settings in case you wanna try out.
CAUTION : If you change the values too many times, lightsensor stops responding and you will not see any changes in values. I believe thats CM related.
My Setup
Build : AndroidMedaUltimate 1.3
Kernel : StockEvo Autobuild dated Oct 29
(No SetCpU/taskkillers/etc)
1. Make sure Auto Brightness is disabled under Settings->Display
2. Goto Settings->Cyanogenmod Settings->User Interface->Automatic Backlight
3. Under Light Sensor filter, make sure Enabled is unchecked (No filters!)
4. Under Light levels, check "Allow Light Decrease" and set "Decrease hysteresis" to 0% (Yes thats no typo, for some reason sensor responds faster this way )
5. Check "Use Custom"
6. Tap on Edit Other Levels...
7. Now set values as in below screenshot and table
Lower ....... Upper ............Screen...........Buttons
0 ____________ 169 _______________ 85 _____________ 255
170 __________ 279 _______________ 120 ____________ 255
280 __________ 749 _______________ 170 ____________ 255
800 __________ () _______________ 254 ____________ 255
Note - The last value is 254, for some reason when I had it as 255 and went outside, brightness got stuck at max and sensor stopped responding
Click to expand...
Click to collapse
8. Tap Save & Apply
9. Wait for few seconds and try covering and changing light, you should see the sensor values change on top
10. Once that starts happening, enable Auto Brightness under Display settings
11. Reboot (Best Practice )
---------------
You can add more levels and adjust the lower/upper range alongwith the Screen values (30-255) to suit you better. However, the more you change it the more its likely to end up not working. Dont know why.
Interesting, will be testing this today with Shubcraft 2.0 and post my findings.
thanks, done the changes and testing with Htcclays V1.4.
edit: it is working very well for me.no lightsensor issue for me.
many thanks for your tip.
Thank you works grat
v-b-n said:
1. Make sure Auto Brightness is disabled under Settings->Display
2. Goto Settings->Cyanogenmod Settings->User Interface->Automatic Backlight
3. Under Light Sensor filter, make sure Enabled is unchecked (No filters!)
4. Under Light levels, check "Allow Light Decrease" and set "Decrease hysteresis" to 0% (Yes thats no typo, for some reason sensor responds faster this way )
5. Check "Use Custom"
6. Tap on Edit Other Levels...
7. Now set values as in below screenshot and table
8. Tap Save & Apply
9. Wait for few seconds and try covering and changing light, you should see the sensor values change on top
10. Once that starts happening, enable Auto Brightness under Display settings
11. Reboot (Best Practice )
---------------
You can add more levels and adjust the lower/upper range alongwith the Screen values (30-255) to suit you better. However, the more you change it the more its likely to end up not working. Dont know why.
Click to expand...
Click to collapse
Thanks very much for this, a few questions if you please.....
I'm using Typhoon 3.8.0.
I'm finding these settings under
Settings->Cyanogenmod Settings->Display->Automatic Backlight
not
Settings->Cyanogenmod Settings->User Interface->Automatic Backlight
And I don't know if that has any underlying significance - like it not being implemented in the same way in Typhoon?
Secondly you don't mention the "screen dim level" setting I see in the same "Display" menu. I've wound it down to 6 (default is 20), but not seeing much difference?
Thirdly, I've used the settings in the "other levels" as your table shows, but I wonder why you used those settings, what drove you to pick those numbers?
Finally, you talk about changing it too much stopping it working....when that happens what do you do to revert? Reboot? Or return to defaults and reboot? or something else?
Thanks, I'm hoping this will help balance out the fact that up to now I've not used auto-brightness so as to keep the battery life up but it's a bit of a pain in bright light to see the screen....
Thanks

[GUIDE] Automatic backlight

Our Nexus S has been blessed with the release of ICS 4.0 in which the light sensor values have been significantly improved over GB. In GB we had about 5 or 6 light sensor values which would decide how bright to set the screen. This created an opportunity for the CyanogenMod team to code the Automatic backlight settings with filtered values in between to try to help the community with correct brightness levels. Still it was a far cry from what is now possible because of the fine increments in light sensor delivered in with the 4.0 binaries.
These settings are a good starting point and can serve well as default values for most. However, depending on your eyes and Voodoo settings you might have to adjust them to your own comfort. So lets get started.
Open the CyanogenMod Settings (if you don't have them in your app menu, ask your ROM developer to integrate them)
Go to Display-> Automatic backlight
Enable - obviously turn this on
Window length - set as low as possible. 2 is the lowest currently. Since our sensor values degradation is very fine now, this is less of use
Reset threshold - set to disabled. Again, this depends on the window length
Sample interval - set to 2s. This will ask the processor to check the brightness level every 2 seconds. You can set it based on what you feel is correct but obviously low values can improve accuracy but uses more cpu and drains your battery quicker
Use custom - check this. we'll set our own values
Screen dim level - this is the default setting for your screen lowest dim level. I use 10 but you might have to use more or less depending on the quality built of your screen and voodoo settings.
Edit other levels... - skip this to the last step
Allow light to decrease - check this.
Decrease hysteresis - set to 0%
Now tap on "Edit other levels..."
Scroll down and tap "set number of levels" set it to 25. Now set the "Lower" value and a "Screen" value for it. The first "Lower" value is set to 0 and can't be modified. "Upper" value is set automatically based on the two values of "Lower" and "Screen". "Buttons" value never worked on the Nexus but with proper kernel support they can change based on light sensor conditions. For now, set all button values to 255.
All values can be set from 0 to 255. Here are my default values:
Code:
Lower | Screen
0 | 10
5 | 20
10 | 30
15 | 40
20 | 50
30 | 60
40 | 70
50 | 80
60 | 90
80 | 100
100 | 110
120 | 120
140 | 130
180 | 140
220 | 150
260 | 160
300 | 170
380 | 180
460 | 190
540 | 200
620 | 210
1240 | 220
2480 | 230
4960 | 240
10000 | 255
Go up and hit "save and apply" after setting it up.
If you're wondering why these values, I doubled the last increment every 4th value. Since the lowest values are the most important for us because we usually are indoors with different lightning conditions, the higher values can be quickly set to max 255 screen brightness when anything over 10,000 hits the sensor such as sitting too close to a powerful light bulb or if you happen to find yourself on Mercury during the day (might want to bring a suit also ).
Modifications and adjustments:
If the screen seems too bright or too dim at any time, go back to the "light sensor levels" screen and look up the current screen value. It's the 2nd line after "Sensor (filtered/raw)". Then scroll down and find a "Screen" setting which is equal to that value and modify it. Try not to move around and make sure the "Sensor (filtered/raw)" values stay the same. What you are doing is simply adjusting your phone's brightness to fit current light sensor level so if it changes while you set it, you wont know if it worked. Also, you can adjust all "Screen" values by 5 or more (down or up) if it feels like it's all off your comfort level.
If you really want to get down and dirty and understand all the fuzz in details byrong over at HTC Droid Incredible forums posted a great explanation and all the science behind it. Just remember that their phone is limited to just a few light sensor values where ours has virtually thousands and that's why I chose to almost eliminate the filtered value to control flicker. But it's up to you if you want to play with that. Also, he has a great post on CPU usage titled "Effects of CPU Frequency and Screen Brightness on Power Consumption". Make sure to check it out.
And one last note regarding the voodoo settings... your screen is different than other phones. I have 4 Nexus S phones and none of them can be set to the same voodoo settings to create the same colors. Depending on screen fabrication quality and possibly date of manufacture, it will vary slightly and sometimes greatly. So if you post your voodoo settings and someone says they suck now you know why.
Awesome guide, thanks!
Or if you're not on CM, grab this app : https://market.android.com/details?id=com.vito.lux , you can set levels based on lux values with ease. Also on new year's sale now at half the price.
madd0g said:
Or if you're not on CM, grab this app : https://market.android.com/details?id=com.vito.lux , you can set levels based on lux values with ease. Also on new year's sale now at half the price.
Click to expand...
Click to collapse
Tried it, works great.
I have this enabled on CM setting and followed your directions...One question? Am I supposed to have automatic brightness levels checked in system settings, display, brightness? Thanks! I believe yes but just want to be sure
Necro but how are these settings in regards to battery life?

reduce brightness on NGLP

Wondering if there's a tweak to a config file that could lower the min brightness on the NGLP, would appreciate any input, thank you.
I've always found the slider to be quite good and wouldn't want it lower than the minimum setting unless it was full off. I know that doesn't really answer your question, but if 99.9% of users are happy with the existing slider it is unlikely there will be a patch or tweak made on the off chance. Having said that, you don't get what you don't ask for so someone here may be able to help.
Is there a specific reason for wanting this or is it just because you find the minimum too bright?
Do you use the Settings > Display > Brightness?
That goes down to at least 5%
You can set it yourself in code:
Code:
// int i is from 0 - 255
System.putInt(getContentResolver(), System.SCREEN_BRIGHTNESS, i);

[BASH SCRIPT] Torch fix for pie GSIs

so, I was googling around a bit, a few days ago, and found out you can control the torch (and other leds) from the command line, or a bash script.
Prerequisites
root (magisk or superSU)
FX file manager or Termux
Text editor
Instructions
Create a file in a directory of your choice with a '.sh' extension
Add the following code to the file:
Code:
su -c 'echo 255 > /sys/class/leds/torch/brightness'
Run the shell script in termux (cd to the directory and run it) or run it using FX, it will ask for root access if you haven't already granted it
Your torch is now on!
To turn it off create another file with
Code:
su -c 'echo 0 > /sys/class/leds/torch/brightness'
in it
Tested on an Honor 9 and P10+
If you have dual tone flash, yo may find different values cause either led to come on, for me, '255' is the yellow flash and '1' is the white flash
For a bit more messing around, cd to the '/sys/class/leds' directory, you will see a few more directories for other LEDs on your device, controlling them is exactly the same as the torch!
Works for me, thanks a bunch dude
EDIT: on honor 7x/Huawei mate se
Thank you so much for this but I found in my own experience, and from comments I saw where this has been shared, that a bash script perhaps wasn't the most effective to have to run each time so I thought of implementing this to Tasker, create a "pseudo toggle" and allocate it to a quick setting tile. The algorithm is:
Code:
If flashlightStatus = TRUE then
Run shell command: su -c 'echo 0 /sys/class/leds/torch/brightness'
Set variable flashlightStatus to FALSE
Else
Run shell command: su -c 'echo 3 /sys/class/leds/torch/brightness'
Set variable flashlightStatus to TRUE
End If
I set it up this way because if you've never set the variable before (or if it clears on reboot or something) then it won't equal true and would still enable. Also, when I set the brightness to 255 the torch had a slight yellow tint so upon further reading, despite that 255 should be full brightness, apparently max brightness is 3 and is a white light (this seems to disable automatically after around 750ms however). Hope this will help those who are still without a torch on treble GSIs.
P.S. I also set up a quick profile that if the flashlight status variable = true then to wait 750ms and check if still true then change to false and turn off the torch; this would reset to compensate for the OS turning the torch off automatically but Tasker still thinking it was on. I'm not sure how necessary this is or whether it's overkill or not.
beejkitsune said:
Thank you so much for this but I found in my own experience, and from comments I saw where this has been shared, that a bash script perhaps wasn't the most effective to have to run each time so I thought of implementing this to Tasker, create a "pseudo toggle" and allocate it to a quick setting tile. The algorithm is:
Code:
If flashlightStatus = TRUE then
Run shell command: su -c 'echo 0 /sys/class/leds/torch/brightness'
Set variable flashlightStatus to FALSE
Else
Run shell command: su -c 'echo 3 /sys/class/leds/torch/brightness'
Set variable flashlightStatus to TRUE
End If
I set it up this way because if you've never set the variable before (or if it clears on reboot or something) then it won't equal true and would still enable. Also, when I set the brightness to 255 the torch had a slight yellow tint so upon further reading, despite that 255 should be full brightness, apparently max brightness is 3 and is a white light (this seems to disable automatically after around 750ms however). Hope this will help those who are still without a torch on treble GSIs.
P.S. I also set up a quick profile that if the flashlight status variable = true then to wait 750ms and check if still true then change to false and turn off the torch; this would reset to compensate for the OS turning the torch off automatically but Tasker still thinking it was on. I'm not sure how necessary this is or whether it's overkill or not.
Click to expand...
Click to collapse
mind if i improve this?
Code:
su -c 'if grep -q 1 /sys/class/leds/torch/brightness; then echo 0 > /sys/class/leds/torch/brightness; else echo 1 > /sys/class/leds/torch/brightness; fi'
-- obviously you can change the 1 to whatever you want
that is the code i'm using, prevents the use of an unnecessary variable, so is faster, and will use less resources, plus its pretty much fail safe, since it reads the current state of the torch to determine if its on or off, so if something else sets it to a state it still works, if something else set you variable externally then the torch becomes messed up until a reboot.
plus, im assuming that variable is a tasker thing? not everyone will use tasker, so eliminating the variable all together makes it work on any app that can add custom quick settings tiles
ambitiousButRubbish said:
mind if i improve this?
Code:
su -c 'if grep -q 1 /sys/class/leds/torch/brightness; then echo 0 > /sys/class/leds/torch/brightness; else echo 1 > /sys/class/leds/torch/brightness; fi'
-- obviously you can change the 1 to whatever you want
that is the code i'm using, prevents the use of an unnecessary variable, so is faster, and will use less resources, plus its pretty much fail safe, since it reads the current state of the torch to determine if its on or off, so if something else sets it to a state it still works, if something else set you variable externally then the torch becomes messed up until a reboot.
plus, im assuming that variable is a tasker thing? not everyone will use tasker, so eliminating the variable all together makes it work on any app that can add custom quick settings tiles
Click to expand...
Click to collapse
Yes, the variable is a Tasker thing so I'm glad there is a solution that wouldn't rely on it. Thanks for the upgrade and I've already switched out my Tasker profile for this. Doesn't seem any quicker or anything but more simple!

Black Screen on zero brightness on T510

I tried many GSIs with Galaxy Tab A T510 but in all of them whenever I set the brightness to very low or lowest the display goes black and I can't seem to revert this as none can be seen afterwards on screen. Any fix for this, guys?
Mrigendra10 said:
I tried many GSIs with Galaxy Tab A T510 but in all of them whenever I set the brightness to very low or lowest the display goes black and I can't seem to revert this as none can be seen afterwards on screen. Any fix for this, guys?
Click to expand...
Click to collapse
Several system settings govern brightness and can be changed with ADB.
Click here to learn about ADB. According to the Android documentation:
public static final int SCREEN_BRIGHTNESS_MODE_MANUAL
SCREEN_BRIGHTNESS_MODE value for manual mode.
Constant Value: 0
public static final String SCREEN_BRIGHTNESS
The screen backlight brightness between 0 and 255.
Click to expand...
Click to collapse
So executing these two commands should might work:
adb shell settings put system screen_brightness_mode 0
adb shell settings put system screen_brightness 0
Clamtacos said:
Several system settings govern brightness and can be changed with ADB.
Click here to learn about ADB. According to the Android documentation:
So executing these two commands should might work:
adb shell settings put system screen_brightness_mode 0
adb shell settings put system screen_brightness 0
Click to expand...
Click to collapse
Thanks for the method you provided but I already figured it out in phh settings. There is an option to set minimum brightness, I set it to a higher number and it worked like a charm. Oh! And also double tap to wake can be enabled from phh settings too.

Categories

Resources