当前位置: 首页>>代码示例>>Java>>正文


Java Button.getButtons方法代码示例

本文整理汇总了Java中lejos.hardware.Button.getButtons方法的典型用法代码示例。如果您正苦于以下问题:Java Button.getButtons方法的具体用法?Java Button.getButtons怎么用?Java Button.getButtons使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lejos.hardware.Button的用法示例。


在下文中一共展示了Button.getButtons方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import lejos.hardware.Button; //导入方法依赖的package包/类
public void run() {
    while (true) {
        if (Button.getButtons() == Keys.ID_ESCAPE) {
            try {
                robot.stop();
            } catch (IOException e) {
                // this won't happen
            }
        }
    }
}
 
开发者ID:JINKEHE,项目名称:Rescue-Victims,代码行数:12,代码来源:StoppingThread.java

示例2: getSelection

import lejos.hardware.Button; //导入方法依赖的package包/类
/**
 * Obtain a menu item selection
 * Allow the user to make a selection from the specified menu item. If a
 * power off timeout has been specified and no choice is made within this
 * time power off the NXT.
 *
 * @param menu Menu to display.
 * @param cur Initial item to select.
 * @return Selected item or < 0 for escape etc.
 */
@SuppressWarnings("deprecation")
private int getSelection(GraphicMenu menu, int cur) {
    int selection;

    curMenu = menu;

    // If the menu is interrupted by another thread, redisplay
    do {
        selection = menu.select(cur, this.timeout * 60000);

        while ( suspend ) {
            if ( program != null && !echoIn.isAlive() && !echoErr.isAlive() ) {
                stopProgram();
                this.ind.resume();
                break;
            }
            int b = Button.getButtons();
            if ( b == 6 ) {
                if ( program != null ) {
                    stopProgram();
                }
                this.ind.resume();
                break;
            }
            Delay.msDelay(200);
        }
    } while ( selection == -2 );

    if ( selection == -3 ) {
        shutdown();
    }

    return selection;
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:45,代码来源:GraphicStartup.java

示例3: exec

import lejos.hardware.Button; //导入方法依赖的package包/类
/**
 * Execute a program and display its output to System.out and error stream to System.err
 */
private static void exec(File jar, String command, String directory) {
    try {
        if ( jar != null ) {
            String jarName = jar.getName();
            programName = jarName.substring(0, jarName.length() - 4); // Remove .jar
        }
        lcd.clear();
        lcd.refresh();
        lcd.setAutoRefresh(false);

        drawLaunchScreen();

        program = new ProcessBuilder(command.split(" ")).directory(new File(directory)).start();
        BufferedReader input = new BufferedReader(new InputStreamReader(program.getInputStream()));
        BufferedReader err = new BufferedReader(new InputStreamReader(program.getErrorStream()));

        echoIn = new EchoThread(jar.getPath().replace(".jar", ".out"), input, System.out);
        echoErr = new EchoThread(jar.getPath().replace(".jar", ".err"), err, System.err);

        echoIn.start();
        echoErr.start();

        System.out.println("Executing " + command + " in " + directory);

        while ( true ) {
            int b = Button.getButtons();
            if ( b == 6 ) {
                System.out.println("Killing the process");
                program.destroy();
                // reset motors after program is aborted
                resetMotors();
                break;
            }
            if ( !echoIn.isAlive() && !echoErr.isAlive() ) {
                break;
            }
            Delay.msDelay(200);
        }
        System.out.println("Waiting for process to die");
        ;
        program.waitFor();
        System.out.println("Program finished");
    } catch ( Exception e ) {
        System.err.println("Failed to execute program: " + e);
    } finally {
        // Turn the LED off, in case left on
        Button.LEDPattern(0);
        lcd.setAutoRefresh(true);
        lcd.clear();
        lcd.refresh();
        program = null;
    }
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:57,代码来源:GraphicStartup.java


注:本文中的lejos.hardware.Button.getButtons方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。