archsupport

package
v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

README

跨平台

这里放置一些对特定硬件的支持库,一般指的是定制化网关产品。如果有不同操作系统上的实现库,建议统一放置此处。可参考下面的hello文件里面的程序。

当前兼容

EEKIT 网关

EEKIT 是 RULEX 团队的默认硬件,操作系统为 64位OpenWrt、Armbian, CPU 架构为 64位全志H3。EEKIT 网关的lua标准库命名空间为 eekit

树莓派4B+

除此之外,还对 树莓派4B的 GPIO 做了支持。树莓派的lua标准库命名空间为 raspberry

环境变量

如果要启用硬件特性,需要在启动的时候加入 ARCHSUPPORT 环境变量来指定运行的版本, 例如要在 EEKIT-H3网关上运行:

ARCHSUPPORT=EEKITH3 rulex run

支持硬件列表

硬件名 环境参数 示例
EEKIT H3版本网关 EEKITH3 ARCHSUPPORT=EEKITH3 rulex run
EEKIT T507版本网关 EEKITT507 ARCHSUPPORT=EEKITT507 rulex run
EEKIT T113版本网关 EEKITT113 ARCHSUPPORT=EEKITT113 rulex run
树莓派4B、4B+ RPI4 ARCHSUPPORT=RPI4B rulex run
玩客云S805 WKYS805 ARCHSUPPORT=WKYS805 rulex run

警告: 这些属于板级高级功能,和硬件架构以及外设有关,默认关闭。 如果你自己需要定制,最好针对自己的硬件进行跨平台适配, 如果没有指定平台,可能会导致预料之外的结果。

常见函数

EEKIT H3版本网关
  1. GPIO 设置

    eekith3:GPIOSet(Pin, Value)
    

    参数表

    参数名 类型 说明
    Pin int GPIO引脚
    Value int 高低电平, 0、1
  2. GPIO 获取

    eekith3:GPIOGet(Pin)
    
    参数名 类型 说明
    Pin int GPIO引脚

示例脚本

  1. 玩客云WS1608
function Main(arg)
    while true do
        ws1608:GPIOSet("red", 1)
        applib:Sleep(2000)
        ws1608:GPIOSet("red", 0)
        applib:Sleep(2000)
    end
end

必须使用这个系统:Linux aml-s812 5.9.0-rc7-aml-s812 #20.12 SMP Sun Dec 13 22:50:05 CST 2020 armv7l GNU/Linux, Armbian 20.12 Buster \l

  1. EEKIT 网关
function Main(arg)
    while true do
        eekith3:GPIOSet(6, 1)
        applib:Sleep(2000)
        eekith3:GPIOSet(7, 0)
        applib:Sleep(2000)
    end
end

Documentation

Index

Constants

View Source
const (
	AmlogicWKYS805_R string = "red"
	AmlogicWKYS805_G string = "green"
	AmlogicWKYS805_B string = "blue"
)

玩客云WS1608有一个RGB LED,其系统内部已经直接支持进设备树:

R -> /sys/class/leds/onecloud\:red\:alive/brightness
G -> /sys/class/leds/onecloud\:green\:alive/brightness
B -> /sys/class/leds/onecloud\:blue\:alive/brightness

Variables

This section is empty.

Functions

func AmlogicWKYS805_RGBGet added in v0.5.2

func AmlogicWKYS805_RGBGet(pin string) (int, error)

func AmlogicWKYS805_RGBSet added in v0.5.2

func AmlogicWKYS805_RGBSet(pin string, value int) (bool, error)

func EEKIT_GPIOGet

func EEKIT_GPIOGet(pin int) (int, error)

explain:read gpio Pin: gpio pin return:1 is high 0 is low

func EEKIT_GPIOSet

func EEKIT_GPIOSet(pin, value int) (bool, error)

explain:set gpio Pin: gpio pin Value:gpio level 1 is high 0 is low

func HelloWorld

func HelloWorld()

* * 这是Linux库函数调用,本案例没有意义,主要用来展示规范化 *

func RASPI4_GPIOGet

func RASPI4_GPIOGet(pin int) (int, error)

func RASPI4_GPIOSet

func RASPI4_GPIOSet(pin, value int) (bool, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL