您的位置:首页 > 编程语言 > Go语言

基于DragonBord410C的智能遥控

2017-10-16 16:25 197 查看
前段时间公司有一个基于高通410c开发板的智能遥控项目,该项目的功能点如下:编码解析,编码学习,远程控制。下面我将为大家一一讲解这些功能的实现和APP的整体架构。


主界面详情:



APP的架构:



发送Code:

public static void WriteData(String path, String content) {
FileOutputStream fos = null;
File file = new File(path);
if (file.exists()) {
try {
fos = new FileOutputStream(file);
Log.e("File", "FileWriter");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
byte[] array = content.getBytes();
try {
fos.write(array);
} catch (IOException e) {
e.printStackTrace();
}
try {
fos.flush();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}

}

}


解析编码:

public void onClick(View view) {
switch (view.getId()) {
case R.id.learn_mode:
im.setVisibility(View.VISIBLE);
message = new Message();
cancle_learn.setVisibility(View.VISIBLE);
cancle_learn.setEnabled(true);
Config.WriteData(Config.LEARN_PATH, "1");
timer.schedule(new TimerTask() {
@Override
public void run() {
String a = Config.Redata(Config.STATUS);
if (a.startsWith("0")) {
/* Config.Redata(Config.LEARN_PATH);*/
irCode = new ET4007IRDevice().readlearncode();
if (irCode.isValid()) {
irString = irCode.toString();
} else {
irString = "ERROR";
}
Bundle bundle = new Bundle();
bundle.putString("key", irString);
message.setData(bundle);
handler.sendMessage(message);
timer.cancel();

}

}
}, 0, 1000);

break;
case R.id.mode_send:
Config.WriteData(Config.SEND_PATH, irString);
break;
case R.id.cancle_learn:
im.setVisibility(View.INVISIBLE);
cancle_learn.setVisibility(View.INVISIBLE);
setEnabled(false);
timer.cancel();
break;
case R.id.save_value:
DialogUtil.launchdialog(this);
break;

}


主要用到的SO:

public class RemoteCore {
private static final String libSoName = "IRCore";
static {
try {
System.loadLibrary(libSoName);
Log.e("JNI",libSoName+" load finished");
}catch (Exception e){
Log.e("JNI"," exception "+e.getMessage());
}

}

public native static IRCode ET4007Learn(byte[] codes);

public native static byte[] readLearnIRCode();

public native static int IRinit();
}


OK,大功告成,简单的智能遥控就实现啦!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  远程控制 架构