| | |
| | | import java.awt.event.*; |
| | | |
| | | import chuankou.dellmessage; |
| | | import chuankou.sendmessage; |
| | | import chuankou.SerialPortService; |
| | | import dikuai.Dikuai; |
| | | import dikuai.Dikuaiguanli; |
| | | import dikuai.addzhangaiwu; |
| | |
| | | // 边界检查定时器:每500ms检查一次割草机是否在边界内 |
| | | boundaryWarningTimer = new Timer(500, e -> { |
| | | checkMowerBoundaryStatus(); |
| | | // 同时更新蓝牙图标状态 |
| | | updateBluetoothButtonIcon(); |
| | | }); |
| | | boundaryWarningTimer.setInitialDelay(0); |
| | | boundaryWarningTimer.start(); |
| | |
| | | } |
| | | }); |
| | | ensureBluetoothIconsLoaded(); |
| | | bluetoothConnected = Bluelink.isConnected(); |
| | | ImageIcon initialIcon = bluetoothConnected ? bluetoothLinkedIcon : bluetoothIcon; |
| | | // 根据串口连接状态显示图标 |
| | | SerialPortService service = sendmessage.getActiveService(); |
| | | boolean serialConnected = (service != null && service.isOpen()); |
| | | ImageIcon initialIcon = serialConnected ? bluetoothLinkedIcon : bluetoothIcon; |
| | | if (initialIcon != null) { |
| | | button.setIcon(initialIcon); |
| | | } else { |
| | | button.setText(bluetoothConnected ? "已连" : "蓝牙"); |
| | | button.setText(serialConnected ? "已连" : "蓝牙"); |
| | | } |
| | | return button; |
| | | } |
| | |
| | | return; |
| | | } |
| | | ensureBluetoothIconsLoaded(); |
| | | bluetoothConnected = Bluelink.isConnected(); |
| | | ImageIcon icon = bluetoothConnected ? bluetoothLinkedIcon : bluetoothIcon; |
| | | // 根据串口连接状态显示图标 |
| | | SerialPortService service = sendmessage.getActiveService(); |
| | | boolean serialConnected = (service != null && service.isOpen()); |
| | | ImageIcon icon = serialConnected ? bluetoothLinkedIcon : bluetoothIcon; |
| | | if (icon != null) { |
| | | bluetoothBtn.setIcon(icon); |
| | | bluetoothBtn.setText(null); |
| | | } else { |
| | | bluetoothBtn.setText(bluetoothConnected ? "已连" : "蓝牙"); |
| | | bluetoothBtn.setText(serialConnected ? "已连" : "蓝牙"); |
| | | } |
| | | } |
| | | |