fix: trailing zeros, speed warning
This commit is contained in:
parent
711c79dd61
commit
36644a1af2
1 changed files with 6 additions and 7 deletions
|
@ -17,12 +17,13 @@ class GarminMapper {
|
|||
}
|
||||
|
||||
fun map(speed: Speed): IntArray {
|
||||
return setSpeed(speed.speed, speed.limit, speed.limit > 0 && speed.speed > speed.limit)
|
||||
return setSpeed(speed.speed, speed.limit)
|
||||
}
|
||||
|
||||
fun setTime(hours: Int, minutes: Int, traffic: Boolean = false, flag: Boolean = false): IntArray {
|
||||
val trafficChar = asChar(traffic)
|
||||
val flagChar = asChar(flag)
|
||||
// TODO: needed? Displaying ETA, not remaining
|
||||
return if (hours > 99) {
|
||||
intArrayOf(
|
||||
0x05,
|
||||
|
@ -40,7 +41,7 @@ class GarminMapper {
|
|||
0x05,
|
||||
trafficChar,
|
||||
asDigit(hours / 10),
|
||||
asDigit(hours),
|
||||
asDigit(if (hours == 0) 10 else hours),
|
||||
0xff,
|
||||
asDigit(minutes / 10),
|
||||
asDigit(minutes),
|
||||
|
@ -97,23 +98,21 @@ class GarminMapper {
|
|||
private fun setSpeed(
|
||||
speed: Int,
|
||||
limit: Int = 0,
|
||||
limitWarning: Boolean = false,
|
||||
acc: Boolean = false
|
||||
): IntArray {
|
||||
// TODO: car connection
|
||||
val accChar = asChar(acc)
|
||||
val limitWarningChar = asChar(limitWarning)
|
||||
return if (limit > 0) {
|
||||
intArrayOf(
|
||||
0x06,
|
||||
asDigit(speed / 100),
|
||||
asDigit(speed / 10),
|
||||
asDigit(speed),
|
||||
asDigit(if (speed == 0) 10 else speed),
|
||||
0xff,
|
||||
asDigit(limit / 100),
|
||||
asDigit(limit / 10),
|
||||
asDigit(limit),
|
||||
limitWarningChar,
|
||||
asChar(speed > limit),
|
||||
accChar
|
||||
)
|
||||
} else {
|
||||
|
@ -126,7 +125,7 @@ class GarminMapper {
|
|||
asDigit(speed / 100),
|
||||
asDigit(speed / 10),
|
||||
asDigit(speed),
|
||||
limitWarningChar,
|
||||
asChar(false),
|
||||
accChar
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue