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


Java AccelerometerEvent类代码示例

本文整理汇总了Java中motej.event.AccelerometerEvent的典型用法代码示例。如果您正苦于以下问题:Java AccelerometerEvent类的具体用法?Java AccelerometerEvent怎么用?Java AccelerometerEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: main

import motej.event.AccelerometerEvent; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
	AccelerometerListener<Mote> listener = new AccelerometerListener<Mote>() {
	
		public void accelerometerChanged(AccelerometerEvent<Mote> evt) {
			System.out.println(evt.getX() + " : " + evt.getY() + " : " + evt.getZ());
		}
	
	};
	
	SimpleMoteFinder simpleMoteFinder = new SimpleMoteFinder();
	Mote mote = simpleMoteFinder.findMote();
	mote.addAccelerometerListener(listener);
	mote.setReportMode(ReportModeRequest.DATA_REPORT_0x31);
	
	Thread.sleep(6000000);
	
	mote.setReportMode(ReportModeRequest.DATA_REPORT_0x30);
	mote.disconnect();
}
 
开发者ID:fustinoni-net,项目名称:PiRobotPlatform,代码行数:20,代码来源:AccelerometerDemo.java

示例2: accelerometerChanged

import motej.event.AccelerometerEvent; //导入依赖的package包/类
@Override
public void accelerometerChanged(AccelerometerEvent event) {
	synchronized (lock) {
		if (event.getSource() instanceof Nunchuk) {
			this.accelNunX = event.getX();
			this.accelNunY = event.getY();
			this.accelNunZ = event.getZ();
			double x = (this.accelNunX - 128) / 60;
			double y = (this.accelNunY - 128) / 60;
			double z = (this.accelNunZ - 128) / 60;
			this.yawList.add((float) (Math.atan2(y,
					Math.sqrt(x * x + z * z)) * 180 / Math.PI));
			this.pitchList.add((float) (Math.atan2(-x,
					Math.sqrt(y * y + z * z)) * 180 / Math.PI));
		} else {
			this.accelX = event.getX();
			this.accelY = event.getY();
			this.accelZ = event.getZ();
			this.accelZmoved = event.getZ() - 139;
		}
	}
}
 
开发者ID:freundTech,项目名称:motecraft,代码行数:23,代码来源:WiiMoteListener.java

示例3: main

import motej.event.AccelerometerEvent; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
	AccelerometerListener<Mote> listener = new AccelerometerListener<Mote>() {
	
		public void accelerometerChanged(AccelerometerEvent<Mote> evt) {
			System.out.println(evt.getX() + " : " + evt.getY() + " : " + evt.getZ());
		}
	
	};
	
	SimpleMoteFinder simpleMoteFinder = new SimpleMoteFinder();
	Mote mote = simpleMoteFinder.findMote();
	mote.addAccelerometerListener(listener);
	mote.setReportMode(ReportModeRequest.DATA_REPORT_0x31);
	
	Thread.sleep(60000l);
	
	mote.setReportMode(ReportModeRequest.DATA_REPORT_0x30);
	mote.disconnect();
}
 
开发者ID:iSchluff,项目名称:Wii-Gesture,代码行数:20,代码来源:AccelerometerDemo.java

示例4: fireAccelerometerEvent

import motej.event.AccelerometerEvent; //导入依赖的package包/类
/**
 * @param data
 */
@SuppressWarnings("unchecked")
protected void fireAccelerometerEvent(byte[] data) {
	AccelerometerListener<Nunchuk>[] listeners = listenerList
			.getListeners(AccelerometerListener.class);
	if (listeners.length == 0) {
		return;
	}

	// remark: I am currently ignoring the LSB as I do with the LSB of the
	// calibration data.
	// if someone comes up with reliable data, we'll add it, i promise.
	int ax = ((data[2] & 0xff)); // << 2) ^ (data[5] & 0x0c);
	int ay = ((data[3] & 0xff)); // << 2) ^ (data[5] & 0x30);
	int az = ((data[4] & 0xff)); // << 2) ^ (data[5] & 0xc0);
	AccelerometerEvent<Nunchuk> evt = new AccelerometerEvent<Nunchuk>(this,
			ax, ay, az);
	for (AccelerometerListener<Nunchuk> l : listeners) {
		l.accelerometerChanged(evt);
	}
}
 
开发者ID:iSchluff,项目名称:Wii-Gesture,代码行数:24,代码来源:Nunchuk.java

示例5: accelerometerChanged

import motej.event.AccelerometerEvent; //导入依赖的package包/类
@Override
public void accelerometerChanged(AccelerometerEvent<Mote> evt) {
	/* Parameter auslesen */
	xAccel=evt.getX();
	yAccel=evt.getY();
	zAccel=evt.getZ();
	
	Vector<Double> accelStep=new Vector<Double>();
	//Log.write(xAccel+" "+yAccel+" "+zAccel,this);
	accelStep.add(xAccel);
	accelStep.add(yAccel);
	accelStep.add(zAccel);
	
	/* Werte filtern */
	if(filter!=null){
		Vector<Double>filtered=filter.filter(xAccel, yAccel, zAccel);
		
		/* Werte in Geste schreiben */
		if(gesture!=null){
			gesture.setAccelStep(filtered);
		}
		graph.setAccel(filtered);
	}else{
		if(gesture!=null){
			gesture.setAccelStep(accelStep);
		}
		graph.setAccel(accelStep);
	}
}
 
开发者ID:iSchluff,项目名称:Wii-Gesture,代码行数:30,代码来源:DataTraceAccelerationListener.java

示例6: fireAccelerometerEvent

import motej.event.AccelerometerEvent; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected void fireAccelerometerEvent(double xAcceleration, double yAcceleration, double zAcceleration) {
    AccelerometerListener<Mote>[] listeners = listenerList.getListeners(AccelerometerListener.class);
    AccelerometerEvent<Mote> evt = new AccelerometerEvent<Mote>(this, xAcceleration, yAcceleration, zAcceleration);
    for (AccelerometerListener<Mote> l : listeners) {
        l.accelerometerChanged(evt);
    }
}
 
开发者ID:iSchluff,项目名称:Wii-Gesture,代码行数:9,代码来源:Mote.java

示例7: accelerometerChanged

import motej.event.AccelerometerEvent; //导入依赖的package包/类
public void accelerometerChanged(AccelerometerEvent<Nunchuk> evt) {
	accelerometerPanel.accelerometerValueChanged(evt.getX() & 0xff, evt.getY() & 0xff, evt.getZ() & 0xff);
}
 
开发者ID:fustinoni-net,项目名称:PiRobotPlatform,代码行数:4,代码来源:NunchukGui.java

示例8: accelerometerChanged

import motej.event.AccelerometerEvent; //导入依赖的package包/类
public void accelerometerChanged(AccelerometerEvent<Nunchuk> evt) {
//		accelerometerPanel.accelerometerValueChanged(evt.getX() & 0xff, evt.getY() & 0xff, evt.getZ() & 0xff);
	}
 
开发者ID:iSchluff,项目名称:Wii-Gesture,代码行数:4,代码来源:NunchukGui.java


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