tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/sdcard/timer.go (about) 1 package sdcard 2 3 import ( 4 "time" 5 ) 6 7 var timeoutTimer [2]timer 8 9 type timer struct { 10 start int64 11 timeout int64 12 } 13 14 func setTimeout(timerID int, timeout time.Duration) *timer { 15 timeoutTimer[timerID].start = time.Now().UnixNano() 16 timeoutTimer[timerID].timeout = timeout.Nanoseconds() 17 return &timeoutTimer[timerID] 18 } 19 20 func (t timer) expired() bool { 21 return time.Now().UnixNano() > (t.start + t.timeout) 22 }