LED 使用¶
前言¶
Face-RK3399 开发板上有 2 个 LED 灯:Blue(GPIO2_D3)和Yellow(GPIO2_D2)。
LED可通过使用 LED 设备子系统或者直接操作 GPIO 控制该 LED。
标准的 Linux 专门为 LED 设备定义了 LED 子系统。 在 Face-RK3399 开发板中的两个 LED 均以设备的形式被定义。
用户可以通过 /sys/class/leds/ 目录控制这两个 LED。
开发板上的 LED 的默认状态为:
Blue: 系统上电时打开
Yellow:用户自定义
用户可以通过 echo 向其 brightness属性输入命令控制每一个 LED:
root@rk3399_firefly_face:~ # echo 0 >/sys/class/leds/firefly:blue:power/brightness //蓝灯灭
root@rk3399_firefly_face:~ # echo 1 >/sys/class/leds/firefly:blue:power/brightness //蓝灯亮
在 kernel/arch/arm64/boot/dts/rockchip/rk3399-firefly-port.dts 文件中定义LED节点,具体定义如下:
leds {
compatible = "gpio-leds";
power{
label = "firefly:blue:power";
linux,default-trigger = "ir-power-click";
default-state = "on";
gpios = <&gpio2 27 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&led_power>;
};
user{
label = "firefly:yellow:user";
linux,default-trigger = "ir-user-click";
default-state = "off";
gpios = <&gpio2 26 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&led_user>;
};
};
若客户购买的是Face-X1人脸识别一体机,则控制补光灯板上面三个控制灯对应如下:
/sys/class/leds/face:green:user/brightness //绿灯
/sys/class/leds/face:red:user/brightness //红灯
/sys/class/leds/face:white:user/brightness //白灯
在 kernel/arch/arm64/boot/dts/rockchip/rk3399-firefly-face.dtsi 文件中定义LED节点,具体定义如下:
face_leds {
compatible = "gpio-leds";
face_green_led: face_green {
label = "face:green:user";
linux,default-trigger = "ir-user-click";
default-state = "off";
gpios = <&gpio3 0 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&led_user>;
};
face_red_led: face_red {
label = "face:red:user";
linux,default-trigger = "ir-user-click";
default-state = "off";
gpios = <&gpio3 1 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&led_user>;
};
face_white_led: face_white {
label = "face:white:user";
linux,default-trigger = "ir-user-click";
default-state = "on";
gpios = <&gpio4 27 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&led_user>;
};
};
若客户购买的是Face-X2人脸识别一体机,则控制补光灯板上面三个控制灯对应如下:
/sys/class/leds/face:green:user/brightness //绿灯
/sys/class/leds/face:red:user/brightness //红灯
/sys/pwm/face_white_led //白灯
其中白灯亮度是可调的
echo x > /sys/pwm/face_white_led
x范围0-8