aboutsummaryrefslogtreecommitdiff
path: root/types.go
blob: 121debaa7eac8e599d5bf67476517a6d3f2f91d4 (plain)
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
58
59
package anki

import (
	"fmt"
	"time"
)

//go:generate stringer -type=ID
type ID uint8

//go:generate stringer -type=Direction
type Direction uint8

type MicroSec uint32

func (v MicroSec) String() string {
	return fmt.Sprintf("%v", time.Duration(v)*time.Microsecond)
}

type MilliVolt uint16

func (v MilliVolt) String() string {
	return fmt.Sprintf("%6.4fV", float64(v)/1000.0)
}

type Bool uint8

func (v Bool) String() string {
	return fmt.Sprintf("%t", v != 0)
}

type MMperSecSQ uint16

func (v MMperSecSQ) String() string {
	return fmt.Sprintf("%5.3fm/s²", float64(v)/1000.0)
}

type MMperSec uint16

func (v MMperSec) String() string {
	return fmt.Sprintf("%5.3fm/s", float64(v)/1000.0)
}

type Offset float32

func (c Offset) String() string {
	return fmt.Sprintf("%4.1fmm", c)
}

type Flags uint8

func (f Flags) String() string {
	return fmt.Sprintf("{Bits: %d InvColor: %t RevParse: %t RevDrive: %t}",
		f&ParseflagsMaskNumBits,
		f&ParseflagsMaskInvertedColor != 0,
		f&ParseflagsMaskReverseParsing != 0,
		f&ParseflagsMaskReverseDriving != 0,
	)
}