mirror of
https://github.com/MonitorControl/MonitorControl.git
synced 2026-05-15 14:15:55 -06:00
Merge a7938e91bc into fc19ce2bd2
This commit is contained in:
commit
098e5b0b89
1 changed files with 16 additions and 2 deletions
|
|
@ -486,7 +486,14 @@ class OtherDisplay: Display {
|
|||
}
|
||||
let curveMultiplier = self.getCurveMultiplier(self.readPrefAsInt(key: .curveDDC, for: command))
|
||||
let minDDCValue = Float(self.readPrefAsInt(key: .minDDCOverride, for: command))
|
||||
let maxDDCValue = Float(self.readPrefAsInt(key: .maxDDC, for: command))
|
||||
let maxDDCValue = max(Float(self.readPrefAsInt(key: .maxDDC, for: command)), minDDCValue)
|
||||
guard maxDDCValue > minDDCValue else {
|
||||
var intDDCValue = UInt16(minDDCValue)
|
||||
if from > 0, command == Command.audioSpeakerVolume {
|
||||
intDDCValue = max(1, intDDCValue)
|
||||
}
|
||||
return intDDCValue
|
||||
}
|
||||
let curvedValue = pow(max(min(value, 1), 0), curveMultiplier)
|
||||
let deNormalizedValue = (maxDDCValue - minDDCValue) * curvedValue + minDDCValue
|
||||
var intDDCValue = UInt16(min(max(deNormalizedValue, minDDCValue), maxDDCValue))
|
||||
|
|
@ -499,7 +506,14 @@ class OtherDisplay: Display {
|
|||
func convDDCToValue(for command: Command, from: UInt16) -> Float {
|
||||
let curveMultiplier = self.getCurveMultiplier(self.readPrefAsInt(key: .curveDDC, for: command))
|
||||
let minDDCValue = Float(self.readPrefAsInt(key: .minDDCOverride, for: command))
|
||||
let maxDDCValue = Float(self.readPrefAsInt(key: .maxDDC, for: command))
|
||||
let maxDDCValue = max(Float(self.readPrefAsInt(key: .maxDDC, for: command)), minDDCValue)
|
||||
guard maxDDCValue > minDDCValue else {
|
||||
var value: Float = 0
|
||||
if self.readPrefAsBool(key: .invertDDC, for: command) {
|
||||
value = 1 - value
|
||||
}
|
||||
return max(min(value, 1), 0)
|
||||
}
|
||||
let normalizedValue = ((min(max(Float(from), minDDCValue), maxDDCValue) - minDDCValue) / (maxDDCValue - minDDCValue))
|
||||
let deCurvedValue = pow(normalizedValue, 1.0 / curveMultiplier)
|
||||
var value = deCurvedValue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue