本文整理汇总了Java中com.physicaloid.lib.usb.driver.uart.ReadLisener类的典型用法代码示例。如果您正苦于以下问题:Java ReadLisener类的具体用法?Java ReadLisener怎么用?Java ReadLisener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReadLisener类属于com.physicaloid.lib.usb.driver.uart包,在下文中一共展示了ReadLisener类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onClickReadCallback
import com.physicaloid.lib.usb.driver.uart.ReadLisener; //导入依赖的package包/类
public void onClickReadCallback(View v) {
if (readCallbackOn) {
mPhysicaloid.clearReadListener();
btReadCallback.setText("ReadCallbackOff");
btRead.setEnabled(true);
readCallbackOn = false;
} else {
mPhysicaloid.addReadListener(new ReadLisener() {
@Override
public void onRead(int size) {
byte[] buf = new byte[size];
mPhysicaloid.read(buf, size);
tvAppend(tvRead, Html.fromHtml("<font color=blue>" + new String(buf) + "</font>"));
}
});
btReadCallback.setText("ReadCallbackOn");
btRead.setEnabled(false);
readCallbackOn = true;
}
}
开发者ID:cattaka,项目名称:PhysicaloidVc,代码行数:21,代码来源:PhysicaloidTestActivity.java
示例2: openDevice
import com.physicaloid.lib.usb.driver.uart.ReadLisener; //导入依赖的package包/类
private void openDevice() {
if (!mPhysicaloid.isOpened()) {
// default 9600bps
if (mPhysicaloid.open()) {
mPhysicaloid.addReadListener(new ReadLisener() {
String readStr;
// Callback when reading one or more size buffer
@Override
public void onRead(int size) {
byte[] buf = new byte[size];
mPhysicaloid.read(buf, size);
try {
readStr = new String(buf, "UTF-8");
} catch (UnsupportedEncodingException e) {
Log.e(TAG, e.toString());
return;
}
}
});
}
}
}
开发者ID:guiruiz,项目名称:Twiteckon,代码行数:25,代码来源:TwitterApp.java
示例3: init
import com.physicaloid.lib.usb.driver.uart.ReadLisener; //导入依赖的package包/类
public boolean init() {
if(mPhysicaloid.open()) {
mPhysicaloid.addReadListener(new ReadLisener() {
// callback when reading one or more size buffer
@Override
public void onRead(int size) {
byte[] buf = new byte[size];
int readSize = mPhysicaloid.read(buf, size);
Log.d(TAG, String.format("%02d ", size));
if(readSize > 2) {
mAdcVal = decodePacket(buf);
mPercentage = getPercentageFromAdc(mAdcVal);
}
}
});
return true;
} else {
return false;
}
}
开发者ID:ksksue,项目名称:PocketDuinoAlcoholMeter,代码行数:22,代码来源:AlcoholMeter.java
示例4: addReadListener
import com.physicaloid.lib.usb.driver.uart.ReadLisener; //导入依赖的package包/类
/**
* Adds read listener
*
* @param listener ReadListener
* @return true : successful , false : fail
* @throws RuntimeException
*/
public boolean addReadListener(ReadLisener listener) throws RuntimeException {
synchronized (LOCK_READ) {
if (mSerial == null) return false;
if (listener == null) return false;
mSerial.addReadListener(listener);
return true;
}
}
开发者ID:cattaka,项目名称:PhysicaloidVc,代码行数:16,代码来源:Physicaloid.java
示例5: onClickOpen
import com.physicaloid.lib.usb.driver.uart.ReadLisener; //导入依赖的package包/类
public void onClickOpen(View v) {
if (mPhysicaloid.open()) { // default 9600bps
setEnabledUi(true);
mPhysicaloid.addReadListener(new ReadLisener() {
String readStr;
// callback when reading one or more size buffer
@Override
public void onRead(int size) {
byte[] buf = new byte[size];
mPhysicaloid.read(buf, size);
try {
readStr = new String(buf, "UTF-8");
} catch (UnsupportedEncodingException e) {
Log.e(TAG, e.toString());
return;
}
// UI thread
tvAppend(tvRead, readStr);
}
});
}
}
开发者ID:cattaka,项目名称:PhysicaloidVc,代码行数:28,代码来源:Tutorial4Activity.java
示例6: onClickOpen
import com.physicaloid.lib.usb.driver.uart.ReadLisener; //导入依赖的package包/类
public void onClickOpen(View v) {
if (mPhysicaloid.open()) { // default 9600bps
setEnabledUi(true);
//****************************************************************
// TODO : add read callback
mPhysicaloid.addReadListener(new ReadLisener() {
String readStr;
// callback when reading one or more size buffer
@Override
public void onRead(int size) {
byte[] buf = new byte[size];
mPhysicaloid.read(buf, size);
try {
readStr = new String(buf, "UTF-8");
} catch (UnsupportedEncodingException e) {
Log.e(TAG, e.toString());
return;
}
// UI thread
tvAppend(tvRead, readStr);
}
});
//****************************************************************
}
}
开发者ID:cattaka,项目名称:PhysicaloidVc,代码行数:31,代码来源:Tutorial3Activity.java
示例7: openDevice
import com.physicaloid.lib.usb.driver.uart.ReadLisener; //导入依赖的package包/类
private void openDevice() {
if (!mPhysicaloid.isOpened()) {
if (mPhysicaloid.open()) { // default 9600bps
setEnabledUi(true);
mPhysicaloid.addReadListener(new ReadLisener() {
String readStr;
// callback when reading one or more size buffer
@Override
public void onRead(int size) {
byte[] buf = new byte[size];
mPhysicaloid.read(buf, size);
try {
readStr = new String(buf, "UTF-8");
} catch (UnsupportedEncodingException e) {
Log.e(TAG, e.toString());
return;
}
// UI thread
tvAppend(tvRead, readStr);
}
});
}
}
}
开发者ID:cattaka,项目名称:PhysicaloidVc,代码行数:29,代码来源:Tutorial5Activity.java
示例8: addReadListener
import com.physicaloid.lib.usb.driver.uart.ReadLisener; //导入依赖的package包/类
/**
* Adds read listener
* @param listener ReadListener
* @return true : successful , false : fail
* @throws RuntimeException
*/
public boolean addReadListener(ReadLisener listener) throws RuntimeException {
synchronized (LOCK_READ) {
if(mSerial == null) return false;
if(listener == null) return false;
mSerial.addReadListener(listener);
return true;
}
}
开发者ID:RobotPajamas,项目名称:SimpleUSB,代码行数:15,代码来源:Physicaloid.java
示例9: onRead
import com.physicaloid.lib.usb.driver.uart.ReadLisener; //导入依赖的package包/类
@ProtoMethod(description = "adds a read callback that is called when one or more bytes are read", example = "")
@ProtoMethodParam(params = {"function(data)"})
public void onRead(final onReadCB callbackfn) {
if (mPhysicaloid.isOpened()) {
mPhysicaloid.addReadListener(new ReadLisener() {
String readStr;
// callback when reading one or more size buffer
@Override
public void onRead(int size) {
byte[] buf = new byte[size];
mPhysicaloid.read(buf, size);
try {
readStr = new String(buf, "UTF-8");
// MLog.d(TAG, " " + readStr);
} catch (UnsupportedEncodingException e) {
// MLog.d(TAG, e.toString());
return;
}
//MLog.network(mContext, TAG, "msg " + msg);
//MLog.network(mContext, TAG, "readStr " + readStr);
if (!mEndLine.isEmpty()) {
msg = msg + readStr;
int newLineIndex = msg.indexOf('\n');
//MLog.network(mContext, TAG, "index " + newLineIndex);
String msgReturn = "";
if (newLineIndex != -1) {
msgReturn = msg.substring(0, newLineIndex);
msg = msg.substring(newLineIndex + 1, msg.length());
//MLog.network(mContext, TAG, "msgReturn " + msgReturn);
}
if (msgReturn.trim().equals("") == false) {
final String finalMsgReturn = msgReturn;
mHandler.post(new Runnable() {
@Override
public void run() {
callbackfn.event(finalMsgReturn);
}
});
}
} else {
mHandler.post(new Runnable() {
@Override
public void run() {
callbackfn.event(readStr);
}
});
}
}
});
}
}
开发者ID:victordiaz,项目名称:phonk,代码行数:60,代码来源:PArduino.java
示例10: addReadListener
import com.physicaloid.lib.usb.driver.uart.ReadLisener; //导入依赖的package包/类
/**
* Adds read listener
*
* @param listener ReadListener
*/
abstract public void addReadListener(ReadLisener listener);
开发者ID:cattaka,项目名称:PhysicaloidVc,代码行数:7,代码来源:SerialCommunicator.java
示例11: addReadListener
import com.physicaloid.lib.usb.driver.uart.ReadLisener; //导入依赖的package包/类
/**
* Adds read listener
* @param listener ReadListener
*/
abstract public void addReadListener(ReadLisener listener);
开发者ID:RobotPajamas,项目名称:SimpleUSB,代码行数:6,代码来源:SerialCommunicator.java
注:本文中的com.physicaloid.lib.usb.driver.uart.ReadLisener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论