专栏名称: 阿群1986
目录
相关文章推荐
中核集团  ·  新春走基层 | 媒体镜头下的中核坚守者 ·  昨天  
中核集团  ·  别再做“法外之徒”了! ·  2 天前  
GiantPandaCV  ·  DeepSeek-V3 FP8量化浅析 ·  4 天前  
中核集团  ·  中核集团各系统召开2025年度工作会议② ·  3 天前  
51好读  ›  专栏  ›  阿群1986

AndroidThings应用程序学习笔记

阿群1986  · 简书  ·  · 2018-05-08 23:37

正文

如何关闭GPIO

    onDestroy(...) {
        if (mLedGpio != null) {
            try {
                mLedGpio.close();
            } catch (IOException e) {
                Log.e(TAG, "Error closing LED GPIO", e);
            } finally {
                mLedGpio = null;
            }
            mLedGpio = null;//貌似与finally重复了
        }
    }

如何打开GPIO管脚

    private Gpio mLedGpio;
    private ButtonInputDriver mButtonInputDriver;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d(TAG, "Hello Android Things!");
        Log.i(TAG, "Starting ButtonActivity");

        PeripheralManagerService pioService = new PeripheralManagerService();
        try {
            Log.i(TAG, "Configuring GPIO pins");
            mLedGpio = pioService.openGpio(BoardDefaults.getGPIOForLED());
            mLedGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
//...






请到「今天看啥」查看全文