aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-12-29 23:02:12 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-12-29 23:02:12 +0100
commit2812950ea28ce4d2e2bd5617c87d87f47892cdc5 (patch)
treed1276e1e65a18b5c7a60925261cd4aa9b3c603a8
parent55fe0c3c7bcd0243493976195a1e4d3283e2bfb7 (diff)
Add lanes
-rw-r--r--cmd/experimental/main.go9
-rw-r--r--protocol.go16
2 files changed, 25 insertions, 0 deletions
diff --git a/cmd/experimental/main.go b/cmd/experimental/main.go
index 991d910..d70c512 100644
--- a/cmd/experimental/main.go
+++ b/cmd/experimental/main.go
@@ -95,6 +95,15 @@ func onConnect(p gatt.Peripheral, err error) {
ss.Set(500, 2500)
b := anki.Encode(ss)
p.WriteCharacteristic(c, b, true)
+
+ go func(c *gatt.Characteristic) {
+ time.Sleep(5 * time.Second)
+ log.Println("Change lane")
+ cl := &anki.VehicleMsgChangeLane{}
+ cl.Set(100, 100, 0.0)
+ b = anki.Encode(cl)
+ p.WriteCharacteristic(c, b, true)
+ }(c)
}
}
}
diff --git a/protocol.go b/protocol.go
index 8662cf5..ee246e0 100644
--- a/protocol.go
+++ b/protocol.go
@@ -153,6 +153,22 @@ type VehicleMsgTurn struct {
Trigger uint8
}
+const (
+ Lane1 float32 = 68.0
+ Lane2 float32 = 23.0
+ Center float32 = 0.0
+ Lane3 float32 = -23.0
+ Lane4 float32 = -68.0
+)
+
+/* Lanes
+direction
+^ -23.0 23.0
+| -68.0 0.0 68.0 offset
+| |____._____.__+__._____.____|
+ 4 3 2 1 track
+*/
+
type VehicleMsgSetOffsetFromRoadCenter struct {
Size uint8
MsgID ID