displayController

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

README

██████╗ ██╗███████╗██████╗ ██╗      █████╗ ██╗   ██╗ ██████╗ ██████╗ ███╗   ██╗████████╗██████╗  ██████╗ ██╗     ██╗     ███████╗██████╗ 
██╔══██╗██║██╔════╝██╔══██╗██║     ██╔══██╗╚██╗ ██╔╝██╔════╝██╔═══██╗████╗  ██║╚══██╔══╝██╔══██╗██╔═══██╗██║     ██║     ██╔════╝██╔══██╗
██║  ██║██║███████╗██████╔╝██║     ███████║ ╚████╔╝ ██║     ██║   ██║██╔██╗ ██║   ██║   ██████╔╝██║   ██║██║     ██║     █████╗  ██████╔╝
██║  ██║██║╚════██║██╔═══╝ ██║     ██╔══██║  ╚██╔╝  ██║     ██║   ██║██║╚██╗██║   ██║   ██╔══██╗██║   ██║██║     ██║     ██╔══╝  ██╔══██╗
██████╔╝██║███████║██║     ███████╗██║  ██║   ██║   ╚██████╗╚██████╔╝██║ ╚████║   ██║   ██║  ██║╚██████╔╝███████╗███████╗███████╗██║  ██║
╚═════╝ ╚═╝╚══════╝╚═╝     ╚══════╝╚═╝  ╚═╝   ╚═╝    ╚═════╝ ╚═════╝ ╚═╝  ╚═══╝   ╚═╝   ╚═╝  ╚═╝ ╚═════╝ ╚══════╝╚══════╝╚══════╝╚═╝  ╚═╝

Go Reference

中文说明

  • Call the low-level library of the system to access the display monitor DDC/CI channel and interface
  • Get the display driver information, such as display driver name, current display location
  • Get the value of the current parameter and the range of the current parameters, such as brightness, sharpness, contrast, red, green, blue, and other custom query parameters
  • Set the value of the display parameter, such as brightness, sharpness, contrast, red, green, blue, and other custom settings parameters
  • Interacting with the display, such as setting the displayed input source, controlling the displayed power mode

Install

go get github.com/gek64/displayController

go doc

Example

package main

import (
	"fmt"
	"github.com/gek64/displayController"
)

func main() {
	// Get the system display devices
	compositeMonitors, err := GetCompositeMonitors()
	if err != nil {
		log.Fatal(err)
	}

	// Travel in all display devices one by one
	for i, compositeMonitor := range compositeMonitors {
		fmt.Printf("Monitor No.%d\n", i)
		fmt.Printf("PhysicalInfo:%v\n", compositeMonitor.PhysicalInfo)
		fmt.Printf("SysInfo:%v\n", compositeMonitor.SysInfo)

		// Get the current and maximum value of the brightness parameters of the physical display
		currentValue, _, err := GetVCPFeatureAndVCPFeatureReply(compositeMonitor.PhysicalInfo.Handvaluele, Brightness)
		if err != nil {
			t.Fatal(err)
		}

		// Set the brightness of the current display to current value
		err = SetVCPFeature(compositeMonitor.PhysicalInfo.Handle, Brightness, currentValue)
		if err != nil {
			t.Fatal(err)
		}
	}
}

FAQ

What operating system does this module support?

  • It only supports Windows now, and support systems such as macOS, Linux kernel system and freeBSD will be considered in the future.

Get the display driver parameter normally, but the display monitor parameter cannot be obtained and controlled.

  • This program uses the VESA DDC/CI Display communication standard protocol which release in 1998 to exchange data with physical display monitors. Most of the modern display supports and enables this feature by default, If you encounter this problem, please confirm whether the DDC/CI function has been opened in OSD menu, or contact your display manufacturer to get more relevant information

What other parameters can be customized?

How to find parameters supported by my own display monitor?

  • If the monitor does not support a certain parameter, the error will be returned when calling the command. You can use the error information to determine whether the monitor supports a certain parameter
  • You can use this tool to check which parameters that your monitor supported ControlMyMonitor

My monitor can't find the option to control DDC/CI

  • I've collected some uncommon ways to enable this feature for some well-known monitors, check instructions
  • Please consult the manufacturer of your monitor for instructions

License

  • GPL-3.0 License
  • See LICENSE for details

Credits

Documentation

Index

Constants

