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

wonderbits

v2.0.1

Published

wonderbits hardware sdk powered by mfeducation

Downloads

23

Readme

WonderBits SDK

使用方法

第一步

安装 WonderBits JS SDK

npm install wonderbits

第二步

安装对应系统的MFElink软件并打开

第三步

初始化 WonderBits JS SDK

const wonderBitsSdk = require("wonderbits");
wonderBitsSdk.initConnection(() => {
  console.log("初始化成功");
});

第四步

使用具体模块。

左侧为具体模块列表。

主控模块连接电脑,其他模块连接到主控模块上。但是,左侧中任意一种模块可能有多块同时插入主控模块,所以,需要有自己的序号来分辨是该种模块的第几个。

模块序号默认从 1 开始。

当左侧某种模块还未插入到主控时,插入该种模块到主控模块上,此模块的序号会被设为 1。再次插入该种模块,则这两个模块的序号会被随机设为 1 和 2,以此类推。

所以,每个模块方法的第一个参数为模块序号。

了解了模块序号,就可以根据需要,在第三步的回调成功之后,即console.log("初始化成功");之后,调用各模块方法

例子

下面就是调用具体模块的形式:

wonderBitsSdk.模块名.模块方法

具体模块名请参照左侧模块列表。

常用的函数有两类,一类为获取类函数,一类为设置类函数:

获取类函数的例子如下:

获取超声波检测的距离值(返回值为Promise类型)

wonderBitsSdk.ultrasonic.getDistance(1).then(distance => {
  console.log(distance);
});

设置类函数的例子如下:

设置彩灯颜色

wonderBitsSdk.led.setRgb(1, 255, 0, 0);

每个模块的具体方法,请点击左侧模块列表查看.

高级用法说明

监听硬件上传的原始数据

wonderBitsSdk.setOnOriginDataReceivedCallback(data => {
  console.log(data);
});

监听硬件复位回调

wonderBitsSdk.addResetListener(() => {
  console.log("reset");
});

清除监听硬件复位回调

wonderBitsSdk.clearResetListener();

获取连接在板子上的模块

let moduleNames = wonderBitsSdk.getConnectedModuleNames();

事件

含义:当指定情况发生时,会收到板子上传的数据,此时会调用注册事件时的callback(obj),将处理后的数据返回。 返回数据的详细类型参见事件回调

事件回调

事件将会返回 json value 的类型根据对应事件值的不同而不同

{ "module": `${moduleName}`, "source": `${sourceName}`, "value": `${value}` }