mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Merge pull request #154 from Ebullioscopic/revamp/essentials
BugFix: Brightness Flash problem
This commit is contained in:
commit
ebc8482cbf
2 changed files with 17 additions and 2 deletions
|
|
@ -6,7 +6,7 @@ import Darwin
|
|||
final class MemoryUsageMonitor {
|
||||
static let shared = MemoryUsageMonitor()
|
||||
|
||||
private let thresholdBytes: UInt64 = 300 * 1_024 * 1_024
|
||||
private let thresholdBytes: UInt64 = 700 * 1_024 * 1_024
|
||||
private let pollInterval: TimeInterval = 8 // Clamp within 5-10 seconds to limit battery impact
|
||||
private let restartCooldown: TimeInterval = 300
|
||||
private let logSampleInterval: TimeInterval = 300
|
||||
|
|
|
|||
|
|
@ -475,7 +475,9 @@ final class SystemBrightnessController {
|
|||
}
|
||||
|
||||
func adjust(by delta: Float) {
|
||||
setBrightness(currentBrightness + delta)
|
||||
// Refresh baseline to avoid jumping if auto-brightness changed the level.
|
||||
syncWithSystemBrightnessIfNeeded()
|
||||
setBrightness(lastEmittedBrightness + delta)
|
||||
}
|
||||
|
||||
func setBrightness(_ value: Float) {
|
||||
|
|
@ -504,9 +506,22 @@ final class SystemBrightnessController {
|
|||
emitBrightnessChange(value: brightness)
|
||||
}
|
||||
|
||||
private func syncWithSystemBrightnessIfNeeded() {
|
||||
// Align our internal baseline with the actual system brightness so that
|
||||
// subsequent adjustments apply deltas from the true value (important when
|
||||
// auto-brightness has changed the level behind our back).
|
||||
let systemLevel = currentBrightness
|
||||
if abs(systemLevel - lastEmittedBrightness) > 0.001 {
|
||||
emitBrightnessChange(value: systemLevel)
|
||||
}
|
||||
}
|
||||
|
||||
private func beginBrightnessAnimation(to target: Float) {
|
||||
brightnessAnimationTimer?.invalidate()
|
||||
|
||||
// Refresh baseline from system in case auto-brightness adjusted it.
|
||||
syncWithSystemBrightnessIfNeeded()
|
||||
|
||||
let start = lastEmittedBrightness
|
||||
if abs(start - target) <= 0.0005 {
|
||||
applyBrightness(target)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue