setup() 在 JS 中使用 PI 的 GPIO 引脚做什么

What does setup() do in JS working with PI's GPIO pins

每次你使用 Raspberry Pi 的 GPIO 引脚与 JavaScript / NodeJS,你必须使用 x.setup('something')x 是你导入的库或者包。我知道你的应用程序没有它就不能工作,但是 setup() 有什么作用,你给它的参数是什么?

Setup documentation (github):

设置(模式) .>= 0.1.1 一个方便的函数来设置 wiringPi 模式可以是以下值之一:

wpi: sets up pin numbering with wiringPiSetup >= 0.1.1
gpio: sets up pin numbering with wiringPiSetupGpio >= 0.1.1
sys: sets up pin numbering with wiringPiSetupSys >= 0.1.1
phys: sets up pin numbering with wiringPiSetupPhys >= 1.0.0

有关引脚编号系统的更多信息here

注意:>= 2.0.0 不再接受未指定模式的调用设置。 (在 < 2.0.0 中默认为 wpi)

由@Roland Starke 提供。