View Source
const (
	Brightness            byte = 0x10
	Contrast              byte = 0x12
	Red                   byte = 0x16
	Green                 byte = 0x18
	Blue                  byte = 0x1a
	InputSource           byte = 0x60
	Volume                byte = 0x62
	Sharpness             byte = 0x87
	ColorSaturation       byte = 0x8a
	MuteORScreenBlank     byte = 0x8d
	HorizontalFrequency   byte = 0xac
	VerticalFrequency     byte = 0xae
	DisplayTechnologyType byte = 0xb6
	DisplayUsageTime      byte = 0xc0
	PowerMode             byte = 0xd6
)

https://www.hattelandtechnology.com/hubfs/pdf/misc/doc101681-1_8_and_13inch_dis_ddc_control.pdf https://www.ddcutil.com/vcpinfo_output/

Variables

This section is empty.

Functions

func BrightnessTest

func BrightnessTest(hPhysicalMonitor syscall.Handle) (err error)

BrightnessTest 亮度循环测试

func GetMonitorBrightness added in v1.0.2

func GetMonitorBrightness(hPhysicalMonitor syscall.Handle) (currentValue int, minimumValue int, maximumValue int, err error)

GetMonitorBrightness 获取显示器亮度

func GetMonitorContrast added in v1.0.2

func GetMonitorContrast(hPhysicalMonitor syscall.Handle) (currentValue int, minimumValue int, maximumValue int, err error)

GetMonitorContrast 获取显示器对比度

func GetMonitorNumberFromHandle

func GetMonitorNumberFromHandle(hMonitor syscall.Handle) (number int32, err error)

GetMonitorNumberFromHandle 获取显示器句柄下的显示器数量

func GetVCPFeatureAndVCPFeatureReply

func GetVCPFeatureAndVCPFeatureReply(hPhysicalMonitor syscall.Handle, bVCPCode byte) (currentValue int, maximumValue int, err error)

GetVCPFeatureAndVCPFeatureReply 获取显示器VCP参数(需要使用 GetPhysicalMonitorInfo 获取到的物理显示器 Handle)

func RestoreMonitorFactoryColorDefaults added in v1.0.2

func RestoreMonitorFactoryColorDefaults(hPhysicalMonitor syscall.Handle) (err error)

RestoreMonitorFactoryColorDefaults 还原显示器出场默认颜色设置

func RestoreRestoreMonitorFactoryDefaults added in v1.0.2

func RestoreRestoreMonitorFactoryDefaults(hPhysicalMonitor syscall.Handle) (err error)

RestoreRestoreMonitorFactoryDefaults 还原显示器出场默认设置

func SetMonitorBrightness added in v1.0.2

func SetMonitorBrightness(hPhysicalMonitor syscall.Handle, value int) (err error)

SetMonitorBrightness 设置显示器亮度

func SetMonitorContrast added in v1.0.2

func SetMonitorContrast(hPhysicalMonitor syscall.Handle, value int) (err error)

SetMonitorContrast 设置显示器对比度

func SetVCPFeature

func SetVCPFeature(hPhysicalMonitor syscall.Handle, bVCPCode byte, value int) (err error)

SetVCPFeature 设置显示器VCP参数

Types

type CompositeMonitorInfo added in v1.0.1

type CompositeMonitorInfo struct {
	PhysicalInfo PhysicalMonitorInfo
	SysInfo      SystemMonitorInfo
}

func GetCompositeMonitors added in v1.0.1

func GetCompositeMonitors() (monitors []CompositeMonitorInfo, err error)

GetCompositeMonitors 获取复合显示器信息

type PhysicalMonitorInfo

type PhysicalMonitorInfo struct {
	Handle      syscall.Handle
	Description string
}

func GetPhysicalMonitor

func GetPhysicalMonitor(hMonitor syscall.Handle) (info PhysicalMonitorInfo, err error)

GetPhysicalMonitor 获取物理显示器信息

type RECT

type RECT struct {
	Left   int32
	Top    int32
	Right  int32
	Bottom int32
}

type SystemMonitorInfo added in v1.0.1

type SystemMonitorInfo struct {
	Handle        syscall.Handle
	DeviceContext syscall.Handle
	RectAngle     RECT
}

func GetSystemMonitors added in v1.0.1

func GetSystemMonitors() (info []SystemMonitorInfo, err error)

GetSystemMonitors 获取所有屏幕设备信息

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL