Skip to content

Commit

Permalink
add README
Browse files Browse the repository at this point in the history
  • Loading branch information
yusakuxxu committed Mar 4, 2020
1 parent 4c5f9b6 commit 089b798
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# cocoro kit javascript SDK

You can run cocorokit with javascript.

## Requirements

This module uses Web Bluetooth API. The support of API is limited.
Please confirm your device following the link (https://caniuse.com/#feat=web-bluetooth).

## Usage

Before run below script, please get cocorokit board and turn on.

```javascript
import CocoroKit from "@ux-xu/cocorokit-js-sdk";

window.cocorokit = new CococoKit(onConnected); // callback on connected.
window.cocorokit.connect();

// after connected
window.cocorokit.spin(CocoroKit.CONST.SPIN.RIGHT, 100); // Spin right motor by 100% power.
window.cocorokit.reverse(CocoroKit.CONST.REVERSE.RIGHT, 100); // Reverse right motor by 100% power.
```

## Functions

```javascript
/**
* Spin motor
* @param {Object} motorSet Cocorokit.CONST.SPIN.RIGHT|LEFT
* @param {Number} ratio 0 - 100
*/
spin(motorSet, ratio) {}

/**
* Reverse motor
* @param {Object} motorSet Cocorokit.CONST.REVERSE.RIGHT|LEFT
* @param {Number} ratio 0 - 100
*/
reverse(motorSet, ratio) {}

/**
* Stop motor
* @param {Array} motorSet Cocorokit.CONST.STOP.RIGHT|LEFT
*/
stop(motorSet) {}

/**
* Change LED color
* @param {Object} color Cocorokit.CONST.COLOR.RED|GREEN|BLUE
* @param {Number} ratio 0 - 100
*/
color(color, ratio) {}

/**
* Clear current values
* @param {Object} type Cocorokit.CONST.RESET.ALL|MOTOR|LED
*/
reset(type) {}
```
1 change: 1 addition & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,4 @@ class CocoroKit {
}

module.exports = CocoroKit;
module.exports.default = CocoroKit;

0 comments on commit 089b798

Please sign in to comment.