Package lejos.util

Examples of lejos.util.TextMenu


{

    public static void main(String[] args) throws Exception
    {
        String[] connectionStrings = new String[]{"Bluetooth", "USB", "RS485"};
        TextMenu connectionMenu = new TextMenu(connectionStrings, 0, "Connection");
        String[] modeStrings = new String[] {"Packet", "Raw"};
        TextMenu modeMenu = new TextMenu(modeStrings, 0, "Mode");
        NXTCommConnector[] connectors = {Bluetooth.getConnector(), USB.getConnector(), RS485.getConnector()};
        int[] modes = {NXTConnection.PACKET, NXTConnection.RAW};

        int connectionType = connectionMenu.select();
        LCD.clear();
        int mode = modeMenu.select();
        while (true)
        {
            LCD.clear();
            LCD.drawString("Type: " + connectionStrings[connectionType], 0, 0);
            LCD.drawString("Mode: " + modeStrings[mode], 0, 1);
View Full Code Here


      for (int i = 0; i < devList.size(); i++) {
        RemoteDevice btrd = ((RemoteDevice) devList.elementAt(i));
        names[i] = btrd.getFriendlyName(true);
      }
       
      TextMenu searchMenu = new TextMenu(names,1);
      String[] subItems = {"Connect"};
      TextMenu subMenu = new TextMenu(subItems,4);
     
      int selected;
      do {
        LCD.clear();
        LCD.drawString("Found",6,0);
        LCD.refresh();
        //Menu 1: Show all BT Devices
        selected = searchMenu.select();
        if (selected >=0){
          RemoteDevice btrd = ((RemoteDevice) devList.elementAt(selected));
          LCD.clear();
          LCD.drawString("Found",6,0);
          LCD.drawString(names[selected],0,1);
          LCD.drawString(btrd.getBluetoothAddress(), 0, 2);
          //Menu 2: Show GPS Device
          int subSelection = subMenu.select();
          if (subSelection == 0){
            GPSDetected = true;
            GPSDevice = btrd;
            break;
          }
View Full Code Here

    }

    public static void main(String[] args) throws Exception
    {
        String[] connectionStrings = new String[]{"Bluetooth", "USB", "RS485"};
        TextMenu connectionMenu = new TextMenu(connectionStrings, 0, "Connection");
        NXTCommConnector[] connectors = {Bluetooth.getConnector(), USB.getConnector(), RS485.getConnector()};

        int connectionType = connectionMenu.select();
        LCD.clear();
        LCD.clear();
        LCD.drawString("Type: " + connectionStrings[connectionType], 0, 0);
        LCD.drawString("Running...", 0, 1);
        Responder resp = new Responder(connectors[connectionType]);
View Full Code Here

{

  public static void main(String [] args) throws Exception
    {
        String ports[] = {"Port 1", "Port 2", "Port 3", "Port 4"};
        TextMenu portMenu = new TextMenu(ports, 0, "Sensor port");
        String modes[] = {"Full", "Red", "Green", "Blue", "None"};
        TextMenu modeMenu = new TextMenu(modes, 0, "Color mode");
        int rawVals[] = new int[4];
        int vals[] = new int[4];

        int portNo = portMenu.select();
        if (portNo < 0) return;
        for(;;)
        {
            ColorLightSensor cs = new ColorLightSensor(SensorPort.PORTS[portNo], ColorLightSensor.TYPE_COLORNONE);
            int mode = modeMenu.select();
            if (mode < 0) return;
            cs.setType(ColorLightSensor.TYPE_COLORFULL + mode);
            LCD.clear();
            while (!Button.ESCAPE.isPressed())
            {
View Full Code Here

    public static void main(String[] args) throws Exception
    {
        String name = "NXT";
        String[] connectionStrings = {"Bluetooth", "RS485"};
        TextMenu connectionMenu = new TextMenu(connectionStrings, 0, "Connection");
        String[] modeStrings = {"Packet", "Raw"};
        TextMenu modeMenu = new TextMenu(modeStrings, 0, "Mode");
        NXTCommConnector[] connectors = {Bluetooth.getConnector(), RS485.getConnector()};
        int[] modes = {NXTConnection.PACKET, NXTConnection.RAW};

        int connectionType = connectionMenu.select();
        LCD.clear();
        int mode = modeMenu.select();

        LCD.clear();
        LCD.drawString("Name: " + name, 0, 0);
        LCD.drawString("Type: " + connectionStrings[connectionType], 0, 1);
        LCD.drawString("Mode: " + modeStrings[mode], 0, 2);
View Full Code Here

    }
   
    LCD.drawString("Play a WAV file",0,0);
   
    // Create menu of WAV files
    TextMenu fileMenu = new TextMenu(fileNames,1);
   
    // Play files until the user quits
    int selected;
    do {
      selected = fileMenu.select();
      if (selected >= 0) {
        Sound.playSample(files[selected],100);
      }
    } while (selected >= 0);
View Full Code Here

    String lightString = "Light:";
    String tachoString = "Tacho:";

        // Get the type of communications to be used
        String[] connectionStrings = new String[]{"Bluetooth", "RS485"};
        TextMenu connectionMenu = new TextMenu(connectionStrings, 0, "Connection");
        NXTCommConnector[] connectors = {Bluetooth.getConnector(), RS485.getConnector()};

        int connectionType = connectionMenu.select();

        // Now connect
        try {
            LCD.clear();
            LCD.drawString("Connecting...",0,0);
View Full Code Here

            for (int i = 0; i < devList.size(); i++)
            {
                RemoteDevice btrd = ((RemoteDevice) devList.elementAt(i));
                names[i] = btrd.getFriendlyName(false);
            }
            TextMenu searchMenu = new TextMenu(names, 1);
            TextMenu subMenu = new TextMenu(new String[]{"Pair"}, 4);
            int selected;
            do
            {
                newScreen("Found");
                ind.setIOMode(Indicators.IO_NONE);
View Full Code Here

            {
                RemoteDevice btrd = ((RemoteDevice) devList.elementAt(i));
                names[i] = btrd.getFriendlyName(false);
            }

            TextMenu deviceMenu = new TextMenu(names, 1);
            TextMenu subMenu = new TextMenu(new String[] {"Remove"}, 6);
            int selected;
            do
            {
                newScreen();
                selected = getSelection(deviceMenu, 0);
View Full Code Here

     * Present the Bluetooth menu to the user.
     */
    private void bluetoothMenu()
    {
        int selection;
        TextMenu menu = new TextMenu(null, 3);
        boolean visible;
        do
        {
            newScreen("Bluetooth");
            LCD.drawString("Power", 0, 1);
            LCD.drawString(btPowerOn ? "on" : "off", 11, 1);
            visible = Bluetooth.getVisibility() == 1;
            if (btPowerOn)
            {
                LCD.drawString("Visibility", 0, 2);
                LCD.drawString(visible ? "on" : "off", 11, 2);
                menu.setItems(new String[]
                        {
                            "Power off", "Search and Pair", "Devices", "Visibility", "Change PIN"
                        });
            }
            else
                menu.setItems(new String[]
                        {
                            "Power on"
                        });
            selection = getSelection(menu, 0);
            switch (selection)
View Full Code Here

TOP

Related Classes of lejos.util.TextMenu

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.