基於DragonBord410C的智能遙控

前段時間公司有一個基於高通410c開發板的智能遙控項目,該項目的功能點如下:編碼解析,編碼學習,遠程控制。下面我將爲大家一一講解這些功能的實現和APP的整體架構。

主界面詳情:

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,大功告成,簡單的智能遙控就實現啦!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章