Skip to content

Commit

Permalink
Updated time of day adjustment progress calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
xanderfrangos committed Jan 9, 2024
1 parent 34a9623 commit c9bad2d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -3766,20 +3766,27 @@ function getCurrentAdjustmentEventLERP() {
}

// Calculate 0-1 percentage of progress
const percent = (next.value - nowValue) / (next.value - current.value)
const lerpValues = {
next: next.value - current.value,
current: current.value - current.value,
now: nowValue - current.value
}
lerpValues.progress = lerpValues.next - lerpValues.now
lerpValues.end = lerpValues.next
lerpValues.percent = 1 - (lerpValues.progress / lerpValues.end)

// Generate result depending on if displays are linked
if (settings.adjustmentTimeIndividualDisplays) {
const keys = Object.keys(next.monitors)
const monitors = Object.assign(current.monitors)
keys.forEach(key => {
if (monitors[key] > -1) {
monitors[key] = Math.round(Utils.lerp(current.monitors[key], next.monitors[key], percent))
monitors[key] = Math.round(Utils.lerp(current.monitors[key], next.monitors[key], lerpValues.percent))
}
})
return monitors
} else {
return Math.round(Utils.lerp(current.brightness, next.brightness, percent))
return Math.round(Utils.lerp(current.brightness, next.brightness, lerpValues.percent))
}
} catch (e) {
console.log("Error generating Adjustment Time LERP", e)
Expand Down

0 comments on commit c9bad2d

Please sign in to comment.