Setting and retaining brightness on Mac displays

I'm using IODisplaySetFloatParameter( ... ) to change the brightness on Mac dislplays and it appears to be working correctly. However the OS does not appear to be retaining the setting.


On a Apple Thunderbolt display (2013?) this works fine. The brightness is adjusted and stays at the level I set. During the adjustments I can the Brightness level change in the System Preferences/Display dialog (by refreshing the dialog)

On my MacBook (mid 2014) and on a iMac 5K (late 2015) the brightness level of the display changes, but the System Preferences/Display dialog never reflects this. Thus, when I am done adjusting the display, the brightness will reset back to the starting value and not the level I want.


I've see this on MacOS 10.12.6 and 10.13.3.


Can someone tell if there is a different set of IO calls or pattern of calls that I should be making that will make the brightness values stick.