0.0.3 • Published 2 years ago
@hangtime/motherboard v0.0.3
Motherboard
A Web Bluetooth API for the Griptonite Motherboard + Beastmaker used by climbers to improve finger strength.
- ✅ Connect with a Motherboard
- ✅ Read/write data
- ❎ Calibrate
- ❎ Output weight
Development
git clone https://github.com/Stevie-Ray/motherboard
cd motherboard
npm install
Install
$ npm install @hangtime/motherboard
Example usage
Simply importing the utilities you need from @hangtime/motherboard
<button id="bluetooth" type="button">Connect Motherboard</button>
import Motherboard, { connect, disconnect, read, write, notify } from "@hangtime/motherboard"
const bluetoothButton = document.querySelector("#bluetooth")
bluetoothButton.addEventListener("click", () => {
connect(async () => {
// Listen for notifications
notify((data: object) => {
console.log(data)
})
// read battery + device info
await read(Motherboard.bat)
await read(Motherboard.devMn)
await read(Motherboard.devHr)
await read(Motherboard.devFr)
// Calibrate?
await write(Motherboard.uartTx, "C", 5000)
// Read stream?
await write(Motherboard.led01, "1", 2500)
await write(Motherboard.led02, "0", 2500)
await write(Motherboard.uartTx, "S30", 5000)
// Read stream (2x)?
await write(Motherboard.led01, "0", 2500)
await write(Motherboard.led02, "1", 2500)
await write(Motherboard.uartTx, "S30", 5000)
// disconnect from device after we are done
disconnect()
})
})
License
MIT © Stevie-Ray Hartog