kopia lustrzana https://github.com/cyoung/stratux
Fix #223. Change ticker to 50 ms intervals for future improvements.
rodzic
1be927e672
commit
2f9ce16bfd
|
@ -729,7 +729,7 @@ func updateStatus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update Uptime value
|
// Update Uptime value
|
||||||
globalStatus.Uptime = int64(stratuxClock.Seconds) * 1000
|
globalStatus.Uptime = int64(stratuxClock.Milliseconds)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReplayWriter struct {
|
type ReplayWriter struct {
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
that can be found in the LICENSE file, herein included
|
that can be found in the LICENSE file, herein included
|
||||||
as part of this header.
|
as part of this header.
|
||||||
|
|
||||||
|
Modifications (c) 2016 AvSquirrel (https://github.com/AvSquirrel)
|
||||||
monotonic.go: Create monotonic clock using time.Timer - necessary because of real time clock changes on RPi.
|
monotonic.go: Create monotonic clock using time.Timer - necessary because of real time clock changes on RPi.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -17,7 +18,7 @@ import (
|
||||||
// Timer (since start).
|
// Timer (since start).
|
||||||
|
|
||||||
type monotonic struct {
|
type monotonic struct {
|
||||||
Seconds uint64
|
Milliseconds uint64
|
||||||
Time time.Time
|
Time time.Time
|
||||||
ticker *time.Ticker
|
ticker *time.Ticker
|
||||||
}
|
}
|
||||||
|
@ -25,8 +26,8 @@ type monotonic struct {
|
||||||
func (m *monotonic) Watcher() {
|
func (m *monotonic) Watcher() {
|
||||||
for {
|
for {
|
||||||
<-m.ticker.C
|
<-m.ticker.C
|
||||||
m.Seconds++
|
m.Milliseconds += 50
|
||||||
m.Time = m.Time.Add(1 * time.Second)
|
m.Time = m.Time.Add(50 * time.Millisecond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,11 +36,11 @@ func (m *monotonic) Since(t time.Time) time.Duration {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *monotonic) HumanizeTime(t time.Time) string {
|
func (m *monotonic) HumanizeTime(t time.Time) string {
|
||||||
return humanize.RelTime(m.Time, t, "ago", "from now")
|
return humanize.RelTime(t, m.Time, "ago", "from now")
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMonotonic() *monotonic {
|
func NewMonotonic() *monotonic {
|
||||||
t := &monotonic{Seconds: 0, Time: time.Time{}, ticker: time.NewTicker(1 * time.Second)}
|
t := &monotonic{Milliseconds: 0, Time: time.Time{}, ticker: time.NewTicker(50 * time.Millisecond)}
|
||||||
go t.Watcher()
|
go t.Watcher()
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue