Compare commits

..

4 Commits

Author SHA1 Message Date
Cameron Fleming ce54d10129 fix: Don't wake up the display if it's turned off 2025-01-28 22:13:06 +00:00
Cameron Fleming 8071f81310 fix: wakeDisplay() doesn't need to stop the tickers
The tickers only need to be reset, if they're disabled, they won't have
been started.
2025-01-28 22:00:23 +00:00
Cameron Fleming 9896eba02a fix(display): Don't attempt to start the tickers if the display is disabled
If max_brightness is zero, then there's no point in trying to dim it (or
turn it off...)
2025-01-28 21:49:26 +00:00
Cameron Fleming f5035f28c9 chore: fix some start-up timing issues 2025-01-28 20:45:55 +00:00
1 changed files with 18 additions and 10 deletions

View File

@ -157,20 +157,21 @@ func wakeDisplay(force bool) {
return return
} }
// Don't try to wake up if the display is turned off.
if config.DisplayMaxBrightness == 0 {
return
}
err := setDisplayBrightness(config.DisplayMaxBrightness) err := setDisplayBrightness(config.DisplayMaxBrightness)
if err != nil { if err != nil {
fmt.Printf("display wake failed, %s\n", err) fmt.Printf("display wake failed, %s\n", err)
} }
if config.DisplayDimAfterSec == 0 { if config.DisplayDimAfterSec != 0 {
dimTicker.Stop()
} else {
dimTicker.Reset(time.Duration(config.DisplayDimAfterSec) * time.Second) dimTicker.Reset(time.Duration(config.DisplayDimAfterSec) * time.Second)
} }
if config.DisplayOffAfterSec == 0 { if config.DisplayOffAfterSec != 0 {
offTicker.Stop()
} else {
offTicker.Reset(time.Duration(config.DisplayOffAfterSec) * time.Second) offTicker.Reset(time.Duration(config.DisplayOffAfterSec) * time.Second)
} }
backlightState = 0 backlightState = 0
@ -209,8 +210,15 @@ func watchTsEvents() {
// option has the value set to zero, but time.NewTicker only accept positive values. // option has the value set to zero, but time.NewTicker only accept positive values.
func startBacklightTickers() { func startBacklightTickers() {
LoadConfig() LoadConfig()
// Don't start the tickers if the display is switched off.
// Set the display to off if that's the case.
if config.DisplayMaxBrightness == 0 {
setDisplayBrightness(0)
return
}
if dimTicker == nil && config.DisplayDimAfterSec != 0 { if dimTicker == nil && config.DisplayDimAfterSec != 0 {
fmt.Printf("display: dim_ticker has started.") fmt.Printf("display: dim_ticker has started\n")
dimTicker = time.NewTicker(time.Duration(config.DisplayDimAfterSec) * time.Second) dimTicker = time.NewTicker(time.Duration(config.DisplayDimAfterSec) * time.Second)
defer dimTicker.Stop() defer dimTicker.Stop()
@ -225,7 +233,7 @@ func startBacklightTickers() {
} }
if offTicker == nil && config.DisplayOffAfterSec != 0 { if offTicker == nil && config.DisplayOffAfterSec != 0 {
fmt.Printf("display: off_ticker has started.") fmt.Printf("display: off_ticker has started\n")
offTicker = time.NewTicker(time.Duration(config.DisplayOffAfterSec) * time.Second) offTicker = time.NewTicker(time.Duration(config.DisplayOffAfterSec) * time.Second)
defer offTicker.Stop() defer offTicker.Stop()
@ -248,9 +256,9 @@ func init() {
updateStaticContents() updateStaticContents()
displayInited = true displayInited = true
fmt.Println("display inited") fmt.Println("display inited")
wakeDisplay(false)
requestDisplayUpdate()
startBacklightTickers() startBacklightTickers()
wakeDisplay(true)
requestDisplayUpdate()
}() }()
go watchTsEvents() go watchTsEvents()