mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-27 04:16:32 -08:00
Fix battery reading compatibility with owoTrack
This commit is contained in:
1 parent
5c22ef0192
commit
b369ae6a2a
2 files changed
+17
-3
No files matched your search
@@ -321,8 +321,18 @@ public class TrackersList extends EJBoxNoStretch {
|
||||
if(realTracker instanceof TrackerWithTPS) {
|
||||
tps.setText(StringUtils.prettyNumber(((TrackerWithTPS) realTracker).getTPS(), 1));
|
||||
}
|
||||
if(realTracker instanceof TrackerWithBattery)
|
||||
bat.setText(String.format("%d%% (%sV)", Math.round(((TrackerWithBattery) realTracker).getBatteryLevel()), StringUtils.prettyNumber(((TrackerWithBattery) realTracker).getBatteryVoltage(), 2)));
|
||||
if(realTracker instanceof TrackerWithBattery) {
|
||||
TrackerWithBattery twb = (TrackerWithBattery) realTracker;
|
||||
float level = twb.getBatteryLevel();
|
||||
float voltage = twb.getBatteryVoltage();
|
||||
if(level == 0.0f) {
|
||||
bat.setText(String.format("%sV", StringUtils.prettyNumber(voltage, 2)));
|
||||
} else if(voltage == 0.0f) {
|
||||
bat.setText(String.format("%d%%", Math.round(level)));
|
||||
} else {
|
||||
bat.setText(String.format("%d%% (%sV)", Math.round(level), StringUtils.prettyNumber(voltage, 2)));
|
||||
}
|
||||
}
|
||||
if(t instanceof ReferenceAdjustedTracker) {
|
||||
ReferenceAdjustedTracker<Tracker> rat = (ReferenceAdjustedTracker<Tracker>) t;
|
||||
if(adj != null) {
|
||||
|
||||
@@ -19,8 +19,12 @@ public class UDPPacket12BatteryLevel extends UDPPacket {
|
||||
@Override
|
||||
public void readData(ByteBuffer buf) throws IOException {
|
||||
voltage = buf.getFloat();
|
||||
if(buf.remaining() > 3)
|
||||
if(buf.remaining() > 3) {
|
||||
level = buf.getFloat();
|
||||
} else {
|
||||
level = voltage;
|
||||
voltage = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user