本文整理汇总了Java中ioio.lib.util.BaseIOIOLooper类的典型用法代码示例。如果您正苦于以下问题:Java BaseIOIOLooper类的具体用法?Java BaseIOIOLooper怎么用?Java BaseIOIOLooper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BaseIOIOLooper类属于ioio.lib.util包,在下文中一共展示了BaseIOIOLooper类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createIOIOLooper
import ioio.lib.util.BaseIOIOLooper; //导入依赖的package包/类
@Override
protected IOIOLooper createIOIOLooper() {
return new BaseIOIOLooper(){
Uart uart;
OutputStream ostream;
@Override
protected void setup() throws ConnectionLostException, InterruptedException {
Thread.sleep(5000);
//led_ = ioio_.openDigitalOutput(0, true);
uart = ioio_.openUart(35,34,57600, Uart.Parity.NONE, Uart.StopBits.ONE);
ostream = uart.getOutputStream();
}
@Override
public void loop() throws ConnectionLostException, InterruptedException {
try {
ostream.write("sending data".getBytes());
Thread.sleep(100);
}
catch (IOException ex) {
//showToast("CommunicationThread: "+ ex.getMessage());
Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
}
}
};
}
示例2: createIOIOLooper
import ioio.lib.util.BaseIOIOLooper; //导入依赖的package包/类
@Override
protected IOIOLooper createIOIOLooper() {
return new BaseIOIOLooper() {
private DigitalOutput led_;
@Override
protected void setup() throws ConnectionLostException,
InterruptedException {
led_ = ioio_.openDigitalOutput(IOIO.LED_PIN);
}
@Override
public void loop() throws ConnectionLostException,
InterruptedException {
led_.write(false);
Thread.sleep(500);
led_.write(true);
Thread.sleep(500);
}
};
}
示例3: createIOIOLooper
import ioio.lib.util.BaseIOIOLooper; //导入依赖的package包/类
@Override
public IOIOLooper createIOIOLooper(String connectionType, Object extra) {
return new BaseIOIOLooper() {
private DigitalOutput led_;
@Override
protected void setup() throws ConnectionLostException,
InterruptedException {
led_ = ioio_.openDigitalOutput(IOIO.LED_PIN, true);
}
@Override
public void loop() throws ConnectionLostException,
InterruptedException {
led_.write(!ledOn_);
Thread.sleep(10);
}
};
}
示例4: createIOIOLooper
import ioio.lib.util.BaseIOIOLooper; //导入依赖的package包/类
@Override
protected IOIOLooper createIOIOLooper() {
MLog.d(TAG, "createIOIOLooper");
return new BaseIOIOLooper() {
@Override
protected void setup() throws ConnectionLostException, InterruptedException {
MLog.d(TAG, "Setup in IOIOLooper");
callback_.onConnect(ioio_);
callback_.setup();
// abort_ = (resp != null && resp != true);
}
@Override
public void loop() throws ConnectionLostException, InterruptedException {
if (abort_) {
this.disconnected();
} else {
callback_.loop();
// abort_ = (resp != null && resp != true);
Thread.sleep(100);
}
}
@Override
public void disconnected() {
super.disconnected();
MLog.d("IOIOBoardService", "-----> Disconnecting <-----");
ioio_.disconnect();
}
};
}
示例5: createIOIOLooper
import ioio.lib.util.BaseIOIOLooper; //导入依赖的package包/类
@Override
protected IOIOLooper createIOIOLooper() {
return new BaseIOIOLooper() {
private AnalogInput in43, in44;
@Override
protected void setup() throws ConnectionLostException,
InterruptedException {
// led_ = ioio_.openDigitalOutput(IOIO.LED_PIN);
in43 = ioio_.openAnalogInput(43);
in44 = ioio_.openAnalogInput(44);
}
@Override
public void loop() throws ConnectionLostException,
InterruptedException {
//led_.write(ledState);
//ledState = !ledState;
double v, sm, v1, v2;
try {
v = in43.read();
ma43.newFrame(v);
sm = ma43.median();
v1 = sm;
v = in44.read();
ma44.newFrame(v);
sm = ma44.median();
v2 = sm;
maDiff.newFrame((v2 - v1));
int status = 0;
if (v1 < 0.4 && v2 < 0.4) {
// off
} else {
// get dists
double val = maDiff.median();
Log.i(TAG, "Diff: " + val);
dists[0] = Math.abs(class1 - val);
dists[1] = Math.abs(class2 - val);
dists[2] = Math.abs(class3 - val);
int idx = 0;
double minVal = Double.MAX_VALUE;
for (int i = 0; i < 3; i++) {
if (dists[i] < minVal) {
idx = i;
minVal = dists[i];
}
}
status = idx + 1;
}
if (statusTrig.newFrame(status)) {
AssistanceReport.postAssistanceStatus(new ModeChangeEvent(status, System.currentTimeMillis()), phoneID);
}
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
Log.i("IOIO", "error while reading IOIO");
e1.printStackTrace();
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
};
}