SteveA
Posts: 32
Joined: Sat Mar 14, 2015 11:18 am
Location: South Yorkshire, England

Adjust Screen Brightness programmatically x11 for HDMI and not LCD screens

Mon Nov 25, 2019 11:19 am

I need to alter the screen brightness when a particular scientific project is run in a dark room/lab. The room is initially bright then turned dark when using such as UV, etc, and so the screen needs to be dimmed to match, so as still to be able to read the text/graphics. If the screen is not dimmed it prevents defects/problems being seen. There is no access to the display monitor brilliance controls as everything has to be sealed.

On the RPI3 I use openvg for all of the graphics/UI in the project. The library I use is the excellent version by Paeryn, which is based on AJ Starks openvg lib, both of which use the OpenVG lib by the Kronos group as pre-installed in all RPi OS up to the RPI4 Buster version.

To dim the screen using openvg, I create a new window layer (I call it a dim layer) above the main drawing layer/s (as openvg allows multiply drawing layers) and then alter the opacitiy of that dim layer to adjust the screen display brightness from 0 - 100% as required. It works perfectly well and finely adjusts the screen brightness without any corruption of gamma/colour.

Unfortunately, the new RPI4 does not include OpenVG/openvg and it cannot be installed due to a change of the firmware. It has been removed by the RPI software team and I have read that it is not going to be added back due to OpenVG Kronos group not updating OpenVG for many years - maybe it does not need updating as it works fine and spot on, hence that appears to be a weak reason to not include it due to it working fine!. All of the excellent OpenVG graphics handling, multi window layers, opacity control, text scaling, image handling, rotating, etc, has now been lost.

To use the RPI4 (which I need for more ram and an increase in speed because of high speed ADC data logging) I will have to completely rewrite everything using x11 windows graphics and not openvg graphics. The first obstacle I have come across is how to programmatically adjust the screen brightness as this is a prime requirement in the environment it will be used.

I have looked through the web and see that you can alter the backlight/brightness when using the small add-on RPI (touch) LCD screen (by altering the backlight, xrandr, etc), but none of the solutions seen can adjust the standard HDMI/DVI monitor displays (2 of them will be used), which I have to use due to the need a for large screen area.

Has anyone managed to programmatically (in C) alter the screen brightness in x11 graphics - perhaps by a driver which scales the pixel values as they are drawn?

I do wish Raspberry Pi foundation would reinstate OpenVG back into the latest OS versions of RPI 4.

Thanks for looking
Steve

Return to “Beginners”