5 * Emulates the RCX Remote control
\r
7 * @author Lawrie Griffiths <lawrie.griffiths@ntlworld.com>
\r
10 * Beep does not work twice in a row with standard RCX firmware.
\r
11 * Commands only work every other time with RCX leJOS RemoteControlTest
\r
12 * example (due to the RCX leJOS Remote Control system not
\r
13 * handling the 0x08 toggle bit in RCX opcodes).
\r
15 public class RCXRemote {
\r
16 public static void main(String[] args) throws Exception {
\r
17 RCXLink link = new RCXLink(SensorPort.S1);
\r
18 String[] menuItems =
\r
19 {"P1", "P2", "P3", "P4", "P5",
\r
21 "A fwd", "A bwd", "B fwd",
\r
22 "B bwd", "C fwd", "C bwd",
\r
23 "Msg 1", "Msg 2", "Msg 3"};
\r
24 TextMenu menu = new TextMenu(menuItems,1,"RCX Remote");
\r
28 menu_item = menu.select();
\r
30 if (menu_item >= 0 && menu_item <= 4) {
\r
31 link.runProgram(menu_item + 1);
\r
34 if (menu_item == 5) link.stopAllPrograms();
\r
35 if (menu_item == 6) link.beep();
\r
37 if (menu_item == 7) link.forwardStep(0);
\r
38 if (menu_item == 8) link.backwardStep(0);
\r
39 if (menu_item == 9) link.forwardStep(1);
\r
40 if (menu_item == 10) link.backwardStep(1);
\r
41 if (menu_item == 11) link.forwardStep(1);
\r
42 if (menu_item == 12) link.backwardStep(1);
\r
44 if (menu_item >=13 && menu_item <= 15) {
\r
45 link.sendRemoteCommand(1 << (menu_item - 13));
\r
48 } while (menu_item >= 0);
\r