lialong1st

CPU:RK3288

系统:Android 5.1

功能:上层 app 控制 led 亮灭

开发板:Firefly RK3288

 

MainActivity.java

package com.aaron.led;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.aaron.link.LedNative;

public class MainActivity extends AppCompatActivity {
    private final String TAG = "LedApp";
    Button led_on;
    Button led_off;
    LedNative lednative;

    View.OnClickListener clickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.btn_on:
                    Log.d(TAG, "Led On");
                    lednative.onDev();
                    break;
                case R.id.btn_off:
                    Log.d(TAG, "Led Off");
                    lednative.offDev();
                    break;
                default:
                    break;
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        led_on = findViewById(R.id.btn_on);
        led_off = findViewById(R.id.btn_off);

        led_on.setOnClickListener(clickListener);
        led_off.setOnClickListener(clickListener);

        lednative = new LedNative();

        lednative.openDev();
        Log.d(TAG, "open Dev");
    }

    protected void onDestroy() {

        super.onDestroy();

        lednative.closeDev();
        Log.d(TAG, "close Dev");
    }
}

 

LedNative.java

package com.aaron.link;

/**
 * Created by Administrator on 2018/3/20.
 */

public class LedNative {
    static{
        System.loadLibrary("firefly_led_jni");
    }

    public native void openDev();
    public native int onDev();
    public native int offDev();
    public native int closeDev();
}

 

分类:

技术点:

相关文章:

  • 2021-09-02
  • 2021-10-17
  • 2021-07-09
  • 2022-12-23
  • 2022-01-14
  • 2021-08-29
  • 2021-10-21
  • 2021-09-14
猜你喜欢
  • 2021-11-28
  • 2021-12-09
  • 2021-11-19
  • 2021-10-01
  • 2022-12-23
  • 2021-07-17
  • 2022-02-20
相关资源
相似解决方案