Kei18 / toio.js-raspi

Library for controlling toio™Core Cube

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

toio.js@Raspberry Pi

Library for controlling toio™Core Cube using Node.js.

💻 Getting Started

Prerequisites

  • Node.js >= 10
  • This library depends on @abandonware/noble.
    • As far as I confirmed, additional libraries are not required.

Installation

Install toio.js using yarn. If yarn command is not existed, type npm install -g yarn to install.

yarn install
yarn build

Usage

Here is a quick example to get you started.

const { NearestScanner } = require('@toio/scanner')

async function main() {
  // start a scanner to find the nearest cube
  const cube = await new NearestScanner().start()

  // connect to the cube
  await cube.connect()

  // move the cube
  cube.move(100, 100, 1000)
  //         |    |     `--- duration [ms]
  //         |    `--------- right motor speed
  //         `-------------- left motor speed
}

main()

📝 Documentation

✅ Verified Environment

Linux

Raspbian GNU/Linux 9.11 on Model B+

📦 Packages

Package name Readme Description
@toio/scanner packages/scanner Cube scanner
@toio/cube packages/cube Cube BLE API wrapper

🎮 Example

How to play sample application

sudo yarn example:<name of example>                  # start sample application (see below)

Do not forget sudo

List of sample application

Name & Source Command #cubes Mat Description
id-reader yarn example:id-reader 1 Yes read & show toio ID information
keyboard-control yarn example:keyboard-control 1 No move a cube with ↑↓←→
chase yarn example:chase 2 Yes a cube chase another one

Note

  • This repo is for research use

About

Library for controlling toio™Core Cube

License:MIT License


Languages

Language:TypeScript 97.4%Language:JavaScript 2.6%