Brightness control over HDMI via DCC/CI?

1.1k views Asked by At

I'm looking for a way to adjust the brightness of a display, which is connected via HDMI to a Dragonboard 410c with Windows IoT Core installed. I read that DCC/CI can control the brightness over HDMI, tested that already with an OpenSource tool called "Monitorian" on my Windows 10 machine, which does work. This tool is written in C# but relies on "DllImport", with which i absolutely have no experience. So the question is, is it possible, to control the brightness from my UWP code somehow?

Using Windows 10 IoT Core API Porting Tool for Monitorian

Parsing Users\Dev\Desktop\mon\Monitorian.exe

Unbehandelte Ausnahme: System.DllNotFoundException: Die DLL "SQLite.Interop.dll": Das angegebene Modul wurde nicht gefunden. (Ausnahme von HRESULT: 0x8007007E) kann nicht geladen werden.
   bei System.Data.SQLite.UnsafeNativeMethods.sqlite3_config_none(SQLiteConfigOpsEnum op)
   bei System.Data.SQLite.SQLite3.StaticIsInitialized()
   bei System.Data.SQLite.SQLiteLog.Initialize()
   bei System.Data.SQLite.SQLiteConnection..ctor(String connectionString, Boolean parseViaFramework)
   bei System.Data.SQLite.SQLiteConnection..ctor(String connectionString)
   bei IoTAPIPortingTool.Program.ProcessLines(String[] lines, Boolean isUAP, String filename, StringBuilder outputBuilder) in C:\Users\Dev\Desktop\iot-utilities-master\IoTAPIPortingTool\Program.cs:Zeile 213.
   bei IoTAPIPortingTool.Program.Main(String[] args) in C:\Users\Dev\Desktop\iot-utilities-master\IoTAPIPortingTool\Program.cs:Zeile 498.
1

There are 1 answers

5
Eric Cartman On

Fork Monitorian project, it's in GitHub and already has P/Invoke you're looking for !

Check that out:

https://github.com/emoacht/Monitorian/search?q=dllimport

Brightness functions are readily available:

    [DllImport("Dxva2.dll", SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    private static extern bool GetMonitorBrightness(
        SafePhysicalMonitorHandle hMonitor,
        out uint pdwMinimumBrightness,
        out uint pdwCurrentBrightness,
        out uint pdwMaximumBrightness);

    [DllImport("Dxva2.dll", SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    private static extern bool SetMonitorBrightness(
        SafePhysicalMonitorHandle hMonitor,
        uint dwNewBrightness);

There should be little changes needed if any for you to re-use the Monitorian.Core project on your application as well.

And as others said, P/Invoke isn't that difficult plus now you have a pretty good example.

Caveat: not sure about the availability of these APIs under UWP however.

Edit:

No support under UWP:

Minimum supported client Windows Vista [desktop apps only]

https://learn.microsoft.com/en-us/windows/win32/api/highlevelmonitorconfigurationapi/nf-highlevelmonitorconfigurationapi-getmonitorbrightness

What about trying the other way around then?

Host WinRT XAML controls in desktop apps (XAML Islands)

Edit:

There isn't a list of what's Win32 supported under IoT but there's a tool instead:

Windows 10 IoT Core API Porting Tool

Windows 10 IoT Core only supports a subset of the Win32 and .NET API surface area available on various prior versions of Windows. This tool will scan your binaries and give you a report of the APIs these binaries use that aren't available and give suggestions for possible replacements. This will both help with estimating the cost of a port to IoT Core as well as help you along the way.

So give it a try and see what it says.