📱 Always Right Light V4 [SN][MS]

by Mattijs Snepvangers

Version 2 (March 1, 2017)

Download (981 downloads)

Takes average of 10 last lux scans.

This flow should be battery friendly, it adjusts the screen brightness by following a logarithmic curve between:

From [ X=0 lx, Y=0 % ]
To [ X=30 000 lx, Y=100 % ]

Where X is input as the light intensity from the light sensor,
(30 000 lx is maximum on my phone).
And Y is output as the screen brightness in percentage.

The formula:

100 * log(lux + 1)
------------------------------- = Bright %
log(30000)

X = lux.
Y = Bright.

The +1 prevents [Y= -infinity] when [X = 0]

I would like the formula to rise a little slower in the beginning but don't know how/where to modify the formula.

Change log:
Version 1:
2016-09-26
* Prevented the: Scan, variable from overflowing... in case you would run this flow for more than 1021 years ;P
(at current speed)
* Changed the time out to inexact delay & removed keep awake (should not have been on at all) to extend battery life further.

Version 2 = crap.
Version 3:
2016-10-07
* Now uses a list of the last lux values (default 10 entries) and calculate the average of them, to get a slower and more seamless light transition.
* I have lowered the delay in this program so the "cycle time" is faster to increase response time (slightly more battery consumption)
* Now resets the list to the current light level when screen has been off for more than 1 program cycle.

Search Tag: [SN]

V4: edited by Mattijs Snepvangers 2016 Dec 29th
Changed cycle time from 3 to 5 secs
Bypassed some redundant code ( blocks 33 through 36, do correct me if I'm wrong )
Added day/night mode 08:00-23:00

Thanks for the feedback. I'll get working on in whenever possible.

4.3 average rating from 6 reviews

5 stars
3
4 stars
2
3 stars
1
2 stars
0
1 star
0
Reports
0

Rate and review within the app in the Community section.