mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-04-06 02:01:58 +02:00
Parse runtime from HID tracker
This commit is contained in:
@@ -310,6 +310,9 @@ public class DataFeedBuilder {
|
||||
HardwareStatus.addRssi(fbb, (short) tracker.getSignalStrength().floatValue());
|
||||
}
|
||||
|
||||
if (tracker.getBatteryRemainingRuntime() != null) {
|
||||
HardwareStatus.addBatteryRuntimeEstimate(fbb, tracker.getBatteryRemainingRuntime());
|
||||
}
|
||||
|
||||
int hardwareDataOffset = HardwareStatus.endHardwareStatus(fbb);
|
||||
int hardwareInfoOffset = DataFeedBuilder.createHardwareInfo(fbb, device);
|
||||
|
||||
@@ -112,6 +112,7 @@ class Tracker @JvmOverloads constructor(
|
||||
val trackerFlexHandler: TrackerFlexHandler = TrackerFlexHandler(this)
|
||||
var batteryVoltage: Float? = null
|
||||
var batteryLevel: Float? = null
|
||||
var batteryRemainingRuntime: Long? = null
|
||||
var ping: Int? = null
|
||||
var signalStrength: Int? = null
|
||||
var temperature: Float? = null
|
||||
|
||||
@@ -138,6 +138,7 @@ class HIDCommon {
|
||||
}
|
||||
|
||||
// Packet data
|
||||
var runtime: Long? = null
|
||||
var batt: Int? = null
|
||||
var batt_v: Int? = null
|
||||
var temp: Int? = null
|
||||
@@ -221,6 +222,11 @@ class HIDCommon {
|
||||
}
|
||||
}
|
||||
|
||||
5 -> { // runtime
|
||||
// ulong as little endian
|
||||
runtime = (dataReceived[i + 9].toUByte().toLong() shl 56) or (dataReceived[i + 8].toUByte().toLong() shl 48) or (dataReceived[i + 7].toUByte().toLong() shl 40) or (dataReceived[i + 6].toUByte().toLong() shl 32) or (dataReceived[i + 5].toUByte().toLong() shl 24) or (dataReceived[i + 4].toUByte().toLong() shl 16) or (dataReceived[i + 3].toUByte().toLong() shl 8) or dataReceived[i + 2].toUByte().toLong()
|
||||
}
|
||||
|
||||
6 -> { // data
|
||||
button = dataReceived[i + 2].toUByte().toInt()
|
||||
rssi = dataReceived[i + 15].toUByte().toInt()
|
||||
@@ -248,6 +254,9 @@ class HIDCommon {
|
||||
}
|
||||
|
||||
// Assign data
|
||||
if (runtime != null) {
|
||||
tracker.batteryRemainingRuntime = runtime
|
||||
}
|
||||
if (batt != null) {
|
||||
tracker.batteryLevel = if (batt == 128) 1f else (batt and 127).toFloat()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user