Add soc push event every 10% charge progress (#2337)

This commit is contained in:
andig 2022-01-20 19:40:49 +01:00 • committed by GitHub
parent 9bb68bd819
commit 479377f0d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 86 additions and 3 deletions

29
core/progress.go Normal file
View file

@ -0,0 +1,29 @@
package core
type Progress struct {
min, step, current float64
}
func NewProgress(min, step float64) *Progress {
return &Progress{
min: min,
step: step,
current: min,
}
}
func (p *Progress) NextStep(value float64) bool {
if value >= p.current {
for p.current <= value {
p.current += p.step
}
return true
}
return false
}
func (p *Progress) Reset() {
p.current = p.min
}