File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 1+ package tinygo_servo
2+
3+ type (
4+ // Direction is an enum to represent the different servo directions for the vehicle.
5+ Direction uint8
6+ )
7+
8+ const (
9+ DirectionNil Direction = iota
10+ DirectionLeft
11+ DirectionRight
12+ DirectionStraight
13+ )
14+
15+ // InvertedDirection returns the inverted direction.
16+ func (d Direction ) InvertedDirection () Direction {
17+ switch d {
18+ case DirectionLeft :
19+ return DirectionRight
20+ case DirectionRight :
21+ return DirectionLeft
22+ case DirectionStraight :
23+ return DirectionStraight
24+ default :
25+ return DirectionNil
26+ }
27+ }
Original file line number Diff line number Diff line change @@ -17,4 +17,5 @@ const (
1717 ErrorCodeServoAngleAboveMaxPulseWidth
1818 ErrorCodeServoFailedToSetServoAngle
1919 ErrorCodeServoNilHandler
20- )
20+ ErrorCodeServoUnknownDirection
21+ )
You can’t perform that action at this time.
0 commit comments