Get the current screen brightness programatically.

I am trying to write an iPhone app that puts up patches of colour with known CIE XYZ values in nits. This would allow you to match your monitor white at home, then carry it to work with you and stand it next to your work monitor. This app is aimed at the motion picture, but it will probably be free, or nearly so.

I cannot see a way to disable adaptive brightness or TrueTone from within the app. This is probably a bad thing to do anyway; my app has to live alongside other apps, and not burn out the screen trying to match impossible whites.

Is there, or can there be please please, some way to determine how bright the screen should be at that moment? If I am matching (say) a gray patch of the digital Macbeth chart as displayed on my home monitor to a patch on my home phone, it could tell me that RGB=1.0 ought to be 165 nits D65 (or whatever) when the colours match to my eye. Or even some undefined but consistent number that I can calibrate myself.

If I can get the current screen brightness, I should be able to get up to the maximum brightness with the adaptive white on. I don't want to weaken my case by asking for something silly - I can live without this extra 2x brightness range - but this may be a feature that already exists for hardware development. Suppose we programatically pretend the ambient light sensor was seeing bright sunlight. With that we could get peak brightness for short periods even if we were trying to match the white of an HDR monitor in a dark room.

If I can get the current screen brightness

        UIScreen.main.brightness

Ah.Thanks, but I know about this. This brightness setting does not directly tell us what the screen brightness is...

The Settings > Display & Brightness page has the Brightness control, but the brightness is also controlled by...

Appearance: Light/Dark (can have different brightness settings) Automatic (overrides Brightness depending on ambient light meter) Options (switches between light & dark mode)

The colour and maybe the brightness too is affected by... Brightness: TrueTone on/off Night Shift

Some of these settings cannot be reached from the app software. I am pretty sure the Automatic and TrueTone states are unreachable from the application software. The display hardware must know how bright it should actually make the display. That is the value I want to get to.

I have measured the screen brightness for different UIScreen.main.brightness settings with as many of the other Display & Brightness settings disabled.

With Brightness = 1.0, my iPhone 12 mini display white is 250 nits.

For Brightness down to about 0.5, the brightness fits 250*pow(UIScreen.main.brightness, 2.2) reasonably well. The 2.2 gamma is approximately the sRGB toe curve. Below that, the brightness is higher than this formula. I cannot fit this using any offset and gamma in the sRGB formula. This is probably a better thing for the user, as otherwise the bottom en of the Brightness control would be very dark, and they might not be able to see to turn it up again.

The 250 nits value is a nice round number. Do all devices of the same model fit the same number? Is there some way to get this value for recent models?

Is there a formula for the brightness function? Is it the same for all recent models? The 2.2 gamma function seems to work over the brightness range I expect people to work with. If Brightness is set to 0.75, for example, I can come up with a reasonable figure for the RGB=1 white brightness. But can we improve on that?

Get the current screen brightness programatically.
 
 
Q