欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

基于DragonBord410C的智能遥控

程序员文章站 2022-05-15 20:55:03
...
前段时间公司有一个基于高通410c开发板的智能遥控项目,该项目的功能点如下:编码解析,编码学习,远程控制。下面我将为大家一一讲解这些功能的实现和APP的整体架构。

主界面详情:

基于DragonBord410C的智能遥控

APP的架构:

基于DragonBord410C的智能遥控

发送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,大功告成,简单的智能遥控就实现啦!

相关标签: 远程控制 架构