Added Navigation service #5
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "yannickulrich/infinitime:navigation-service"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
InfiniTime implements a Navigation Service. This pull request will add it to the go library by defining a function
From the InfiniTime manual
flag
: the graphic instruction as provided by Pure Maps. A list of valid instruction icons can be found herenarrative
: the instruction in words, eg. "At the roundabout take the first exit".dist
: a short string describing the distance to the upcoming instruction such as "50 m".progress
: the percent complete in auint8
Adding this to the
itd
daemon is straightforwardThank you for the PR.
If you have issues completing any of the changes I requested, simply do what you can and I'll handle the rest.
@ -55,0 +62,4 @@
NavProgressChar: "Navigation Progress",
}
var NavFlagNames = []string{
I think it would be better if these were individual constants rather than a slice. That way, they could have their own type and the compiler can guarantee that they're valid instead of needing a separate function. Since that will add quite a bit of code, I think the navigation service can be moved into a separate file.
Maybe something like
Then, the
NavigationEvent
can take aNavFlag
instead ofstring
.Taken care of in
d46f545
@ -71,6 +125,7 @@ type Device struct {
notifEventDone bool
Music MusicCtrl
DFU DFU
navigationEv NavigationEvent
I don't see why this is needed. It never gets used except to set its values, so there's no reason for it to be here.
The idea here was that we only update a field when it actually changes. Alternatively, the field in NavigationEvent could be
nil
or something to indicate that we won't want to update this. How would you do this? I don't have that much experience with Go.I actually think that you don't need to make sure it's changed. GATT characteristic writes are fast enough that it doesn't really cause a problem if you update them with the same value. InfiniTime might even check if it's changed in the navigation service code.
For the music service, for example, I update the values as they come in from the DBus MPRIS interface. This does mean that if you, for example, reload a page, it will send the same values again, but this has never caused a problem because writes take milliseconds.
@ -726,0 +798,4 @@
}
// Navigation sends a NavigationEvent to the watch
func (i *Device) Navigation(flag string, narrative string, dist string, progress uint8) error {
I'd prefer if this accepted a
NavigationEvent
rather than individual arguments. That also means all the fields inNavigationEvent
should be capitalized to export them.Sure! See
c3a8727
but also my comment aboveChanges to the
itd
daemon with the changes to the APIThanks for merging 💜
I've also prepared the changes for itd. Do you want me to open a pull request on Arsen6331/itd or do you just want to apply the above patch?
I'll probably just add PureMaps support directly rather than exposing it in the RPC interface, unless you have a specific need for that