0.0.1 • Published 1 year ago
jcode-ble v0.0.1
Jcode-Bluetooth
用码上掘金操作蓝牙智能设备。
已支持设备
- Mipow-Playbulb-LED | GATT ✔︎ | SPP x
- Pixoo 16x16 | GATT x | SPP ✔︎
- 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);
}
});
0.0.1
1 year ago