Interface GpioHandle

Gpio操控句柄

Description

用 gpio.open() 打开gpio后,可返回gpio的控制句柄。或者用 gpio.handle() 获取gpio当前的句柄。

Hierarchy

  • GpioHandle

Properties

Methods

Properties

id: Byte

引脚编号

Methods

  • 引脚输出能力。

    Returns 0 | 2 | 1 | 3

  • 设置引脚输出能力。

    Parameters

    • n: 0 | 2 | 1 | 3

    Returns GpioHandle

  • 设置引脚中断处理。

    Parameters

    • handler: ((level: boolean) => null | void)

      中断回调函数。null表示关闭中断。

        • (level: boolean): null | void
        • Parameters

          • level: boolean

          Returns null | void

    • Optional options: {
          debounce?: number;
          trigger?: "both" | "rising" | "falling" | "low" | "high";
      }
      • Optional debounce?: number

        防抖动时间,以毫秒计。默认为0

      • Optional trigger?: "both" | "rising" | "falling" | "low" | "high"

        中断触发类型, rising=上升沿, falling=下降沿, both=上升/下降沿, low=低电平, high=高电平. 默认为 both.

    Returns GpioHandle

  • 读引脚当前电平。true=高电平,false=低电平。

    Returns boolean

  • 引脚输出电平。true=高电平,false/0=低电平。

    Parameters

    • b: number | boolean

    Returns GpioHandle