jcode-ble
v0.0.1
Published
jcode web bluetooth lib
Downloads
2
Readme
Jcode-Bluetooth
用码上掘金操作蓝牙智能设备。
已支持设备
- [x] Mipow-Playbulb-LED | GATT ✔︎ | SPP x
- [x] Pixoo 16x16 | GATT x | SPP ✔︎
- [x] Pixoo-Max | GATT x | SPP ✔︎
逐步添加中...
使用方法
控制Playbulb智能LED
import {Playbulb} from './jcode-ble.js';
const device = new Playbulb();
const button = document.querySelector('button');
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
button.addEventListener('click', async () => {
await device.connect();
let hue = 0;
while (true) {
await device.setColor(`hsl(${hue}, 100%, 50%)`);
hue = (hue + 1) % 360;
await sleep(100);
}
});