| | |
| | | private final Consumer<String> serialLineListener = line -> { |
| | | SwingUtilities.invokeLater(() -> { |
| | | updateDataPacketCountLabel(); |
| | | // 如果收到$GNGGA数据,立即更新拖尾 |
| | | if (line != null && line.trim().startsWith("$GNGGA")) { |
| | | if (mapRenderer != null && !pathPreviewActive) { |
| | | mapRenderer.forceUpdateIdleMowerTrail(); |
| | | // 如果收到GGA数据,立即更新拖尾 |
| | | if (line != null) { |
| | | String trimmed = line.trim(); |
| | | if (trimmed.startsWith("$GNGGA") || trimmed.startsWith("$GPGGA") || trimmed.startsWith("$GBGGA")) { |
| | | if (mapRenderer != null && !pathPreviewActive) { |
| | | mapRenderer.forceUpdateIdleMowerTrail(); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | |
| | | visualizationPanel.repaint(); |
| | | } |
| | | |
| | | // 测试方法 |
| | | public static void main(String[] args) { |
| | | JFrame frame = new JFrame("AutoMow - 首页"); |
| | | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
| | | frame.setSize(400, 800); |
| | | frame.setLocationRelativeTo(null); |
| | | |
| | | Shouye shouye = new Shouye(); |
| | | frame.add(shouye); |
| | | |
| | | frame.setVisible(true); |
| | | UDPServer.startAsync();//启动数据接收线程 |
| | | } |
| | | } |