-
Notifications
You must be signed in to change notification settings - Fork 0
/
mode_debug.go
executable file
·66 lines (60 loc) · 1.1 KB
/
mode_debug.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
58
59
60
61
62
63
64
65
66
//go:build debug
package pico
import (
"fmt"
"strings"
)
//////////////////////////////////////////////////////////////////////////////
// STRINGIFY
func (v Mode) String() string {
switch v {
case ModeOutput:
return "ModeOutput"
case ModeInput:
return "ModeInput"
case ModeInputPulldown:
return "ModeInputPulldown"
case ModeInputPullup:
return "ModeInputPullup"
case ModeUART:
return "ModeUART"
case ModePWM:
return "ModePWM"
case ModeI2C:
return "ModeI2C"
case ModeSPI:
return "ModeSPI"
case ModeOff:
return "ModeOff"
default:
return fmt.Sprintf("Mode(0x%02X)", uint(v))
}
}
func (v State) String() string {
if v == StateNone {
return v._String()
}
str := ""
for f := StateMin; f <= StateMax; f <<= 1 {
if v&f != 0 {
str += "|" + f._String()
}
}
return strings.Trim(str, "|")
}
func (v State) _String() string {
switch v {
case StateLow:
return "StateLow"
case StateHigh:
return "StateHigh"
case StateFall:
return "StateFall"
case StateRise:
return "StateRise"
case StateNone:
return "StateNone"
default:
return fmt.Sprintf("State(0x%02X)", uint(v))
}
}