Unified with python var names
This commit is contained in:
parent
385234bfd9
commit
379dd7118a
3 changed files with 22 additions and 28 deletions
|
@ -41,6 +41,7 @@ class Garmin(
|
|||
|
||||
private inner class ProcessingThread(val maneuver: Maneuver) : Thread() {
|
||||
override fun run() {
|
||||
// TODO: check for equality before mapping!
|
||||
send(ManeuverMapper.apply(maneuver))
|
||||
}
|
||||
|
||||
|
@ -57,23 +58,23 @@ class Garmin(
|
|||
private fun setDistance(state: eu.ztsh.garmin.State) {
|
||||
connection.enqueue(intArrayOf(
|
||||
0x03, asDigit(state.distance / 1000), asDigit(state.distance / 100), asDigit(state.distance / 10),
|
||||
0x00, asDigit(state.distance), state.unit.data
|
||||
0x00, asDigit(state.distance), state.unit.value
|
||||
))
|
||||
}
|
||||
|
||||
private fun setDirection(direction: Direction) {
|
||||
val param1 = when (direction.outAngle) {
|
||||
val param1: Int = when (direction.angle) {
|
||||
OutAngle.LeftDown -> 0x10
|
||||
OutAngle.RightDown -> 0x20
|
||||
else -> direction.outType.data
|
||||
else -> direction.out.value
|
||||
}
|
||||
val param2: Int = if (direction.outType == OutType.RightRoundabout
|
||||
|| direction.outType == OutType.LeftRoundabout) {
|
||||
if (direction.roundabout == OutAngle.AsDirection) direction.outAngle.data else direction.roundabout.data
|
||||
val param2: Int = if (direction.out == OutType.RightRoundabout
|
||||
|| direction.out == OutType.LeftRoundabout) {
|
||||
if (direction.roundabout == OutAngle.AsDirection) direction.angle.value else direction.roundabout.value
|
||||
} else {
|
||||
0x00
|
||||
}
|
||||
val param3: Int = if (direction.outAngle == OutAngle.LeftDown || direction.outAngle == OutAngle.RightDown) 0x00 else direction.outAngle.data
|
||||
val param3: Int = if (direction.angle == OutAngle.LeftDown || direction.angle == OutAngle.RightDown) 0x00 else direction.angle.value
|
||||
connection.enqueue(intArrayOf(0x01, param1, param2, param3))
|
||||
}
|
||||
|
||||
|
|
|
@ -10,17 +10,10 @@ class ManeuverMapper {
|
|||
val state = State()
|
||||
maneuver.apply {
|
||||
this.primary.apply {
|
||||
state.direction = Direction()
|
||||
when (this.type) {
|
||||
"turn" -> {
|
||||
state.direction.outType = OutType.Lane
|
||||
state.direction.roundabout = OutAngle.AsDirection
|
||||
}
|
||||
|
||||
"roundabout" -> {
|
||||
state.direction.outType = OutType.RightRoundabout
|
||||
state.direction.out = OutType.RightRoundabout
|
||||
}
|
||||
|
||||
"arrive" -> {
|
||||
state.flag = true
|
||||
}
|
||||
|
@ -28,17 +21,17 @@ class ManeuverMapper {
|
|||
when (this.modifier) {
|
||||
"right" -> {
|
||||
when (this.type) {
|
||||
"turn" -> state.direction.outAngle = OutAngle.Right
|
||||
"turn" -> state.direction.angle = OutAngle.Right
|
||||
"roundabout" -> {
|
||||
when (this.degrees) {
|
||||
137.0 -> state.direction.outAngle = OutAngle.EasyRight
|
||||
137.0 -> state.direction.angle = OutAngle.EasyRight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"left" -> {
|
||||
when (this.type) {
|
||||
"turn" -> state.direction.outAngle = OutAngle.Left
|
||||
"turn" -> state.direction.angle = OutAngle.Left
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.ztsh.garmin
|
||||
|
||||
enum class OutType(val data: Int) {
|
||||
enum class OutType(val value: Int) {
|
||||
|
||||
Off(0x00),
|
||||
Lane(0x01),
|
||||
|
@ -13,7 +13,7 @@ enum class OutType(val data: Int) {
|
|||
}
|
||||
|
||||
|
||||
enum class OutAngle(val data: Int) {
|
||||
enum class OutAngle(val value: Int) {
|
||||
|
||||
Down(0x01),
|
||||
SharpRight(0x02),
|
||||
|
@ -29,7 +29,7 @@ enum class OutAngle(val data: Int) {
|
|||
|
||||
}
|
||||
|
||||
enum class Unit(val data: Int) {
|
||||
enum class Unit(val value: Int) {
|
||||
|
||||
Any(0),
|
||||
Metres(1),
|
||||
|
@ -39,7 +39,7 @@ enum class Unit(val data: Int) {
|
|||
|
||||
}
|
||||
|
||||
enum class Lane(val data: Int) {
|
||||
enum class Lane(val value: Int) {
|
||||
|
||||
DotsRight(0x01),
|
||||
OuterRight(0x02),
|
||||
|
@ -70,8 +70,8 @@ class State {
|
|||
}
|
||||
|
||||
class Direction {
|
||||
var outAngle: OutAngle = OutAngle.AsDirection
|
||||
var outType: OutType = OutType.Lane
|
||||
var angle: OutAngle = OutAngle.AsDirection
|
||||
var out: OutType = OutType.Lane
|
||||
var roundabout: OutAngle = OutAngle.AsDirection
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
|
@ -79,16 +79,16 @@ class Direction {
|
|||
|
||||
other as Direction
|
||||
|
||||
if (outAngle != other.outAngle) return false
|
||||
if (outType != other.outType) return false
|
||||
if (angle != other.angle) return false
|
||||
if (out != other.out) return false
|
||||
if (roundabout != other.roundabout) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = outAngle.hashCode()
|
||||
result = 31 * result + outType.hashCode()
|
||||
var result = angle.hashCode()
|
||||
result = 31 * result + out.hashCode()
|
||||
result = 31 * result + roundabout.hashCode()
|
||||
return result
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue