国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

python - RPi.GPIO中wait_for_edge和event_detected有什么區(qū)別?

瀏覽:113日期:2022-07-30 10:29:31

問(wèn)題描述

比如說(shuō)我要監(jiān)聽(tīng)一個(gè)下降沿觸發(fā)的中斷請(qǐng)求,并且執(zhí)行一段函數(shù),究竟該怎么寫(xiě)代碼,網(wǎng)上各種文檔都是互相抄襲國(guó)外的機(jī)翻文檔,完全無(wú)法正常閱讀,請(qǐng)各位高手幫忙解答一下,謝謝!!!

問(wèn)題解答

回答1:

The wait_for_edge() function is designed to block execution of your program until an edge is detected.

翻譯過(guò)來(lái)就是wait_for_edge會(huì)阻塞程序,直到有一個(gè)邊沿事件被觸發(fā)

The event_detected() function is designed to be used in a loop with other things, but unlike polling it is not going to miss the change in state of an input while the CPU is busy working on other things.

event_detected就是事件觸發(fā)

具體到你這里,要中斷請(qǐng)求,那只能是用事件方式觸發(fā)了。

那第一步是讓接口電阻上拉

GPIO.setup(channel, GPIO.IN, pull_up_down=GPIO.PUD_UP)

然后

GPIO.add_event_detect(channel, GPIO.FALLING)GPIO.add_event_callback(channel, callback_func)

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 吐鲁番市| 武义县| 黑龙江省| 湖南省| 古蔺县| 大田县| 商洛市| 平阳县| 庐江县| 灵台县| 府谷县| 阿瓦提县| 措勤县| 平果县| 宜兴市| 吉安县| 昭苏县| 盐边县| 黄骅市| 南乐县| 许昌市| 开封县| 芦山县| 奉节县| 略阳县| 且末县| 中方县| 滁州市| 丽江市| 巴楚县| 共和县| 洛隆县| 静海县| 焉耆| 古蔺县| 张家口市| 响水县| 常德市| 大渡口区| 当涂县| 和平县|