Use tickers instead of time.Sleep(), simplify main loop condition

This commit is contained in:
eleksir
2025-04-07 20:41:01 +03:00
parent 44dbaee87a
commit 4fd0815c1d
8 changed files with 439 additions and 388 deletions

View File

@@ -16,11 +16,10 @@ func (c *MyConfig) UpdateBatteryInfo() {
Batts string
InitialDelay = 100 * time.Millisecond
LoopIterationDelay = 5 * time.Second
Delay = InitialDelay
ticker = time.NewTicker(Delay)
)
Delay := InitialDelay
ticker := time.NewTicker(Delay)
for range ticker.C {
if Delay == InitialDelay {
Delay = LoopIterationDelay
@@ -170,7 +169,5 @@ func (c *MyConfig) UpdateBatteryInfo() {
c.Values.BatteryString = Batts
c.Channels.UpdateReady <- true
}
time.Sleep(5 * time.Second)
}
}