| | |
| | | mowingProgressLabel.setForeground(THEME_COLOR); |
| | | |
| | | mowerSpeedValueLabel = new JLabel("--"); |
| | | mowerSpeedValueLabel.setFont(new Font("微软雅黑", Font.BOLD, 14)); |
| | | // 数值大小与单位 km/h 显示大小一致 |
| | | mowerSpeedValueLabel.setFont(new Font("微软雅黑", Font.BOLD, 9)); |
| | | mowerSpeedValueLabel.setForeground(THEME_COLOR); |
| | | |
| | | mowerSpeedUnitLabel = new JLabel("km/h"); |
| | |
| | | String display = "--"; |
| | | Device device = Device.getGecaoji(); |
| | | if (device != null) { |
| | | String sanitized = sanitizeSpeedValue(device.getRealtimeSpeed()); |
| | | // 使用 yaw 值作为速度显示(单位:km/h) |
| | | String sanitized = sanitizeSpeedValue(device.getYaw()); |
| | | if (sanitized != null) { |
| | | display = sanitized; |
| | | // yaw为0时显示为"0" |
| | | try { |
| | | double v = Double.parseDouble(sanitized); |
| | | if (Math.abs(v) < 1e-9) { |
| | | display = "0"; |
| | | } else { |
| | | display = sanitized; |
| | | } |
| | | } catch (NumberFormatException ex) { |
| | | display = sanitized; |
| | | } |
| | | } |
| | | } |
| | | mowerSpeedValueLabel.setText(display); |