forked from aykevl/board
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dummy.go
57 lines (44 loc) · 1.25 KB
/
dummy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package board
import "time"
// This file contains dummy devices, for devices which don't support a
// particular kind of device.
// Dummy button input that doesn't actually read any inputs.
// Used for boards that don't have any buttons.
type noButtons struct{}
func (b noButtons) Configure() {
}
func (b noButtons) ReadInput() {
}
func (b noButtons) NextEvent() KeyEvent {
return NoKeyEvent
}
// Dummy touch object that doesn't read any input.
// Used for displays without touch capabilities.
type noTouch struct{}
func (t noTouch) ReadTouch() []TouchPoint {
return nil
}
var lastWaitForVBlank time.Time
// Utility function for all those boards that don't support vblank.
func dummyWaitForVBlank(defaultInterval time.Duration) {
waitUntil := lastWaitForVBlank.Add(defaultInterval)
now := time.Now()
duration := waitUntil.Sub(now)
if duration < 0 {
lastWaitForVBlank = now
return
}
time.Sleep(duration)
lastWaitForVBlank = waitUntil
}
// Dummy implementation of the Power value, for devices with no battery or where
// the battery status cannot be read.
type dummyBattery struct {
state ChargeState
}
func (b dummyBattery) Configure() {
// nothing to do here
}
func (b dummyBattery) Status() (ChargeState, uint32, int8) {
return b.state, 0, -1
}