From 2812950ea28ce4d2e2bd5617c87d87f47892cdc5 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Thu, 29 Dec 2016 23:02:12 +0100 Subject: Add lanes --- cmd/experimental/main.go | 9 +++++++++ protocol.go | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) 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 -- cgit v1.2.3