npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lifekit-curtain

v1.0.0

Published

lifekit-curtain

Downloads

5

Readme

RS485电动窗帘模块

本模块主要面向SunFlower电动窗帘电机进行界面控制与必要的接口暴露,方便系统对电机模块的控制与编程

推荐的淘宝商家:https://detail.tmall.com/item.htm?id=551532457638&spm=a1z09.2.0.0.67002e8d4GBTMK&_u=gnsauvqa7f0

联系卖家时说明要RS485款式的就可以了

依赖环境

nodejs >=10.0.0

lifekit >= 1.0.21

安装运行

  • 安装
lifekit install lifekit-curtain

安装完成后需要配置串口路径与设备地址,在如下文件中配置:

./lifekit-curtain/src/codeMap.js

//串口路径
const SerialPath = "/dev/tty.usbserial-AC01QKHG";
//设备地址
const dev_addr = "1234";
  • 运行

启动lifekit服务,访问如下路径: http://localhost:1337/lifekit-curtain/

模块API

模块引入


//具体引用路径请动态修改
const handler = require("/engine/lifekit-curtain/src/curtainHandler");

方法介绍与代码示例

  • open

    打开窗帘

    代码示例:

    await handler.open();
    
  • close

    关闭窗帘

    代码示例:

    await handler.close();
    
  • stop

    停止窗帘电机

    代码示例:

    await handler.stop();
    
  • percent(per)

    控制百分比,per是一个十六进制的数,比如 1E 代表十进制的30,则表示控制窗帘打开到30%的位置上

    代码示例:

    await handler.percent("1E");
    
  • delway

    删除百分比设置

    代码示例:

    await handler.delway();
    
  • resetfactory

    恢复出厂设置

    代码示例:

    await handler.resetfactory();
    
  • setscenariomode(modeNum)

    设置情景模式,每台电机最多可以设置 20 个情景模式(数据内容为情景模式号,十六进制)

    代码示例:

    await handler.setscenariomode("08");
    
  • runscenariomode(modeNum)

    运行情景模式,让电机运行没有设置的情景时,电机不会运行,返回 0xFF。当电机没有设置行程时,不能运行情景模式,返回 0xFF。 当设备掉电后重新上电,此时也不能运行情景模式,可以先执行打开或者关闭命令恢复行程后,才能运行情景模式。

    代码示例:

    await handler.runscenariomode("08");
    
  • delscenariomode(modeNum)

    删除情景模式

    代码示例:

    await handler.delscenariomode("08");
    
  • position

    获取位置信息.当设备有设置行程时,设备返回当前行程(0x00~0x64),0x00 表示完全关闭,0x64 表示完全打开。当设备没有设置行程时,设备返回 0xFF

    代码示例:

    let num = await handler.position();
    console.log(num);
  • direction

    获取方向状态。0x00-默认方向,0x01-反方向,此方向用于判断开合帘打开闭合方向,比如发送打开控制命令时开合帘闭合,此时请执行读方向,再写入相反 方向来换向,使控制命令与电机实际运行一致。

    代码示例:

    let num = await handler.direction();
    console.log(num);
  • enginestatus

    获取电机状态

    00-表示电机停止。

    01-表示电机打开。

    02-表示电机关闭。

    03-表示电机处于设置状态

    代码示例:

    let num = await handler.enginestatus();
    console.log(num);
  • writeaddres

    写设备地址,此方法必须先按住窗帘电机的reset键五秒之后才能生效

    代码示例:

    await handler.writeaddres();
    
  • setdirection(str)

    设置方向

    00-正向

    01-反向

    代码示例:

    await handler.setdirection("01");