Jump to content

Lineage OS Night Light and brightness configuration


Recommended Posts

On stock Android I was using Fx Service color filter feature to basically implement my own Night Light version. With Lineage OS we can look at it from a device manufacturer perspective and better customize Night Light as explained there:
https://source.android.com/devices/tech/display/night-light

My goal would be to make it darker than it currently is at maximum intensity, by either just changing the temperature range or even fine tuning those equations parameters. I'm also not that crazy about the Amber offset so I guess I would try to make sure it's not too pronounced.

Moreover maybe there is a way to further lower the screen brightness or is that controlled by closed source drivers?

@Sean McCreary @npjohnson any thoughts on that?

Edited by Slion
Link to post
Share on other sites
  • Slion changed the title to Lineage OS Night Light and brightness configuration

To configure Night Light you need to edit that config.xml resource overlay:
https://github.com/LineageOS/android_device_fxtec_pro1/blob/lineage-18.1/overlay/frameworks/base/core/res/res/values/config.xml

It is in fact overriding values from the platform config.xml in which you can find all defaults:
https://github.com/LineageOS/android_frameworks_base/blob/lineage-18.1/core/res/res/values/config.xml

From the two quadratic equations defined in our config, Pro1 uses the native one, at least in the configuration I tested: config_nightDisplayColorTemperatureCoefficientsNative

Red component quadratic actually defines a constant straight line at 1.0 so reds are not affected by Night Light as configured.

Plot of the Green component quadratic looks as follow with interesting values between about 2596 and 4082 as defined by our temperature range: https://www.desmos.com/calculator/xirci6hx7t
That means greens modulation is in the range 0.723 and 0.855.

Plot of the Blue component quadratic looks as follow:
https://www.desmos.com/calculator/oyj4fjsk6n
That means blues modulation is in the range 0.459 and 0.72.

With lower intensity Night Light we observe less of a colour shift therefore when you push up the intensity it means you reduce the temperature toward the lower limit defined in the configuration, in our case taking out more of the blue and green components thus creating a shift toward yellow.

Edited by Slion
  • Thanks 2
Link to post
Share on other sites

I'll be testing the following parameters:

     <!-- That's the one actually used on Pro1
          vres = vat2 + vbt + vy-int
     -->
    <string-array name="config_nightDisplayColorTemperatureCoefficientsNative">
        <!-- R a-coefficient --> <item>-0.0000000189359041</item>
        <!-- R b-coefficient --> <item>0.000302412211</item>
        <!-- R y-intercept --> <item>-0.198650895</item>
        <!-- G a-coefficient --> <item>-0.0000000189359041</item>
        <!-- G b-coefficient --> <item>0.000302412211</item>
        <!-- G y-intercept --> <item>-0.198650895</item>
        <!-- B a-coefficient --> <item>-0.0000000189359041</item>
        <!-- B b-coefficient --> <item>0.000302412211</item>
        <!-- B y-intercept --> <item>-0.198650895</item>
    </string-array>

Basically it applies the same treatment to all three colour components, RGB, thus you can modulate the screen colours by anything between 0.72 and 0.459 meaning you can cut up to half the brightness from the lower brightness settings. With those settings you don't get the amber colour shift people are used to with Night Light but the exact same amount of blue light emission is removed, while also cutting out just as much red and green light.

I would also argue that the temperature range should be change as follow:

1660 for 0.251 thus providing only one quarter of the lowest brightness settings.
7290 for 1.0 thus allowing full range of brightness selection between 1.0 and 0.251.

By the way my understanding is that if you change the equations parameters the way we did, the temperature range don't actually have much to do with temperature I guess but they are still providing a measure of the intensity. In fact if our goal is to use Night Light to just reduce the brightness linearly I suppose we could simplify those equations quite a bit.

Link to post
Share on other sites
On 9/15/2021 at 4:34 AM, Slion said:

Moreover maybe there is a way to further lower the screen brightness or is that controlled by closed source drivers?

I do not know how to just change the screen brightness range rather than use Night Light to do that.

Looking in our configuration we are already using quite a low minimum brightness – it is set to one, could it be zero? Should not make much of a difference anyway. –  so I'm guessing this is more of a Kernel driver issue and I'm not sure where to look for it.

<integer name="config_screenBrightnessSettingMinimum">1</integer>

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms