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


Java Sound.buzz方法代码示例

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


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

示例1: uncaughtException

import lejos.hardware.Sound; //导入方法依赖的package包/类
@Override
public void uncaughtException(Thread th, Throwable t)  {
	Sound.buzz();
    TextLCD lcd = LocalEV3.get().getTextLCD(Font.getSmallFont());
    int offset = 0;
    while (true)
    {
   		lcd.clear();
   		lcd.drawString("Uncaught exception:", offset, 0);
   		lcd.drawString(t.getClass().getName(), offset, 2);
   		if (t.getMessage() != null) lcd.drawString(t.getMessage(), offset, 3);		
   		
   		if (t.getCause() != null) {
   			lcd.drawString("Caused by:", offset, 5);
   			lcd.drawString(t.getCause().toString(), offset, 6);
   		}
   		
   		StackTraceElement[] trace = t.getStackTrace();
   		for(int i=0;i<7 && i < trace.length ;i++) lcd.drawString(trace[i].toString(), offset, 8+i);
   		
   		lcd.refresh();
   		int id = Button.waitForAnyEvent();
   		if (id == Button.ID_ESCAPE) break;
   		if (id == Button.ID_LEFT) offset += 5;
   		if (id == Button.ID_RIGHT)offset -= 5;
   		if (offset > 0) offset = 0;
    }
    
    // Shutdown the EV3
   	try {
		Runtime.getRuntime().exec("init 0");
	} catch (IOException e) {
		// Ignore
	}
    System.exit(1);
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:37,代码来源:ExceptionHandler.java

示例2: toolException

import lejos.hardware.Sound; //导入方法依赖的package包/类
private void toolException(Throwable t) {
    Sound.buzz();
    TextLCD lcd = BrickFinder.getDefault().getTextLCD(Font.getSmallFont());
    int offset = 0;
    // Get rid of invocation exception
    if ( t.getCause() != null ) {
        t = t.getCause();
    }
    while ( true ) {
        lcd.clear();
        lcd.drawString("Tool exception:", offset, 1);
        lcd.drawString(t.getClass().getName(), offset, 3);
        if ( t.getMessage() != null ) {
            lcd.drawString(t.getMessage(), offset, 4);
        }

        if ( t.getCause() != null ) {
            lcd.drawString("Caused by:", offset, 5);
            lcd.drawString(t.getCause().toString(), offset, 6);
        }

        StackTraceElement[] trace = t.getStackTrace();
        for ( int i = 0; i < 7 && i < trace.length; i++ ) {
            lcd.drawString(trace[i].toString(), offset, 8 + i);
        }

        lcd.refresh();
        int id = Button.waitForAnyEvent();
        if ( id == Button.ID_ESCAPE ) {
            break;
        }
        if ( id == Button.ID_LEFT ) {
            offset += 5;
        }
        if ( id == Button.ID_RIGHT ) {
            offset -= 5;
        }
        if ( offset > 0 ) {
            offset = 0;
        }
    }
    lcd.clear();
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:44,代码来源:GraphicStartup.java

示例3: getString

import lejos.hardware.Sound; //导入方法依赖的package包/类
String getString() {
	StringBuilder sb = new StringBuilder();
	x = 0;
	y = 5;
	display();
	
	while (true) {
		int b = Button.waitForAnyPress();
		
		displayCursor(false);
		
		if (b == Button.ID_DOWN) {
			if (++y > 6) y = 1;
		} else if (b == Button.ID_UP) {
			if (--y < 1) y = 6;
		} else if (b == Button.ID_LEFT) {
			if (--x < 0) x = 17;
		} else if (b == Button.ID_RIGHT) {
			if (++x > 17) x = 0;
		} else if (b == Button.ID_ENTER) {
			if (y < 6) sb.append(lines[y-1].charAt(x));
			else {
				switch (lines[5].charAt(x)) {
				case 'U': 
					lines = upper;
					display();
				    break;
				case 'l':
					lines = lower;
					display();
					break;
				case 'x':
					if (sb.length() > 0) {
						sb.deleteCharAt(sb.length()-1);
						lcd.drawString(" ", sb.length(), 7);
					} else Sound.buzz();
					break;
				case 'D':
					return sb.toString();
				}
			}
		} else if (b == Button.ID_ESCAPE) {
			return null;
		}
		
		displayCursor(true);
		String s = sb.toString();
		if (s.length() > 18) s = s.substring(s.length() - 18, s.length());
		lcd.drawString(s, 0, 7);
	}
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:52,代码来源:Keyboard.java

示例4: trackLost

import lejos.hardware.Sound; //导入方法依赖的package包/类
public void trackLost() {
	Button.LEDPattern(2);	
	Sound.buzz();
}
 
开发者ID:phllipo,项目名称:RoboRace,代码行数:5,代码来源:AudioVideoController.java

示例5: getPose

import lejos.hardware.Sound; //导入方法依赖的package包/类
public Pose getPose() {
    if(moves >= scanInterval) {
    	ArrayList<Double> beaconAngles = bl.locate();
		//System.out.println("BEFORE SORT:");
		//for(int i=0;i<beaconAngles.size();i++)
		//	System.out.println("a" + i + ": " + beaconAngles.get(i));
		//Button.ESCAPE.waitForPressAndRelease();
		
    	// Use OdometryPoseProvider (opp) to sort the beacons into the expected scan sequence.
		if (beaconAngles.size() == 3) {
			// Now try to sort the identifications of the beacons out. This method keeps track of Pose
			// using OdometryPoseProvider, which helps it id beacons.
			if(hasScanned) { // Can only do this after one successful scan. Otherwise opp.setPose() has not been set to proper coordinates.
				Pose robot = opp.getPose();
				double a1 = robot.angleTo(bt.beacon1);
				double a2 = robot.angleTo(bt.beacon2);
				double a3 = robot.angleTo(bt.beacon3);
				double h = robot.getHeading();
				
				// TODO: I think it was useless to convert these first because only angles are used!
				a1 = convertToRelative(h, a1);
				a2 = convertToRelative(h, a2);
				a3 = convertToRelative(h, a3);
				
				ArrayList<Double> odometryAngles = new ArrayList<Double>(3);
				odometryAngles.add(a1);
				odometryAngles.add(a2);
				odometryAngles.add(a3);
				
				//System.out.println("ODOMETRY:");
				//System.out.println("A1 " + a1);
				//System.out.println("A2 " + a2);
				//System.out.println("A3 " + a3);
				//Button.ESCAPE.waitForPressAndRelease();
				
				boolean success = sortBeacons(beaconAngles, odometryAngles);
				
				System.out.println("AFTER SORT:");
				for(int i=0;i<beaconAngles.size();i++)
					System.out.println("a" + i + ": " + beaconAngles.get(i));
				//Button.ESCAPE.waitForPressAndRelease();
			}
			
            Pose p = bt.calcPose(beaconAngles.get(0), beaconAngles.get(1), beaconAngles.get(2));
            System.out.println("POSE CALC");
			System.out.println(p.getX() + ", " + p.getY());
			System.out.println("H: " + p.getHeading());
			//Button.ESCAPE.waitForPressAndRelease();
            	            
            opp.setPose(p); // update OdometryPoseProvider with latest pose
            moves = 0;
            distance = 0;
            hasScanned = true;
            System.out.println("set to " + hasScanned);
            return p;
        } else Sound.buzz();
    }
    // If beacons <> 3 then use OdometryPP reading:
       return opp.getPose();
}
 
开发者ID:SnakeSVx,项目名称:ev3,代码行数:61,代码来源:BeaconPoseProvider.java

示例6: buzz

import lejos.hardware.Sound; //导入方法依赖的package包/类
@Override
public void buzz() throws RemoteException {
	Sound.buzz();	
}
 
开发者ID:SnakeSVx,项目名称:ev3,代码行数:5,代码来源:RMIRemoteSound.java


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