aboutsummaryrefslogtreecommitdiff
path: root/types.go
diff options
context:
space:
mode:
Diffstat (limited to 'types.go')
-rw-r--r--types.go59
1 files changed, 59 insertions, 0 deletions
diff --git a/types.go b/types.go
new file mode 100644
index 0000000..121deba
--- /dev/null
+++ b/types.go
@@ -0,0 +1,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,
+ )
+}