fix: Model rebuilt

This commit is contained in:
Piotr Dec 2024-07-31 20:16:44 +02:00
parent 75e10c1579
commit 785a35473e
Signed by: stawros
GPG key ID: F89F27AD8F881A91
6 changed files with 136 additions and 137 deletions

View file

@ -4,24 +4,20 @@ class GarminMapper {
companion object {
fun setLines(state: State): IntArray {
return intArrayOf(0x02, state.lineOutlines.sumOf { it.value }, state.lineArrows.sumOf { it.value })
fun map(lanes: Lanes): IntArray {
return intArrayOf(0x02, lanes.lanes.lanes.sumOf { it.value }, lanes.outlines.lanes.sumOf { it.value })
}
fun setDirection(state: State): IntArray {
return setDirection(state.direction.angle, state.direction.out, state.direction.roundabout)
fun map(direction: Direction): IntArray {
return toDirectionArray(direction.angle, direction.out, direction.roundabout)
}
fun setDistance(state: State): IntArray {
return setDistance(state.distance, state.unit)
fun map(distance: Distance): IntArray {
return setDistance(distance.distance, distance.unit)
}
fun setSpeed(state: State): IntArray {
return setSpeed(state.speed, state.limit, state.speed > state.limit)
}
fun setSpeedFreeRide(state: State): Pair<IntArray, IntArray> {
return Pair(setDistance(state.speed), setSpeed(state.limit, limitWarning = state.speed > state.limit))
fun map(speed: Speed): IntArray {
return setSpeed(speed.speed, speed.limit, speed.speed > speed.limit)
}
fun setTime(hours: Int, minutes: Int, traffic: Boolean = false, flag: Boolean = false): IntArray {
@ -54,20 +50,15 @@ class GarminMapper {
}
}
fun setSpeedControl(state: State): IntArray {
return intArrayOf(0x04, if (state.control) 0x01 else 0x02)
}
fun setCompass(state: State): IntArray {
// TODO: Implement
return setDirection(OutAngle.Straight, OutType.ArrowOnly)
fun speedControl(state: Boolean): IntArray {
return intArrayOf(0x04, if (state) 0x01 else 0x02)
}
fun cleanDistance(): IntArray {
return intArrayOf(0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
}
private fun setDirection(
private fun toDirectionArray(
angle: OutAngle,
out: OutType = OutType.Lane,
roundabout: OutAngle = OutAngle.AsDirection