Documentation
¶
Index ¶
- Constants
- type DriveType
- type PhysicalMonitor
- func (m *PhysicalMonitor) CapabilitiesRequestAndCapabilitiesReply() (info string, err error)
- func (m *PhysicalMonitor) Degauss() error
- func (m *PhysicalMonitor) GetBrightness() (minValue, current, maxValue int, err error)
- func (m *PhysicalMonitor) GetCapabilities() (capabilities, supportedColorTemperatures int, err error)
- func (m *PhysicalMonitor) GetCapabilitiesStringLength() (size int, err error)
- func (m *PhysicalMonitor) GetColorTemperature() (current int, err error)
- func (m *PhysicalMonitor) GetContrast() (minValue, current, maxValue int, err error)
- func (m *PhysicalMonitor) GetDisplayAreaPosition(positionType PositionType) (minValue, current, maxValue int, err error)
- func (m *PhysicalMonitor) GetDisplayAreaSize(sizeType SizeType) (minValue, current, maxValue int, err error)
- func (m *PhysicalMonitor) GetRedGreenOrBlueDrive(driveType DriveType) (minValue, current, maxValue int, err error)
- func (m *PhysicalMonitor) GetRedGreenOrBlueGain(driveType DriveType) (minValue, current, maxValue int, err error)
- func (m *PhysicalMonitor) GetTechnologyType() (value int, err error)
- func (m *PhysicalMonitor) GetTimingReport() (*TimingReport, error)
- func (m *PhysicalMonitor) GetVCPFeatureAndVCPFeatureReply(coder vcp.Coder) (current, maxValue int, err error)
- func (m *PhysicalMonitor) RestoreFactoryColorDefaults() error
- func (m *PhysicalMonitor) RestoreFactoryDefaults() error
- func (m *PhysicalMonitor) SaveCurrentMonitorSettings() error
- func (m *PhysicalMonitor) SaveCurrentSettings() error
- func (m *PhysicalMonitor) SetBrightness(value int) error
- func (m *PhysicalMonitor) SetContrast(value int) error
- func (m *PhysicalMonitor) SetVCPFeature(code vcp.VCP) error
- type PositionType
- type RECT
- type SizeType
- type SystemMonitor
- type TimingReport
Examples ¶
Constants ¶
const ( EnumDisplayMonitors = "EnumDisplayMonitors" GetMonitorInfoA = "GetMonitorInfoA" GetMonitorInfoW = "GetMonitorInfoW" )
const ( GetMonitorBrightness = "GetMonitorBrightness" GetMonitorCapabilities = "GetMonitorCapabilities" GetMonitorColorTemperature = "GetMonitorColorTemperature" GetMonitorContrast = "GetMonitorContrast" GetMonitorDisplayAreaPosition = "GetMonitorDisplayAreaPosition" GetMonitorDisplayAreaSize = "GetMonitorDisplayAreaSize" GetMonitorRedGreenOrBlueDrive = "GetMonitorRedGreenOrBlueDrive" GetMonitorRedGreenOrBlueGain = "GetMonitorRedGreenOrBlueGain" GetMonitorTechnologyType = "GetMonitorTechnologyType" DegaussMonitor = "DegaussMonitor" RestoreMonitorFactoryColorDefaults = "RestoreMonitorFactoryColorDefaults" RestoreMonitorFactoryDefaults = "RestoreMonitorFactoryDefaults" SaveCurrentMonitorSettings = "SaveCurrentMonitorSettings" )
const ( SetMonitorBrightness = "SetMonitorBrightness" SetMonitorContrast = "SetMonitorContrast" )
See microsoft-windows doc Set Monitor With HighLevel
const ( SetMonitorColorTemperature = "SetMonitorColorTemperature" SetMonitorDisplayAreaPosition = "SetMonitorDisplayAreaPosition" SetMonitorDisplayAreaSize = "SetMonitorDisplayAreaSize" SetMonitorRedGreenOrBlueDrive = "SetMonitorRedGreenOrBlueDrive" SetMonitorRedGreenOrBlueGain = "SetMonitorRedGreenOrBlueGain" )
Set Monitor With HighLevel
See microsoft-windows doc
Deprecated: cannot use preset values because Golang does not support the 'enum' type.
eg: compared to *PhysicalMonitor .call(SetMonitorColorTemperature, 4000K), it is better: *PhysicalMonitor.SetVCPFeature(vcp.SelectColorPreset.Set4000K)
const ( GetCapabilitiesStringLength = "GetCapabilitiesStringLength" CapabilitiesRequestAndCapabilitiesReply = "CapabilitiesRequestAndCapabilitiesReply" GetTimingReport = "GetTimingReport" SaveCurrentSettings = "SaveCurrentSettings" GetVCPFeatureAndVCPFeatureReply = "GetVCPFeatureAndVCPFeatureReply" SetVCPFeature = "SetVCPFeature" )
const ( DestroyPhysicalMonitor = "DestroyPhysicalMonitor" DestroyPhysicalMonitors = "DestroyPhysicalMonitors" GetNumberOfPhysicalMonitorsFromHMONITOR = "GetNumberOfPhysicalMonitorsFromHMONITOR" GetNumberOfPhysicalMonitorsFromIDirect3DDevice9 = "GetNumberOfPhysicalMonitorsFromIDirect3DDevice9" GetPhysicalMonitorsFromHMONITOR = "GetPhysicalMonitorsFromHMONITOR" GetPhysicalMonitorsFromIDirect3DDevice9 = "GetPhysicalMonitorsFromIDirect3DDevice9" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PhysicalMonitor ¶
type PhysicalMonitor struct {
// contains filtered or unexported fields
}
PhysicalMonitor Contains a handle and text description corresponding to a physical monitor.
func NewPhysicalMonitor ¶
func NewPhysicalMonitor(m *SystemMonitor) (*PhysicalMonitor, error)
NewPhysicalMonitor Retrieves the physical monitors associated with an HMONITOR monitor handle.
[in] hMonitor A monitor handle. PhysicalMonitor handles are returned by several Multiple Display PhysicalMonitor functions, including EnumDisplayMonitors and MonitorFromWindow, which are part of the graphics device interface (GDI).
[out] pPhysicalMonitorArray Pointer to an array of PHYSICAL_MONITOR structures. The caller must allocate the array.
Example ¶
package main import ( "fmt" "github.com/niluan304/ddcci" ) func main() { monitors, err := ddcci.NewSystemMonitors() if err != nil { panic(err) } m, err := ddcci.NewPhysicalMonitor(&monitors[0]) if err != nil { panic(err) } fmt.Println(m != nil) }
Output: true
func PhysicalMonitor0 ¶
func PhysicalMonitor0() *PhysicalMonitor
PhysicalMonitor0 return the first PhysicalMonitor in your Windows computer, so your computer must be connected to a monitor.
it is short name: NewPhysicalMonitor(NewSystemMonitors()[0]), if err != nil during in the function, the result will be nil
Example ¶
package main import ( "fmt" "github.com/niluan304/ddcci" ) func main() { m := ddcci.PhysicalMonitor0() fmt.Println(m != nil) }
Output: true
func (*PhysicalMonitor) CapabilitiesRequestAndCapabilitiesReply ¶
func (m *PhysicalMonitor) CapabilitiesRequestAndCapabilitiesReply() (info string, err error)
CapabilitiesRequestAndCapabilitiesReply Retrieves a string describing a monitor's capabilities.
[out] pszASCIICapabilitiesString Pointer to a buffer that receives the monitor's capabilities string. The caller must allocate this buffer.
func (*PhysicalMonitor) Degauss ¶
func (m *PhysicalMonitor) Degauss() error
Degauss Degausses a monitor. Degaussing improves a monitor's image quality and color fidelity by demagnetizing the monitor.
func (*PhysicalMonitor) GetBrightness ¶
func (m *PhysicalMonitor) GetBrightness() (minValue, current, maxValue int, err error)
GetBrightness Retrieves a monitor's minimum, maximum, and current brightness settings.
[out] pdwMinimumBrightness Receives the monitor's minimum brightness.
[out] pdwCurrentBrightness Receives the monitor's current brightness.
[out] pdwMaximumBrightness Receives the monitor's maximum brightness.
Example ¶
package main import ( "fmt" "github.com/niluan304/ddcci" ) func main() { m := ddcci.PhysicalMonitor0() minValue, current, maxValue, err := m.GetBrightness() if err != nil { panic(err) } fmt.Println(minValue) fmt.Println(maxValue) fmt.Println(0 <= current && current <= 100) }
Output: 0 100 true
func (*PhysicalMonitor) GetCapabilities ¶
func (m *PhysicalMonitor) GetCapabilities() (capabilities, supportedColorTemperatures int, err error)
GetCapabilities Retrieves the configuration capabilities of a monitor. Call this function to find out which high-level monitor configuration functions are supported by the monitor.
[out] pdwMonitorCapabilities Receives a bitwise OR of capabilities flags. See Remarks.
[out] pdwSupportedColorTemperatures Receives a bitwise OR of color temperature flags. See Remarks.
func (*PhysicalMonitor) GetCapabilitiesStringLength ¶
func (m *PhysicalMonitor) GetCapabilitiesStringLength() (size int, err error)
GetCapabilitiesStringLength
Retrieves the length of a monitor's capabilities string.
[out] pdwCapabilitiesStringLengthInCharacters Receives the length of the capabilities string, in characters, including the terminating null character.
func (*PhysicalMonitor) GetColorTemperature ¶
func (m *PhysicalMonitor) GetColorTemperature() (current int, err error)
GetColorTemperature Retrieves a monitor's current color temperature.
[out] pctCurrentColorTemperature Receives the monitor's current color temperature, specified as a member of the MC_COLOR_TEMPERATURE enumeration.
func (*PhysicalMonitor) GetContrast ¶
func (m *PhysicalMonitor) GetContrast() (minValue, current, maxValue int, err error)
GetContrast Retrieves a monitor's minimum, maximum, and current contrast settings.
[out] pdwMinimumContrast Receives the monitor's minimum contrast.
[out] pdwCurrentContrast Receives the monitor's current contrast.
[out] pdwMaximumContrast Receives the monitor's maximum contrast.
Example ¶
package main import ( "fmt" "github.com/niluan304/ddcci" ) func main() { m := ddcci.PhysicalMonitor0() minValue, current, maxValue, err := m.GetContrast() if err != nil { panic(err) } fmt.Println(minValue) fmt.Println(maxValue) fmt.Println(0 <= current && current <= 100) }
Output: 0 100 true
func (*PhysicalMonitor) GetDisplayAreaPosition ¶
func (m *PhysicalMonitor) GetDisplayAreaPosition(positionType PositionType) (minValue, current, maxValue int, err error)
GetDisplayAreaPosition Retrieves a monitor's minimum, maximum, and current horizontal or vertical position.
[in] ptPositionType
A member of the MC_POSITION_TYPE enumeration, specifying whether to retrieve the horizontal position or the vertical position.
[out] pdwMinimumPosition Receives the minimum horizontal or vertical position.
[out] pdwCurrentPosition Receives the current horizontal or vertical position.
[out] pdwMaximumPosition Receives the maximum horizontal or vertical position.
func (*PhysicalMonitor) GetDisplayAreaSize ¶
func (m *PhysicalMonitor) GetDisplayAreaSize(sizeType SizeType) (minValue, current, maxValue int, err error)
GetDisplayAreaSize
[out] pdwMinimumWidthOrHeight Receives the minimum width or height.
[out] pdwCurrentWidthOrHeight Receives the current width or height.
[out] pdwMaximumWidthOrHeight Receives the maximum width or height.
func (*PhysicalMonitor) GetRedGreenOrBlueDrive ¶
func (m *PhysicalMonitor) GetRedGreenOrBlueDrive(driveType DriveType) (minValue, current, maxValue int, err error)
GetRedGreenOrBlueDrive Retrieves a monitor's red, green, or blue drive value.
[in] dtDriveType A member of the McDriveType enumeration, specifying whether to retrieve the red, green, or blue drive value.
[out] pdwMinimumDrive Receives the minimum red, green, or blue drive value.
[out] pdwCurrentDrive Receives the current red, green, or blue drive value.
[out] pdwMaximumDrive Receives the maximum red, green, or blue drive value.
func (*PhysicalMonitor) GetRedGreenOrBlueGain ¶
func (m *PhysicalMonitor) GetRedGreenOrBlueGain(driveType DriveType) (minValue, current, maxValue int, err error)
GetRedGreenOrBlueGain Retrieves a monitor's red, green, or blue gain value.
[in] dtDriveType A member of the McDriveType enumeration, specifying whether to retrieve the red, green, or blue drive value.
[out] pdwMinimumGain Receives the minimum red, green, or blue gain value.
[out] pdwCurrentGain Receives the current red, green, or blue gain value.
[out] pdwMaximumGain Receives the maximum red, green, or blue gain value.
func (*PhysicalMonitor) GetTechnologyType ¶
func (m *PhysicalMonitor) GetTechnologyType() (value int, err error)
GetTechnologyType
[out] pdtyDisplayTechnologyType Receives the technology type, specified as a member of the MC_DISPLAY_TECHNOLOGY_TYPE enumeration.
func (*PhysicalMonitor) GetTimingReport ¶
func (m *PhysicalMonitor) GetTimingReport() (*TimingReport, error)
GetTimingReport Retrieves a monitor's horizontal and vertical synchronization frequencies.
[out] pmtrMonitorTimingReport Pointer to an TimingReport structure that receives the timing information.
func (*PhysicalMonitor) GetVCPFeatureAndVCPFeatureReply ¶
func (m *PhysicalMonitor) GetVCPFeatureAndVCPFeatureReply(coder vcp.Coder) (current, maxValue int, err error)
GetVCPFeatureAndVCPFeatureReply Retrieves the current value, maximum value, and code type of Virtual Control Panel (VCP) code for a monitor.
[in] vcpCode VCP code to query. The VCP codes are Include the VESA PhysicalMonitor Control Command Set (MCCS) standard, versions 1.0 and 2.0. This parameter must specify a continuous or non-continuous VCP, or a vendor-specific code. It should not be a table control code.
[out] pdwCurrentValue Receives the current value of the VCP code. This parameter can be NULL.
[out] pdwMaximumValue If vcpCode specifies a continuous VCP code, this parameter receives the maximum value of the VCP code. If vcpCode specifies a non-continuous VCP code, the value received in this parameter is undefined. This parameter can be NULL.
Example ¶
package main import ( "fmt" "github.com/niluan304/ddcci" "github.com/niluan304/ddcci/vcp" ) func main() { m := ddcci.PhysicalMonitor0() current, maxValue, err := m.GetVCPFeatureAndVCPFeatureReply(vcp.Brightness) if err != nil { panic(err) } fmt.Println(maxValue) fmt.Println(0 <= current && current <= 100) }
Output: 100 true
func (*PhysicalMonitor) RestoreFactoryColorDefaults ¶
func (m *PhysicalMonitor) RestoreFactoryColorDefaults() error
RestoreFactoryColorDefaults Restores a monitor's color settings to their factory defaults.
func (*PhysicalMonitor) RestoreFactoryDefaults ¶
func (m *PhysicalMonitor) RestoreFactoryDefaults() error
RestoreFactoryDefaults Restores a monitor's settings to their factory defaults.
func (*PhysicalMonitor) SaveCurrentMonitorSettings ¶
func (m *PhysicalMonitor) SaveCurrentMonitorSettings() error
SaveCurrentMonitorSettings Saves the current monitor settings to the display's nonvolatile storage.
func (*PhysicalMonitor) SaveCurrentSettings ¶
func (m *PhysicalMonitor) SaveCurrentSettings() error
SaveCurrentSettings Saves the current monitor settings to the display's nonvolatile storage.
note: This low-level function is identical to the high-level function SaveCurrentMonitorSettings.
func (*PhysicalMonitor) SetBrightness ¶
func (m *PhysicalMonitor) SetBrightness(value int) error
SetBrightness Sets a monitor's brightness value. Increasing the brightness value makes the display on the monitor brighter, and decreasing it makes the display dimmer.
[in] dwNewBrightness Brightness value. To get the monitor's minimum and maximum brightness values, call GetMonitorBrightness.
It is same as PhysicalMonitor.SetVCPFeature(vcp.Brightness. Value(value))
Example ¶
package main import ( "fmt" "time" "github.com/niluan304/ddcci" "github.com/niluan304/ddcci/vcp" ) func main() { m := ddcci.PhysicalMonitor0() minValue, origin, maxValue, err := m.GetBrightness() if err != nil { panic(err) } defer func() { time.Sleep(time.Second) m.SetVCPFeature(vcp.Brightness.Value(origin)) }() m.SetBrightness(50) _, current, _, _ := m.GetBrightness() fmt.Println(minValue) fmt.Println(maxValue) fmt.Println(current) }
Output: 0 100 50
func (*PhysicalMonitor) SetContrast ¶
func (m *PhysicalMonitor) SetContrast(value int) error
SetContrast Sets a monitor's contrast value.
[in] value Contrast value. To get the monitor's minimum and maximum contrast values, call GetMonitorContrast.
It is same as PhysicalMonitor.SetVCPFeature(vcp.Contrast. Value(value))
Example ¶
package main import ( "fmt" "time" "github.com/niluan304/ddcci" "github.com/niluan304/ddcci/vcp" ) func main() { m := ddcci.PhysicalMonitor0() minValue, origin, maxValue, err := m.GetContrast() if err != nil { panic(err) } defer func() { time.Sleep(time.Second) m.SetVCPFeature(vcp.Contrast.Value(origin)) }() m.SetContrast(50) _, current, _, _ := m.GetContrast() fmt.Println(minValue) fmt.Println(maxValue) fmt.Println(current) }
Output: 0 100 50
func (*PhysicalMonitor) SetVCPFeature ¶
func (m *PhysicalMonitor) SetVCPFeature(code vcp.VCP) error
SetVCPFeature Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR or GetPhysicalMonitorsFromIDirect3DDevice9.
[in] vcpCode VCP code to set. The VCP codes are defined in the VESA PhysicalMonitor Control Command Set (MCCS) standard, version 1.0 and 2.0. This parameter must specify a continuous or non-continuous VCP, or a vendor-specific code. It should not be a table control code.
[in] value Value of the VCP code.
[out] If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. To get extended error information, call GetLastError.
Example ¶
package main import ( "fmt" "time" "github.com/niluan304/ddcci" "github.com/niluan304/ddcci/vcp" ) func main() { m := ddcci.PhysicalMonitor0() origin, maxValue, err := m.GetVCPFeatureAndVCPFeatureReply(vcp.Brightness) if err != nil { panic(err) } defer func() { time.Sleep(time.Second) m.SetVCPFeature(vcp.Brightness.Value(origin)) }() m.SetVCPFeature(vcp.Brightness.Value(50)) current, _, _ := m.GetVCPFeatureAndVCPFeatureReply(vcp.Brightness) fmt.Println(maxValue) fmt.Println(current) }
Output: 100 50
type PositionType ¶
type PositionType int
const ( HorizontalPosition PositionType = iota VerticalPosition )
type RECT ¶
The RECT structure defines a rectangle by the coordinates of its upper-left and lower-right corners.
type SystemMonitor ¶
type SystemMonitor struct {
// contains filtered or unexported fields
}
SystemMonitor
func NewSystemMonitors ¶
func NewSystemMonitors() ([]SystemMonitor, error)
NewSystemMonitors The EnumDisplayMonitors function enumerates display monitors (including invisible pseudo-monitors associated with the mirroring drivers) that intersect a region formed by the intersection of a specified clipping rectangle and the visible region of a device context.
EnumDisplayMonitors calls an application-defined MonitorEnumProc callback function once for each monitor that is enumerated. Note that GetSystemMetrics (SM_CMONITORS) counts only the display monitors.
A value of type MONITORENUMPROC is a pointer to a MonitorEnumProc function.
func (*SystemMonitor) GetNumberOfPhysicalMonitorsFromHMONITOR ¶
func (m *SystemMonitor) GetNumberOfPhysicalMonitorsFromHMONITOR() (num int, err error)
GetNumberOfPhysicalMonitorsFromHMONITOR Retrieves the number of physical monitors associated with an HMONITOR monitor handle. Call this function before calling GetPhysicalMonitorsFromHMONITOR.
[out] num Receives the number of physical monitors associated with the monitor handle.
type TimingReport ¶
type TimingReport struct { // The monitor's horizontal synchronization frequency in Hz. HorizontalFrequency uint32 // The monitor's vertical synchronization frequency in Hz. VerticalFrequency uint32 // Timing status byte. // For more information about this value, // see the Display Data Channel Command Interface (DDC/CI) standard. // // 4.7 Get Timing Report & Timing Message // Bit 7 = 1 Sync.Freq. out of range // Bit 6 = 1 Unstable count // Bit 5-2 Reserved, shall be set to 0 // Bit 1 = 1 Positive Horizontal sync polarity // Bit 1 = 0 Negative Horizontal sync polarity // Bit 0 = 1 Positive Vertical sync polarity // Bit 0 = 0 Negative Vertical sync polarity TimingStatus byte }
TimingReport Contains information from a monitor's timing report.