OSDN Git Service

lejos_NXJ_win32_0_5_0beta.zip
[nxt-jsp/lejos_nxj.git] / nxtOSEK / lejos_nxj / samples / SignalTest / SignalTest.java
1 import java.io.DataInputStream;\r
2 import java.io.DataOutputStream;\r
3 import java.io.InputStream;\r
4 import java.io.OutputStream;\r
5 \r
6 import lejos.nxt.*;\r
7 import lejos.nxt.comm.*;\r
8 \r
9 /**\r
10  * Open a connection to the NXT using the BTSend sample\r
11  * and then walk round the house measuring the signal\r
12  * strength.\r
13  * \r
14  * @author Lawrie Griffiths\r
15  *\r
16  */\r
17 public class SignalTest {\r
18 \r
19         public static void main(String [] args)  throws Exception \r
20         {\r
21                 String connected = "Connected";\r
22         String waiting = "Waiting";\r
23         String strength = "Signal: ";\r
24 \r
25                 LCD.drawString(waiting,0,0);\r
26                 LCD.refresh();\r
27 \r
28         BTConnection btc = Bluetooth.waitForConnection();\r
29         \r
30                 LCD.clear();\r
31                 LCD.drawString(connected,0,0);\r
32                 LCD.refresh();  \r
33                 \r
34                 while(!Button.ESCAPE.isPressed()) {\r
35                         LCD.drawString(strength, 0, 3);\r
36                         LCD.drawInt(btc.getSignalStrength(), 3, 9 ,3);\r
37                         LCD.refresh();\r
38                         Thread.sleep(1000);\r
39                 }\r
40                 \r
41                 btc.close();\r
42         }\r
43 }\r